43 std::string
padHex(std::uint16_t v) {
44 std::ostringstream os;
45 os << std::setfill(
'0') << std::setw(4) << std::hex << v;
49 int main(
int argc,
char *argv[]) {
52 function<osvr::usbserial::Enumerator()> enumerate = [] {
53 return osvr::usbserial::enumerate();
63 cerr <<
"Could not parse first command line argument as a "
74 cerr <<
"Could not parse second command line argument as "
80 cout <<
"Will enumerate USB Serial devices with hex VID:PID "
83 enumerate = [vID, pID] {
return osvr::usbserial::enumerate(vID, pID); };
85 }
else if (argc != 1) {
86 cerr <<
"Usage: either pass no arguments to enumerate all USB "
87 "Serial devices, or pass two arguments: a hex VID and PID "
93 cout <<
"Will enumerate all USB Serial devices.\n" << endl;
96 for (
auto &&dev : enumerate()) {
97 cout << setfill(
'0') << setw(4) << hex << dev.getVID() <<
":"
98 << setfill(
'0') << setw(4) << hex << dev.getPID() <<
" "
99 << dev.getPlatformSpecificPath() << endl;
std::string padHex(std::uint16_t v)
Returns a hex value always padded out to 4 digits.