liblightmodbus 3.0
A lightweight, header-only, hardware-agnostic Modbus RTU/TCP library
|
Liblightmodbus v3.0 introduces a new type for error handling - ModbusErrorInfo - returned by majority of the library functions. This new type allows to store both error type and its source - whether it was caused by an invalid request/response frame or by an actual library/user error.
In older versions, error checking would usually look like this:
In the new version, it's a bit more sophisticated:
modbusGetGeneralError()
, modbusGetRequestError()
and modbusGetResponseError()
return a ModbusError enum value which can be easily handled with a switch statement.
You can find more information about errors returned by certain functions in their documentation. For example, please take a look at modbusParseResponseRTU()
.
ModbusErrorInfo
directly. They are not considered a part of the library interface, and hence are subject to change in future versions of the library. Instead, please use functions described above.