modbus_srvr_tcp
Purpose:
Initialize and run a Modbus TCP server to handle communication with Modbus slave devices, including parsing arguments for device connections and options.
Enter:
-
modbus_srvr_tcp <priority> [interface …] [de] [aid] [aod] [did] [dod] [dis] [ais] [dos] [noerr]
Where:
-
priority
Specify an integer to indicate the priority level of the task.
interface
Optional. Specify strings in the format IP:port:endian for each device to connect to.
de
Optional. Specify this option to enable general debug output.
aid
Optional. Specify this option to enable Analog Input debug output.
aod
Optional. Specify this option to enable Analog Output debug output.
did
Optional. Specify this option to enable Digital Input debug output.
dod
Optional. Specify this option to enable Digital Output debug output.
dis
Optional. Specify this option to enable single coil and discrete register reads.
ais
Optional. Specify this option to enable single input and holding register reads.
dos
Optional. Specify this option to enable single coil register writes.
noerr
Optional. Specify this option to prevent certain errors from triggering restarts.
Example:
-
modbus_srvr_tcp 24 127.0.0.1:34567:l &
The preceding communicates with a device at IP 127.0.0.1, port 34567, and uses little endian.
modbus_srvr_tcp 24 127.0.0.1:34567:l 10.0.0.1:502:b &
The preceding communicates with 2 interfaces. The first is a device at IP 127.0.0.1, port 34567, and uses little endian. The second interface is a device at IP 10.0.0.1, port 502, and uses big endian.
-
modbus_srvr_tcp 24 127.0.0.1:34567:l 10.0.0.1:502:b dis ais &
The preceding communicates with 2 interfaces. The first is a device at IP 127.0.0.1, port 34567, and uses little endian. The second interface is a device at IP 10.0.0.1, port 502, and uses big endian. The task will read all registers one at a time.
-
modbus_srvr_tcp 24 127.0.0.1:34567:l 10.0.0.1:502:b dis ais noerr &
The preceding communicates with 2 interfaces. The first is a device at IP 127.0.0.1, port 34567, and uses little endian. The second interface is a device at IP 10.0.0.1, port 502, and uses big endian. The task will read all registers one at a time. This will also not have some errors cause the task to re-connect.
Notes:
-
The ‘ais’ and ‘dis’ options may slow down the task by reading registers individually instead of in batches.