liblightmodbus 3.0
A lightweight, header-only, hardware-agnostic Modbus RTU/TCP library
Loading...
Searching...
No Matches
Porting code from v2.0 to v3.0

The table below presents a brief overview of changes that need to be applied to existing code in order to make it work with liblightmodbus v3.0.

Task Changes
Slave init Update call to modbusSlaveInit() according to Slave initialization.
Master init Update call to modbusMasterInit() according to Master initialization.
Slave cleanup Rename modbusSlaveEnd() to modbusSlaveDestroy()
Master cleanup Rename modbusMasterEnd() to modbusMasterDestroy()
Error handling Use modbusIsOk() and modbusGetGeneralError(). See Error handling.
Parsing requests Use modbusParseRequestRTU() instead of modbusParseRequest(). Provide slave address and the request frame as arguments.
Register callback Slave register callback now takes arguments in a struct. See Register callback.
Register/coil arrays Write a register callback accessing your own array instead. See Register callback.
Register/coil write protection Return exceptions from the register callback in response to R/W access check queries.
Accessing slave's response Use modbusSlaveGetResponse() and modbusSlaveGetResponseLength() instead of directly accessing the fields in ModbusSlave.
Building requests Use modbusBuildRequest*RTU() instead of modbusBuildRequest*().
Accessing master's request Use modbusMasterGetRequest() and modbusMasterGetRequestLength() instead of directly accessing the fields in ModbusMaster.
Parsing responses Use modbusParseResponseRTU() instead of modbusParseResponse(). Provide both request and response frames as arguments.
Receiving data Implement a data callback to receive the data on the master end — see Data callback.
Endianness operations Use modbusRLE(), modbusRBE(), modbusWLE() and modbusWBE().
Mask read/write modbusMaskRead() and modbusMaskWrite() no longer provide bounds checking.
Static memory allocation Implement a custom static memory allocator — see Static memory allocation.
User's context pointer Use modbusMasterSetUserPointer(), modbusMasterGetUserPointer(), modbusSlaveSetUserPointer() and modbusSlaveGetUserPointer()
User's functions Provide an array with all functions you want to be used to modbusSlaveInit() or modbusMasterInit()