2011-03-16 08:03:54 -05:00
|
|
|
#include <string>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
#include "serial.h"
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
2011-03-22 10:39:28 -05:00
|
|
|
if(argc < 2) {
|
|
|
|
|
std::cerr << "Usage: test_serial <serial port address>" << std::endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
std::string port(argv[1]);
|
2011-03-16 08:03:54 -05:00
|
|
|
|
2011-03-22 10:39:28 -05:00
|
|
|
serial::Serial serial(port, 115200, 250);
|
2011-03-16 08:03:54 -05:00
|
|
|
|
2011-03-18 17:51:17 -05:00
|
|
|
int count = 0;
|
2011-03-21 08:06:14 -05:00
|
|
|
while (count >= 0) {
|
2011-03-22 10:39:28 -05:00
|
|
|
int bytes_wrote = serial.write("Testing.");
|
|
|
|
|
std::string result = serial.read(8);
|
2011-03-21 08:06:14 -05:00
|
|
|
if(count % 10 == 0)
|
|
|
|
|
std::cout << ">" << count << ">" << bytes_wrote << ">" << result << std::endl;
|
2011-03-18 17:51:17 -05:00
|
|
|
|
2011-03-21 08:06:14 -05:00
|
|
|
count += 1;
|
2011-03-16 08:03:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2011-03-18 19:02:32 -05:00
|
|
|
}
|