Serial (RS-485) driver.
More...
#include <SerialDriver.h>
|
| SerialDriver () |
| CTOR.
|
|
| ~SerialDriver () |
| DTOR.
|
|
ErrorCode | Open (const std::string &port) |
| Open the serial port.
|
|
void | Close () noexcept |
| Close the serial port.
|
|
ErrorCode | Write (std::string_view data, unsigned int timeout_ms) const |
| Write data over the serial port.
|
|
Result< std::string > | ReadLine (unsigned int timeout_ms) const |
| Read a line from the serial port.
|
|
void | SetDeviceID (unsigned int id) |
| Set the target device ID.
|
|
unsigned int | GetDeviceID () const |
| Get the target device ID.
|
|
bool | IsSendOnly () const |
| Determine whether the port is send-only.
|
|
◆ GetDeviceID()
unsigned int GetDeviceID |
( |
| ) |
const |
|
virtual |
Get the target device ID.
- Returns
- Target device ID.
Reimplemented from CommDriver.
◆ IsSendOnly()
bool IsSendOnly |
( |
| ) |
const |
|
virtual |
Determine whether the port is send-only.
This is true when the target device ID is 32+.
- Returns
- Whether the port is send-only.
Reimplemented from CommDriver.
◆ Open()
Open the serial port.
- Parameters
-
[in] | port | the serial port to open, such as COM5 or /dev/ttyS2 |
- Returns
- An error code.
◆ ReadLine()
Result< std::string > ReadLine |
( |
unsigned int |
timeout_ms | ) |
const |
|
virtual |
Read a line from the serial port.
- Parameters
-
[in] | timeout_ms | read timeout in milliseconds |
- Returns
- Result containing the line read or an error code.
Implements CommDriver.
◆ SetDeviceID()
void SetDeviceID |
( |
unsigned int |
id | ) |
|
|
virtual |
Set the target device ID.
- Parameters
-
[in] | id | target device ID, 0-31 or 32+ to broadcast to all devices on the bus |
Reimplemented from CommDriver.
◆ Write()
ErrorCode Write |
( |
std::string_view |
data, |
|
|
unsigned int |
timeout_ms |
|
) |
| const |
|
virtual |
Write data over the serial port.
- Parameters
-
[in] | data | data to send |
[in] | timeout_ms | send timeout in milliseconds (ignored; unsupported by serial ports) |
- Returns
- An error code.
Implements CommDriver.
The documentation for this class was generated from the following file: