This commit is contained in:
2021-08-18 23:06:12 +02:00
parent 6d6bbc0405
commit 72b67feb25
4 changed files with 26 additions and 16 deletions

View File

@@ -134,6 +134,19 @@ void TimeoutSerial::read(char *data, size_t size)
}
}
int TimeoutSerial::readChar(int delay)
{
vector<char> result(1,'\0');
timeout = posix_time::seconds(delay);
try {
result = read(1);
return static_cast<int>(result[0]);
} catch (boost::system::system_error& e) {
return -1;
}
}
std::vector<char> TimeoutSerial::read(size_t size)
{
vector<char> result(size,'\0');//Allocate a vector with the desired size