Test that reads data on serial port.
#include <iostream>
#include <stdlib.h>
#include <visp3/core/vpTime.h>
#include <visp3/core/vpSerial.h>
int main(int argc, char **argv)
{
#if !defined(_WIN32)
std::string port;
unsigned long baud = 9600;
for (int i = 0; i < argc; i++) {
if (std::string(argv[i]) == "--port")
port = std::string(argv[i + 1]);
else if (std::string(argv[i]) == "--baud") {
baud = (unsigned long)atol(argv[i + 1]);
} else if (std::string(argv[i]) == "--help") {
std::cout << "\nUsage: " << argv[0] << " [--port <serial name>] [--baud <baud rate>] [--help]\n" << std::endl;
return EXIT_SUCCESS;
}
}
if (port.empty()) {
std::cout << "\nSerial port not specified." << std::endl;
std::cout << "\nUsage: " << argv[0] << " [--port <serial name>] [--baud <baud rate>] [--help]\n" << std::endl;
return EXIT_SUCCESS;
}
std::cout << "Try to connect to port \"" << port << "\" with baud rate " << baud << std::endl;
do {
std::string line = serial.
readline(
"\n");
if (!line.empty()) {
std::cout << "Read line: " << line << std::endl;
}
#else
(void)argc;
(void)argv;
std::cout << "Serial test is only working on unix-like OS." << std::endl;
#endif
return EXIT_SUCCESS;
}
std::string readline(const std::string &eol)
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeSecond()