liblightmodbus
2.0
A lightweight, cross-platform Modbus RTU library
|
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... | |
ModbusError modbusMasterEnd | ( | ModbusMaster * | status | ) |
Frees memory used by the ModbusMaster structure, previously initialized with modbusMasterInit.
status | The master structure to be freed |
ModbusError modbusMasterInit | ( | ModbusMaster * | status | ) |
Performs initialization of the ModbusMaster structure.
status | The master structure to be initialized |
ModbusError modbusParseException | ( | ModbusMaster * | status, |
ModbusParser * | parser | ||
) |
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.
status | The master structure to work on |