#ifndef SERIAL_H #define SERIAL_H #include #include #include #ifdef __cplusplus #include #include #include #endif #define BAUDRATE B38400 ssize_t sWrite(int port, 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); #ifdef __cplusplus void printRates(); #endif 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_) + " error: " + strerror(errorNumber_) + "\n"), fd(fd_), errorNumber(errorNumber_) {} }; #endif #endif // SERIAL_H