mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
Updating the example to allow variable bauds
This commit is contained in:
parent
241daf3073
commit
5324caf2a3
@ -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())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user