fix race bug

This commit is contained in:
2021-10-02 14:22:00 +02:00
parent 15216f7f3a
commit 84dd4bc30a
4 changed files with 71 additions and 26 deletions

View File

@ -6,13 +6,14 @@
#ifdef __cplusplus
#include <iostream>
#include <stdexcept>
#endif
#define BAUDRATE B38400
void sWrite(int port, char string[], size_t length);
ssize_t sWrite(int port, char string[], size_t length);
void sWrite(int port, const char string[], size_t length);
ssize_t sWrite(int port, const char string[], size_t length);
ssize_t sRead(int port, void *buf, size_t count);
@ -24,5 +25,17 @@ int serialport_set_config(int fd, int baud);
int serialport_init(const char* device, int baud = BAUDRATE, bool block = false);
#ifdef __cplusplus
class serialIoException: public std::runtime_error
{
public:
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_)
{}
};
#endif
#endif // SERIAL_H