Skip to content

Commit

Permalink
Add support for UDP
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkRivers committed Apr 16, 2024
1 parent dd41f27 commit bfc203c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 9 additions & 8 deletions docs/source/creating_driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Creating a **modbus** port driver
---------------------------------

Before **modbus** port drivers can be created, it is necessary to first
create at least one asyn TCP/IP or serial port driver to communicate
create at least one asyn TCP/IP, UDP/IP or serial port driver to communicate
with the hardware. The commands required depend on the communications
link being used.

TCP/IP
~~~~~~
TCP/IP UDP/IP
~~~~~~~~~~~~~

For TCP/IP use the following standard asyn command:
For TCP/IP or UDP/IP use the following standard asyn command:

::

Expand All @@ -31,6 +31,7 @@ the asynInterpose interface does no harm.
However, the asynInterposeEos interface is definitely needed when using drvAsynIPPortConfigure to talk
to a terminal server that is communicating with the Modbus device over Modbus RTU or ASCII,
because then the communication from the device may well be broken up into multiple packets.
To use UDP rather than TCP, add " UDP" after the host name/number and optional port number.

::

Expand Down Expand Up @@ -105,7 +106,7 @@ modbusInterposeConfig
After creating the asynIPPort or asynSerialPort driver, the next step is
to add the asyn "interpose interface" driver. This driver takes the
device-independent Modbus frames and adds or removes the
communication-link specific information for the TCP, RTU, or ASCII link
communication-link specific information for the TCP, UDP, RTU, or ASCII link
protocols. The interpose driver is created with the command:

::
Expand All @@ -128,7 +129,7 @@ protocols. The interpose driver is created with the command:
- Name of the asynIPPort or asynSerialPort previously created.
* - linkType
- int
- Modbus link layer type:, 0 = TCP/IP, 1 = RTU, 2 = ASCII
- Modbus link layer type:, 0 = TCP/IP, 1 = RTU, 2 = ASCII, 3 = UDP/IP
* - timeoutMsec
- int
- The timeout in milliseconds for write and read operations to the underlying asynOctet
Expand Down Expand Up @@ -186,7 +187,7 @@ created with the following command:
* - slaveAddress
- int
- The address of the Modbus slave. This must match the configuration of the Modbus
slave (PLC) for RTU and ASCII. For TCP the slave address is used for the "unit identifier",
slave (PLC) for RTU and ASCII. For TCP or UDP the slave address is used for the "unit identifier",
the last field in the MBAP header. The "unit identifier" is ignored by most PLCs,
but may be required by some.
* - modbusFunction
Expand Down Expand Up @@ -454,4 +455,4 @@ Number formats
It can be convenient to specify the modbusStartAddress and modbusLength
in octal, rather than decimal, because this is the convention on most
PLCs. In the iocsh and vxWorks shells this is done by using a leading 0
on the number, i.e. 040400 is an octal number.
on the number, i.e. 040400 is an octal number.
6 changes: 6 additions & 0 deletions docs/source/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Modbus supports the following 3 communication-link layers:
- Description
* - TCP
- TCP/IP using standard port 502.
* - UDP
- UDP/IP using standard port 502. The use of UDP/IP is not part of the MODBUS
- standard but is useful for FPGAs with Ethernet in firmware which may provide
- support only for UDP. The only difference between TCP and UDP operation is
- that when using UDP a missing reply packet is not considered to
- be an error until the transaction has been attempted 5 times.
* - RTU
- RTU is normally run over serial communication links, i.e. RS-232,
RS-422, or RS-485. RTU uses an additional CRC for packet checking. The
Expand Down

0 comments on commit bfc203c

Please sign in to comment.