make serial handling more robust to hw errors

This commit is contained in:
2023-08-22 11:27:21 +02:00
parent 2ec88114c6
commit 229932b274
2 changed files with 42 additions and 12 deletions

View File

@ -7,6 +7,7 @@
#ifdef __cplusplus
#include <iostream>
#include <stdexcept>
#include <string.h>
#endif
#define BAUDRATE B38400
@ -32,7 +33,7 @@ class serialIoException: public std::runtime_error
int fd;
int errorNumber;
serialIoException(int fd_, int errorNumber_):
std::runtime_error("file descriptor error, fd: " + std::to_string(fd_) + " errno: " + std::to_string(errorNumber_) + "\n"), fd(fd_), errorNumber(errorNumber_)
std::runtime_error("file descriptor error, fd: " + std::to_string(fd_) + " error: " + strerror(errorNumber_) + "\n"), fd(fd_), errorNumber(errorNumber_)
{}
};
#endif