ABS SCPI Driver 0.2.0
ABS SCPI driver library
Loading...
Searching...
No Matches
SerialDriver Class Referencefinal

Serial (RS-485) driver. More...

#include <SerialDriver.h>

+ Inheritance diagram for SerialDriver:
+ Collaboration diagram for SerialDriver:

Detailed Description

Serial (RS-485) driver.

Public Member Functions

 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.
 

Member Function Documentation

◆ 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()

ErrorCode Open ( const std::string &  port)

Open the serial port.

Parameters
[in]portthe 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_msread 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]idtarget 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]datadata to send
[in]timeout_mssend 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: