get_serial_number.cpp
Go to the documentation of this file.
1 
11 #include <iostream>
12 
13 #include "kobuki_ftdi/scanner.hpp"
14 
15 int main(int argc, char** argv)
16 {
17  int ret_val;
18  FTDI_Scanner scanner;
19 
20  ret_val = scanner.scan();
21  if (ret_val <= 0) {
22  std::cout << "FTDI device not found!!!" << std::endl;
23  return -1;
24  }
25 
26  unsigned int no_devices = (unsigned int)ret_val;
27  std::cout << no_devices << " device(s) found." << std::endl;
28 
29  std::string serial_number, manufacturer, product;
30  for( unsigned int i=0; i<no_devices; i++ )
31  {
32  ret_val = scanner.get_serial_id(i, serial_number);
33  if (ret_val < 0) break;
34 
35  ret_val = scanner.get_manufacturer(i, manufacturer);
36  if (ret_val < 0) break;
37 
38  ret_val = scanner.get_product(i, product);
39  if (ret_val < 0) break;
40 
41  std::cout << std::endl;
42  std::cout << "Device #" << i << std::endl;
43  std::cout << " Manufacturer : " << manufacturer << std::endl;
44  std::cout << " Product : " << product << std::endl;
45  std::cout << " Serial Number: " << serial_number << std::endl;
46  ret_val = 0;
47  }
48 
49  if (ret_val < 0) std::cerr << "Something went wrong. Did you run with sudo." << std::endl;
50  return ret_val;
51 }
int main(int argc, char **argv)
int get_serial_id(unsigned int index, std::string &serial_id)
Definition: scanner.hpp:143
int scan()
Definition: scanner.hpp:89
int get_product(unsigned int index, std::string &product)
Definition: scanner.hpp:173
int get_manufacturer(unsigned int index, std::string &manufacturer)
Definition: scanner.hpp:158
A Scanner class.
Definition: scanner.hpp:56
Scan the usb devices, and retrieve its serial id and else descriptions, especially for ftdi devices...


kobuki_ftdi
Author(s): Younghun Ju
autogenerated on Mon Jun 10 2019 13:41:32