modbusOpenX (Function) |
Top Previous Next |
This function will open a connection to a MODBUS network. The connection uses either the RTU, ASCII or TCP protocol.
The device supports both master mode, where the device controls the MODBUS network and polls the slaves, and slave mode, where the device waits for commands from the master. Please note that the TCP protocol can only be used via the LAN network interface, which must be opened before communication is possible.
For NX32L devices, all interfaces can be used with the TCP protocol (from firmware version 1.08.00).
Input: mode : SINT
unit_id : INT (0..247) The address of the RTCU device on the MODBUS network. If this parameter is set to zero, the RTCU device will be the master on the network.
port : DINT (default -1) When port is set to -1, the default port for the selected mode is used.
iface : SINT (default 0) The network interface from which incoming TCP connections are accepted. (See Network) The network interface must be present and connected, when modbusOpenX is called if set. This parameter is ignored if mode != 3 or if the RTCU device is the master. (from firmware version 1.32.00).
con_timeout : UINT (0..30000) (default 1000) The number of milliseconds to try to connect to a slave before timing out. This parameter is ignored if mode != 3 or if the RTCU device is not the master.
baud : DINT (9600,19200,38400,57600,115200) (default 115200) Selects the desired baud rate. This parameter is ignored if mode 3 is selected.
bit : SINT (7/8) (default 8) Selects the number of bits per character. This parameter is ignored if mode 3 is selected. Note: 7 bit without parity bit only works on LX devices.
parity : SINT (0..2) (default 1) Selects the desired parity, 0 is none, 1 is even, and 2 is odd. This parameter is ignored if mode 3 is selected.
stopbit : SINT (1/2) (default 1) Selects number of stop bits. This parameter is ignored if mode 3 is selected.
rs485 : SINT (-1..1) (default -1)
This parameter is ignored if mode 3 is selected.
allow1 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow2 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow3 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow4 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow5 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow6 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow7 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow8 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow9 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
allow10 : DINT (default 0) Remote IP address accepted. 0 if all is allowed. This parameter is ignored if mode != 3 or if the RTCU device is the master.
Returns: INT ID of the MODBUS connection.
Declaration: FUNCTION modbusOpenX : INT;
Example: INCLUDE rtcu.inc |