1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00
serial/tests/serial_tests.cc
John Harrison 8f4b34cc03 Adding in an internal buffer to Serial, this is independent of the SerialImpl and buffers reads to help performance.
Also correcting my styles to match the style guide and adding in some documentation.
2012-01-15 02:06:38 -06:00

34 lines
708 B
C++

#include <string>
#include <iostream>
#include "serial/serial.h"
using std::string;
using std::cout;
using std::endl;
using serial::Serial;
using serial::SerialExecption;
int main(int argc, char **argv) {
try {
Serial s("/dev/tty.usbserial-A900adHq", 115200, 2000);
s.flush();
long long count = 0;
while (1) {
// size_t available = s.available();
// cout << "avialable: " << available << endl;
string line = s.readline();
cout << count << ": " << line << line.length() << endl;
count++;
}
}
catch (SerialExecption e)
{
cout << "Caught SerialException: " << e.what() << endl;
}
catch (...)
{
cout << "Caught an error." << endl;
}
}