MBM_FC03_HoldingRegRdFP() - Modbus-M
This function is called from YOUR application code to read 32-bit floating-point registers from a Modbus slave.
Prototype
CPU_INT16U MBM_FC03_HoldingRegRdFP (MODBUS_CH *pch, CPU_INT08U slave_node, CPU_INT16U start_addr, CPU_FP32 *p_reg_tbl, CPU_INT16U nbr_regs);
Arguments
pch
is a pointer to the channel (returned by MB_CfgCh()
). This pointer specifies onto which channel the Modbus master will be communicating on. Of course, ‘pch
’ must have been configured as a Master when you configured the channel.
slave_node
specifies the slave ‘node address’ that you desire to read the registers from. This can be a number between 1 and 255 but needs to match the number assigned to the slave node.
start_addr
specifies the start address of the floating-point holding registers. This can be from MODBUS_CFG_FP_START_IX
to 65535 (of the slave) and assumes that you enabled floating-point support by setting MODBUS_CFG_FP_EN
to DEF_ENABLED
in mb_cfg.h
in the slave.
p_reg_tbl
is a pointer to an array of 32-bit IEEE-754 format floating-point values that will receive the value of all the registers you are reading. The size of the array needs to be at least nbr_regs
.
nbr_regs
specifies the number of registers you want to read from the slave.
Returned Value
MODBUS_ERR_NONE
if the call was successful.
MODBUS_ERR_RX
if a response was not received from the slave within the timeout specified for this channel (see MB_CfgCh()
).
MODBUS_ERR_SLAVE_ADDR
If the transmitted slave address doesn't correspond to the received slave address
MODBUS_ERR_FC
If the transmitted function code doesn't correspond to the received function code
MODBUS_ERR_BYTE_COUNT
If the expected number of bytes to receive doesn't correspond to the number of bytes received.
Notes / Warnings
The floating-point format corresponds to the Daniels Flow control extensions. Specifically, a register is assumed to be 32 bits and uses the IEEE-754 format.
Floating-support must have been enabled in the slave you are communicating with and, the start address of the floating-point registers (MODBUS_CFG_FP_START_IX)
corresponds to that of the slave.
Called By
Your Modbus master application.