fix race bug
This commit is contained in:
17
serial_io.h
17
serial_io.h
@ -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
|
||||
|
Reference in New Issue
Block a user