#include <serial_port.h>
Definition at line 82 of file serial_port.h.
◆ Result
Enumerator |
---|
SUCCESS | |
TIMEOUT | |
INTERRUPTED | |
ERROR | |
Definition at line 86 of file serial_port.h.
◆ SerialPort()
swri_serial_util::SerialPort::SerialPort |
( |
| ) |
|
◆ ~SerialPort()
swri_serial_util::SerialPort::~SerialPort |
( |
| ) |
|
Destructor.
Closes serial port if open.
Definition at line 80 of file serial_port.cpp.
◆ Close()
void swri_serial_util::SerialPort::Close |
( |
| ) |
|
|
virtual |
◆ ErrorMsg()
std::string swri_serial_util::SerialPort::ErrorMsg |
( |
| ) |
const |
|
inline |
Get the most recent error message.
Definition at line 150 of file serial_port.h.
◆ Open()
Open and configure the serial port.
The default configuration is: baud = 115200 parity = NO_PARITY flow control = false data bits = 8 stop bits = 1 low latency mode = false
- Parameters
-
[in] | device | The OS path of the device. |
[in] | config | The port configuration settings. |
Definition at line 94 of file serial_port.cpp.
◆ ParseBaudRate()
int32_t swri_serial_util::SerialPort::ParseBaudRate |
( |
int32_t |
baud | ) |
|
|
private |
Parses integer and enumerated baud rates into enumerated baud rates.
- Parameters
-
[in] | baud | The baud rate (either integer or enumerated) |
- Returns
- The enumerated baud rate or -1 if invalid.
Definition at line 228 of file serial_port.cpp.
◆ ReadBytes()
SerialPort::Result swri_serial_util::SerialPort::ReadBytes |
( |
std::vector< uint8_t > & |
output, |
|
|
size_t |
max_bytes, |
|
|
int32_t |
timeout |
|
) |
| |
|
virtual |
Read bytes from the serial port.
Appends up to max_bytes into the provided vector. If max_bytes is 0, it reads all available bytes.
- Parameters
-
[out] | output | The output buffer for bytes read in. |
[in] | max_bytes | The maximum number of bytes to read. If set to 0, all available bytes are read. |
[in] | timeout | The maximum time to block in milliseconds |
- Returns
- Read result (SUCCESS, TIMEOUT, INTERRUPTED, or ERROR).
Definition at line 352 of file serial_port.cpp.
◆ SetLowLatencyMode()
bool swri_serial_util::SerialPort::SetLowLatencyMode |
( |
| ) |
|
|
private |
Attempts to put serial port in low latency mode.
Definition at line 201 of file serial_port.cpp.
◆ Write()
int32_t swri_serial_util::SerialPort::Write |
( |
const std::vector< uint8_t > & |
input | ) |
|
|
virtual |
◆ error_msg_
std::string swri_serial_util::SerialPort::error_msg_ |
◆ fd_
int swri_serial_util::SerialPort::fd_ |
The documentation for this class was generated from the following files: