modbuspp
1.1.40
C++ wrapper for the libmodbus library
|
Network layer base class (backend) More...
#include <netlayer.h>
Public Member Functions | |
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... | |
NetLayer () | |
Constructor. | |
virtual bool | prepareToSend (Message &msg) |
Prepare the message msg before sending. More... | |
virtual int | sendRawMessage (const Message *msg) |
Send a request/response msg via the socket of the context() More... | |
const std::string & | settings () const |
Returns the connection settings. More... | |
virtual | ~NetLayer () |
Destructor. | |
Static Public Member Functions | |
static bool | checkMessage (const Message &msg) |
Return true if the message is valid for this backend. | |
static std::string | lastError () |
last error message More... | |
Network layer base class (backend)
const std::string& Modbus::NetLayer::connection | ( | ) | const |
Returns the connection used.
Serial port or host depending on the backend.
modbus_t* Modbus::NetLayer::context | ( | ) |
libmodbus context
context is an opaque structure containing all necessary information to establish a connection with other Modbus devices according to the selected variant.
const modbus_t* Modbus::NetLayer::context | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
static |
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.
Net Modbus::NetLayer::net | ( | ) | const |
Underlying layer used (backend)
This function allows to know the underlying layer used.
|
virtual |
Prepare the message msg before sending.
This function updates the ADU header or adds the CRC at the end depending on the network used..
Reimplemented in Modbus::RtuLayer, and Modbus::TcpLayer.
|
virtual |
Send a request/response msg via the socket of the context()
This function can be used to send message not handled by the library. The message is transmitted "raw", without any modification.
Reimplemented in Modbus::RtuLayer, and Modbus::TcpLayer.
const std::string& Modbus::NetLayer::settings | ( | ) | const |
Returns the connection settings.
IP port or speed, parity and stop bit depending on the backend