1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 03:34:53 +08:00

Changed the serial::PortDescription struct.

- Renamed to PortInfo.

- "friendly_name" field is now "description".
This commit is contained in:
Craig Lilley 2014-04-24 02:17:07 +01:00
parent b8479822f7
commit 301a3d4b27
4 changed files with 21 additions and 21 deletions

View File

@ -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() );
}
}

View File

@ -698,15 +698,15 @@ public:
/*!
* 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<PortDescription>
std::vector<PortInfo>
list_ports();
} // namespace serial

View File

@ -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<PortDescription>
vector<PortInfo>
serial::list_ports()
{
vector<PortDescription> results;
vector<PortInfo> results;
vector<string> 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 );

View File

@ -11,7 +11,7 @@
#include <devguid.h>
#include <cstring>
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<PortDescription>
vector<PortInfo>
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);