Skip to content

Commit

Permalink
Changed the serial::PortDescription struct.
Browse files Browse the repository at this point in the history
- Renamed to PortInfo.

- "friendly_name" field is now "description".
  • Loading branch information
Craig Lilley committed Apr 24, 2014
1 parent b847982 commit 301a3d4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions examples/serial_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ void my_sleep(unsigned long milliseconds) {

void enumerate_ports()
{
vector<serial::PortDescription> devices_found = serial::list_ports();
vector<serial::PortInfo> devices_found = serial::list_ports();

vector<serial::PortDescription>::iterator iter = devices_found.begin();
vector<serial::PortInfo>::iterator iter = devices_found.begin();

while( iter != devices_found.end() )
{
serial::PortDescription device = *iter++;
serial::PortInfo device = *iter++;

printf( "(%s, %s, %s)\n", device.port.c_str(), device.friendly_name.c_str(),
printf( "(%s, %s, %s)\n", device.port.c_str(), device.description.c_str(),
device.hardware_id.c_str() );
}
}
Expand Down
16 changes: 8 additions & 8 deletions include/serial/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,27 +698,27 @@ class PortNotOpenedException : public std::exception
/*!
* Structure that describes a serial device.
*/
struct PortDescription {
struct PortInfo {

/*! Address of port (this can be passed to the constructor of Serial) */
/*! Address of port (this can be passed to the constructor of Serial). */
std::string port;

/*! Has additional information when available */
std::string friendly_name;
/*! Human readable description if available. */
std::string description;

/*! Hardware ID or "n/a" if not available */
/*! Hardware ID (e.g. VID:PID of USB serial devices) or "n/a" if not available. */
std::string hardware_id;

};

/* Lists the serial ports available on the system
*
* Returns a vector of available serial ports, each represented
* by a serial::PortDescription data structure:
* by a serial::PortInfo data structure:
*
* \return vector of serial::PortDescription.
* \return vector of serial::PortInfo.
*/
std::vector<PortDescription>
std::vector<PortInfo>
list_ports();

} // namespace serial
Expand Down
10 changes: 5 additions & 5 deletions src/impl/list_ports/list_ports_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "serial/serial.h"

using serial::PortDescription;
using serial::PortInfo;
using std::istringstream;
using std::ifstream;
using std::getline;
Expand Down Expand Up @@ -292,10 +292,10 @@ usb_sysfs_hw_string(const string& sysfs_path)
return format("USB VID:PID=%s:%s %s", vid.c_str(), pid.c_str(), serial_number.c_str() );
}

vector<PortDescription>
vector<PortInfo>
serial::list_ports()
{
vector<PortDescription> results;
vector<PortInfo> results;

vector<string> search_globs;
search_globs.push_back("/dev/ttyACM*");
Expand All @@ -318,9 +318,9 @@ serial::list_ports()

string hardware_id = sysfs_info[1];

PortDescription device_entry;
PortInfo device_entry;
device_entry.port = device;
device_entry.friendly_name = friendly_name;
device_entry.description = friendly_name;
device_entry.hardware_id = hardware_id;

results.push_back( device_entry );
Expand Down
8 changes: 4 additions & 4 deletions src/impl/list_ports/list_ports_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
#include <devguid.h>
#include <cstring>

using serial::PortDescription
using serial::PortInfo
using std::vector;
using std::string;

static const DWORD port_name_max_length = 256;
static const DWORD friendly_name_max_length = 256;
static const DWORD hardware_id_max_length = 256;

vector<PortDescription>
vector<PortInfo>
serial::list_ports()
{
decltype( serial::list_ports() ) devices_found;
Expand Down Expand Up @@ -113,9 +113,9 @@ serial::list_ports()
else
hardware_id[0] = '\0';

PortDescription port_entry;
PortInfo port_entry;
port_entry.port = port_name;
port_entry.friendly_name = friendly_name;
port_entry.description = friendly_name;
port_entry.hardware_id = hardware_id;

devices_found.push_back(port_entry);
Expand Down

0 comments on commit 301a3d4

Please sign in to comment.