1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00

Updating the example to allow variable bauds

This commit is contained in:
John Harrison 2012-01-23 11:55:17 -06:00
parent 241daf3073
commit 5324caf2a3

View File

@ -7,14 +7,17 @@
int run(int argc, char **argv)
{
if(argc < 2) {
std::cerr << "Usage: test_serial <serial port address>" << std::endl;
if(argc < 3) {
std::cerr << "Usage: test_serial <serial port address> <baudrate>" << std::endl;
return 0;
}
std::string port(argv[1]);
unsigned long baud = 0;
sscanf(argv[2], "%lu", &baud);
// port, baudrate, timeout in milliseconds
serial::Serial serial(port, 115200, 250);
serial::Serial serial(port, baud, 250);
std::cout << "Is the serial port open?";
if(serial.isOpen())