Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This function is used to configure each Modbus channel in your product. MB_CfgCh() MUST be called AFTER calling MB_Init(). The function prototype is:

Prototype

MODBUS_CH  *MB_CfgCh (CPU_INT08U  node_addr, 
                      CPU_INT08U  master_slave,
                      CPU_INT32U  rx_timeout, 
                      CPU_INT08U  modbus_mode, 
                      CPU_INT08U  port_nbr, 
                      CPU_INT32U  baud, 
                      CPU_INT08U  bits, 
                      CPU_INT08U  parity, 
                      CPU_INT08U  stops, 
                      CPU_INT08U  wr_en);

Arguments

node_addr

is the node address of the channel as seen by the Modbus master connected to your product. Each channel can be ‘seen’ as having the same node address or have different node addresses for each channel.

...

this argument specifies whether a Modbus master is allowed to send ‘write’ commands to this Modbus channel. This argument can either be MODBUS_WR_EN or MODBUS_WR_DIS. In other words, if you don’t want a Modbus master to change values in your product, simply specify MODBUS_WR_DIS. Note that your application code can actually change this setting at run-time by calling MB_WrEnSet() (see section 3.06).

Returned Value

The function returns a pointer to the created channel which you can use when calling other functions.

Notes / Warnings

None

Called By

Your Modbus master or slave application.