modbuspp
1.1.40
C++ wrapper for the libmodbus library
|
RTU serial link layer. More...
#include <rtulayer.h>
Public Member Functions | |
int | baud () const |
Return the baudrate. | |
const std::string & | connection () const |
Returns the connection used. More... | |
modbus_t * | context () |
libmodbus context More... | |
const modbus_t * | context () const |
uint16_t | maxAduLength () const |
Returns the maximum ADU length. | |
Net | net () const |
Underlying layer used (backend) More... | |
char | parity () const |
Return the parity. | |
const std::string & | port () const |
Name of the serial port. More... | |
virtual bool | prepareToSend (Message &msg) |
SerialRts | rts () |
Get the current RTS mode. More... | |
int | rtsDelay () |
Get the current RTS delay. More... | |
RtuLayer (const std::string &port, const std::string &settings) | |
Constructor. | |
virtual int | sendRawMessage (const Message *msg) |
SerialMode | serialMode () |
Get the current serial mode. More... | |
bool | setRts (SerialRts rts) |
Set the RTS mode. More... | |
bool | setRtsDelay (int us) |
Set the RTS delay. More... | |
bool | setSerialMode (SerialMode mode) |
Set the serial mode. More... | |
const std::string & | settings () const |
Returns the connection settings. More... | |
int | stop () const |
Return the bits of stop. | |
Static Public Member Functions | |
static int | baud (const std::string &settings) |
Extracts the baudrate from a settings string. More... | |
static bool | checkMessage (const Message &msg) |
static uint16_t | crc16 (const uint8_t *buf, uint16_t count) |
Performing Modbus CRC16 generation of the buffer buf. | |
static std::string | lastError () |
last error message More... | |
static char | parity (const std::string &settings) |
Extracts the parity from a settings string. More... | |
static int | stop (const std::string &settings) |
Return the stop bits from a settings string. More... | |
RTU serial link layer.
This class can not and should not be instantiated by the user. It provides access to properties and methods specific to the RTU layer.
An instance of this class is created by the constructor Device::Device() of the Device class (or its derived classes) if the RTU layer is selected.
Access to this instance is done using the Device::rtu() method.
|
static |
Extracts the baudrate from a settings string.
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inherited |
Returns the connection used.
Serial port or host depending on the backend.
|
inherited |
libmodbus context
context is an opaque structure containing all necessary information to establish a connection with other Modbus devices according to the selected variant.
|
inherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
staticinherited |
last error message
This function shall return the error message corresponding to the last error. This function must be called right after the instruction that triggered an error.
|
inherited |
Underlying layer used (backend)
This function allows to know the underlying layer used.
|
static |
Extracts the parity from a settings string.
const std::string& Modbus::RtuLayer::port | ( | ) | const |
Name of the serial port.
This property specifies the name of the serial port handled by the OS, eg. "/dev/ttyS0" or "/dev/ttyUSB0".
|
virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Reimplemented from Modbus::NetLayer.
SerialRts Modbus::RtuLayer::rts | ( | ) |
int Modbus::RtuLayer::rtsDelay | ( | ) |
Get the current RTS delay.
This function shall get the current Request To Send delay period.
|
virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Reimplemented from Modbus::NetLayer.
SerialMode Modbus::RtuLayer::serialMode | ( | ) |
Get the current serial mode.
This function shall return the serial mode currently used.
This function is only available on Linux kernels 2.6.28 onwards.
bool Modbus::RtuLayer::setRts | ( | SerialRts | rts | ) |
Set the RTS mode.
This function shall set the Request To Send mode to communicate on a RS485 serial bus.
bool Modbus::RtuLayer::setRtsDelay | ( | int | us | ) |
Set the RTS delay.
This function shall set the Request To Send delay period in microseconds.
bool Modbus::RtuLayer::setSerialMode | ( | SerialMode | mode | ) |
Set the serial mode.
This function shall set the selected serial mode mode.
|
inherited |
Returns the connection settings.
IP port or speed, parity and stop bit depending on the backend
|
static |
Return the stop bits from a settings string.