From 5324caf2a3547f5a088304c3823e86b109808b0e Mon Sep 17 00:00:00 2001 From: John Harrison Date: Mon, 23 Jan 2012 11:55:17 -0600 Subject: [PATCH] Updating the example to allow variable bauds --- examples/serial_example.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/serial_example.cc b/examples/serial_example.cc index 91ae497..af7b666 100644 --- a/examples/serial_example.cc +++ b/examples/serial_example.cc @@ -7,14 +7,17 @@ int run(int argc, char **argv) { - if(argc < 2) { - std::cerr << "Usage: test_serial " << std::endl; + if(argc < 3) { + std::cerr << "Usage: test_serial " << 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())