From 301a3d4b271244c6973865172de0232c2dd89635 Mon Sep 17 00:00:00 2001 From: Craig Lilley Date: Thu, 24 Apr 2014 02:17:07 +0100 Subject: [PATCH] Changed the serial::PortDescription struct. - Renamed to PortInfo. - "friendly_name" field is now "description". --- examples/serial_example.cc | 8 ++++---- include/serial/serial.h | 16 ++++++++-------- src/impl/list_ports/list_ports_linux.cc | 10 +++++----- src/impl/list_ports/list_ports_win.cc | 8 ++++---- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/serial_example.cc b/examples/serial_example.cc index e81e50e2..a8296353 100644 --- a/examples/serial_example.cc +++ b/examples/serial_example.cc @@ -46,15 +46,15 @@ void my_sleep(unsigned long milliseconds) { void enumerate_ports() { - vector devices_found = serial::list_ports(); + vector devices_found = serial::list_ports(); - vector::iterator iter = devices_found.begin(); + vector::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() ); } } diff --git a/include/serial/serial.h b/include/serial/serial.h index 16f52eaa..baac72e5 100644 --- a/include/serial/serial.h +++ b/include/serial/serial.h @@ -698,15 +698,15 @@ 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; }; @@ -714,11 +714,11 @@ struct PortDescription { /* 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 +std::vector list_ports(); } // namespace serial diff --git a/src/impl/list_ports/list_ports_linux.cc b/src/impl/list_ports/list_ports_linux.cc index 375d6acc..14c154b3 100644 --- a/src/impl/list_ports/list_ports_linux.cc +++ b/src/impl/list_ports/list_ports_linux.cc @@ -22,7 +22,7 @@ #include "serial/serial.h" -using serial::PortDescription; +using serial::PortInfo; using std::istringstream; using std::ifstream; using std::getline; @@ -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 +vector serial::list_ports() { - vector results; + vector results; vector search_globs; search_globs.push_back("/dev/ttyACM*"); @@ -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 ); diff --git a/src/impl/list_ports/list_ports_win.cc b/src/impl/list_ports/list_ports_win.cc index 00cdb52e..d835e1f0 100644 --- a/src/impl/list_ports/list_ports_win.cc +++ b/src/impl/list_ports/list_ports_win.cc @@ -11,7 +11,7 @@ #include #include -using serial::PortDescription +using serial::PortInfo using std::vector; using std::string; @@ -19,7 +19,7 @@ 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 +vector serial::list_ports() { decltype( serial::list_ports() ) devices_found; @@ -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);