liblightmodbus  2.0
A lightweight, cross-platform Modbus RTU library
Functions
master.c File Reference

Functions

ModbusError modbusParseException (ModbusMaster *status, ModbusParser *parser)
 
ModbusError modbusParseResponse (ModbusMaster *status)
 Interprets the incoming response frame located in the master structure. More...
 
ModbusError modbusMasterInit (ModbusMaster *status)
 Performs initialization of the ModbusMaster structure. More...
 
ModbusError modbusMasterEnd (ModbusMaster *status)
 Frees memory used by the ModbusMaster structure, previously initialized with modbusMasterInit. More...
 

Function Documentation

◆ modbusMasterEnd()

ModbusError modbusMasterEnd ( ModbusMaster status)

Frees memory used by the ModbusMaster structure, previously initialized with modbusMasterInit.

Parameters
statusThe master structure to be freed
Returns
A ModbusError error code

◆ modbusMasterInit()

ModbusError modbusMasterInit ( ModbusMaster status)

Performs initialization of the ModbusMaster structure.

Parameters
statusThe master structure to be initialized
Returns
A ModbusError error code

◆ modbusParseException()

ModbusError modbusParseException ( ModbusMaster status,
ModbusParser parser 
)
+ Here is the caller graph for this function:

◆ modbusParseResponse()

ModbusError modbusParseResponse ( ModbusMaster status)

Interprets the incoming response frame located in the master structure.

Calling this function results in processing the frame located in ModbusMaster::response. The received data will be located in ModbusMaster::data or ModbusMaster::exception if slave has responded with an exception frame.

Firstly, this function resets and freed data previously stored in ModbusMaster::exception and ModbusMaster::data.

Afterwards, the frame is validated using modbusCRC() function. If it's not consistent, it's discarded at this point and MODBUS_ERROR_PARSE is returned.

Then, array of user-defined functions is searched. It is important to mention that, user functions override built-in functions. That means, one can disable specific function by simply inserting NULL pointer into the array,

If matching function is found among user-defined or built-in functions, the modbusParseResponse() returns the exact error code the parsing function had returned. Otherwise, MODBUS_ERROR_PARSE is returned.

Parameters
statusThe master structure to work on
Returns
A ModbusError error code
+ Here is the call graph for this function: