*cbFunc[]()

Description

cbFunc is a callback function pointer array. When poll() receives the corresponding function code, it will call the corresponding function pointed to in the cbFunc array.

Syntax

uint8_t Func1(function, address, length) { return EXCEPTION_CODE; } node1.cbFunc[MODBUS_CB_CODES] = Func1;

Parameters

node1: ModbusSlaveNode object.

Func1: User-defined function, returns a Byte EXCEPTION_CODE.

function: Function code of Modbus packet.

address: Address to be accessed by Modbus packet.

length: Length of space to be accessed by Modbus packet.

cbFunc[]: Callback function array.

MODBUS_CB_CODES: Index value of callback function array, supports the following function codes.

  • MODBUS_CB_READ_COILS
  • MODBUS_CB_READ_DISCRETE_INPUTS
  • MODBUS_CB_READ_HOLDING_REGISTERS
  • MODBUS_CB_READ_INPUT_REGISTERS
  • MODBUS_CB_WRITE_SINGLE_COIL
  • MODBUS_CB_WRITE_SINGLE_REGISTER
  • MODBUS_CB_WRITE_MULTIPLE_COILS
  • MODBUS_CB_WRITE_MULTIPLE_REGISTERS
  • MODBUS_CB_MASK_WRITE_REGISTER

Example

Please refer to Modbus Slave Example

See Also

ModbusMasterNode::poll()


Library Reference

The text in the 86Duino reference is modified from the Arduino reference and is licensed under the Creative Commons Attribution-ShareAlike 3.0 License. The code examples in the reference have been released into the public domain.