MBM_FC15_CoilWr() - Modbus-M

MBM_FC15_CoilWr() - Modbus-M

This function is called from YOUR application code to write to multiple coils on a Modbus slave.

Prototype

CPU_INT16U MBM_FC15_CoilWr (MODBUS_CH *pch, CPU_INT08U slave_node, CPU_INT16U slave_addr, CPU_INT08U *p_coil_tbl, CPU_INT16U nbr_coils);

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 change the coil values. This can be a number between 1 and 255 but needs to match the number assigned to the slave node.

slave_addr

specifies the start address of the coils that you want to change. This can be from 0 to 65535.

p_coil_tbl

is an array of values corresponding to the desired values for the coils. The format is assumed to be as follows:

MSB LSB B7 B6 B5 B4 B3 B2 B1 B0 ------------------------------------- p_coil_tbl[0] #8 #7 #1 p_coil_tbl[1] #16 #15 #9 : :

nbr_coils

specifies the number of coils you are changing. Of course, the array pointed to by p_coil_tbl must contain the corresponding number of entries.

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

None

Called By

Your Modbus master application.