88 unsigned long baud = 0;
89 #if defined(WIN32) && !defined(__MINGW32__) 90 sscanf_s(argv[2],
"%lu", &baud);
92 sscanf(argv[2],
"%lu", &baud);
98 cout <<
"Is the serial port open?";
99 if(my_serial.isOpen())
100 cout <<
" Yes." << endl;
102 cout <<
" No." << endl;
108 test_string = argv[3];
110 test_string =
"Testing.";
114 cout <<
"Timeout == 1000ms, asking for 1 more byte than written." << endl;
116 size_t bytes_wrote = my_serial.write(test_string);
118 string result = my_serial.read(test_string.length()+1);
120 cout <<
"Iteration: " << count <<
", Bytes written: ";
121 cout << bytes_wrote <<
", Bytes read: ";
122 cout << result.length() <<
", String read: " << result << endl;
130 cout <<
"Timeout == 250ms, asking for 1 more byte than written." << endl;
132 size_t bytes_wrote = my_serial.write(test_string);
134 string result = my_serial.read(test_string.length()+1);
136 cout <<
"Iteration: " << count <<
", Bytes written: ";
137 cout << bytes_wrote <<
", Bytes read: ";
138 cout << result.length() <<
", String read: " << result << endl;
145 cout <<
"Timeout == 250ms, asking for exactly what was written." << endl;
147 size_t bytes_wrote = my_serial.write(test_string);
149 string result = my_serial.read(test_string.length());
151 cout <<
"Iteration: " << count <<
", Bytes written: ";
152 cout << bytes_wrote <<
", Bytes read: ";
153 cout << result.length() <<
", String read: " << result << endl;
160 cout <<
"Timeout == 250ms, asking for 1 less than was written." << endl;
162 size_t bytes_wrote = my_serial.write(test_string);
164 string result = my_serial.read(test_string.length()-1);
166 cout <<
"Iteration: " << count <<
", Bytes written: ";
167 cout << bytes_wrote <<
", Bytes read: ";
168 cout << result.length() <<
", String read: " << result << endl;
void print_usage()
Definition: serial_example.cc:62
void enumerate_ports()
Definition: serial_example.cc:47
static uint32_t max()
Definition: serial.h:102
static Timeout simpleTimeout(uint32_t timeout)
Definition: serial.h:112