10 #define tty_ttyUSB_hpp    16 #include <mx/ioutils/fileUtils.hpp>    37                    const std::string & vendor,  
    38                    const std::string & product, 
    39                    const std::string & serial   
    42    std::vector<std::string> devNames;
    45    devNames = mx::ioutils::getFileNames(
"/sys/class/tty/", 
"ttyUSB", 
"", 
"");
    56    for(
size_t i=0; i< devNames.size(); ++i)
    58       struct udev_device *dev;
    60       dev = udev_device_new_from_syspath(udev, devNames[i].c_str());
    64       dev = udev_device_get_parent_with_subsystem_devtype( dev, 
"usb", 
"usb_device");
    68       const char * idVendor = udev_device_get_sysattr_value( dev, 
"idVendor" );
    70       if(idVendor == 
nullptr) 
continue;
    71       if( strcmp( idVendor, vendor.c_str()) != 0) 
continue;
    73       const char * idProduct = udev_device_get_sysattr_value( dev, 
"idProduct" );
    75       if(idProduct == 
nullptr) 
continue;
    76       if( strcmp( idProduct, product.c_str()) != 0) 
continue;
    78       const char * dserial = udev_device_get_sysattr_value( dev, 
"serial" );
    80       if(dserial == 
nullptr)
    82          if( serial != 
"") 
continue;
    84       else if( strcmp( dserial, serial.c_str()) != 0 ) 
continue;
    87       boost::filesystem::path p(devNames[i]);
    88       devName = 
"/dev/" + p.filename().string();
    99 #endif //tty_ttyUSB_hpp Error numbers for the tty utilities. 
 
#define TTY_E_DEVNOTFOUND
 
int ttyUSBDevName(std::string &devName, const std::string &vendor, const std::string &product, const std::string &serial)
Get the ttyUSB device name. 
 
#define TTY_E_UDEVNEWFAILED