48 const std::string ERR_MSG_INVALID_BAUD_RATE =
"Invalid baud rate.";
49 const std::string ERR_MSG_INVALID_CHARACTER_SIZE =
"Invalid character size.";
50 const std::string ERR_MSG_INVALID_FLOW_CONTROL =
"Invalid flow control.";
51 const std::string ERR_MSG_INVALID_PARITY =
"Invalid parity setting.";
52 const std::string ERR_MSG_INVALID_STOP_BITS =
"Invalid number of stop bits.";
53 const std::string ERR_MSG_READ_TIMEOUT =
"Read timeout";
54 const std::string ERR_MSG_PORT_ALREADY_OPEN =
"Serial port already open.";
55 const std::string ERR_MSG_PORT_NOT_OPEN =
"Serial port not open.";
56 const std::string ERR_MSG_INVALID_MODEM_LINE =
"Invalid modem line." ;
61 constexpr int MICROSECONDS_PER_MS = 1000 ;
62 constexpr int MILLISECONDS_PER_SEC = 1000 ;
63 constexpr int MICROSECONDS_PER_SEC = 1000000 ;
68 constexpr int BITS_PER_BYTE = 8 ;
73 constexpr short VMIN_DEFAULT = 1 ;
78 constexpr short VTIME_DEFAULT = 0 ;
84 constexpr char CTRL_Q = 0x11 ;
90 constexpr char CTRL_S = 0x13 ;
95 using DataBuffer = std::vector<uint8_t> ;
131 explicit NotOpen(
const std::string& whatArg [[maybe_unused]])
132 : logic_error(whatArg)
147 : logic_error(whatArg)
161 explicit OpenFailed(
const std::string& whatArg [[maybe_unused]])
162 : runtime_error(whatArg)
179 : runtime_error(whatArg)
191 enum class BaudRate : speed_t
209 BAUD_115200 = B115200,
210 BAUD_230400 = B230400,
214 BAUD_460800 = B460800,
215 BAUD_500000 = B500000,
216 BAUD_576000 = B576000,
217 BAUD_921600 = B921600,
218 BAUD_1000000 = B1000000,
219 BAUD_1152000 = B1152000,
220 BAUD_1500000 = B1500000,
221#if __MAX_BAUD > B2000000
222 BAUD_2000000 = B2000000,
223 BAUD_2500000 = B2500000,
224 BAUD_3000000 = B3000000,
225 BAUD_3500000 = B3500000,
226 BAUD_4000000 = B4000000,
229 BAUD_DEFAULT = BAUD_115200,
230 BAUD_INVALID = std::numeric_limits<speed_t>::max()
236 enum class CharacterSize : tcflag_t
242 CHAR_SIZE_DEFAULT = CS8,
243 CHAR_SIZE_INVALID = std::numeric_limits<tcflag_t>::max()
249 enum class FlowControl : tcflag_t
251 FLOW_CONTROL_HARDWARE,
252 FLOW_CONTROL_SOFTWARE,
254 FLOW_CONTROL_DEFAULT = FLOW_CONTROL_NONE,
255 FLOW_CONTROL_INVALID = std::numeric_limits<tcflag_t>::max()
261 enum class Parity : tcflag_t
266 PARITY_DEFAULT = PARITY_NONE,
267 PARITY_INVALID = std::numeric_limits<tcflag_t>::max()
273 enum class StopBits : tcflag_t
277 STOP_BITS_DEFAULT = STOP_BITS_1,
278 STOP_BITS_INVALID = std::numeric_limits<tcflag_t>::max()
AlreadyOpen(const std::string &whatArg)
Exception error thrown when the serial port is already open.
NotOpen(const std::string &whatArg)
Exception error thrown when the serial port is not open.
OpenFailed(const std::string &whatArg)
Exception error thrown when the serial port could not be opened.
ReadTimeout(const std::string &whatArg)
Exception error thrown when data could not be read from the serial port before the timeout had been e...