Modsak Manual v3.10 - 2.2. Interface settings
Modsak uses two communications interfaces: one to communicate with Modbus masters (in slave mode and monitor mode), and one to communicate with a Modbus slave (in master mode and monitor mode). Use thepage to configure the interface to the master(s), and the page to configure the interface to the slave.
The first four items in the page must always be configured:
Interface Type. Select Serial for a RS232/485 serial interface. Select TCP Socket for a TCP/IP network interface. Select UDP Socket for a UDP/IP interface (use of UDP for Modbus is non-standard). Note that the Serial option is only available on Windows and Linux operating systems (the → window tells you whether the serial library is loaded).
Packet Type. You would normally select RTU if you are using a serial interface, and TCP if you are using a socket interface. You may have to use ASCII for some legacy serial interfaces or devices. It is possible to use RTU or ASCII packets over a socket interface - this is non-standard, but it is used by some serial-TCP converters and can also be useful for software testing. It is also possible to use TCP packets over a serial interface, but there is no good reason to do so (and there would be no error-checking of the packets).
EOM Timeout. Enter the maximum delay (in milliseconds) expected within a message. The default value works fine in most situations, but you may need to increase the value if you are using a serial interface (or an operating system) that introduces large delays in the middle of messages.
A connection to a slave device is considered to be idle if no valid responses have been received from the device within the timeout period.
A connection to a master is considered to be idle if no requests have been responded to within the timeout period.
Setting an idle timeout can be used to avoid holding on to resources that are not currently in use. It can also be useful for recovering from some error conditions.
Responses. When using Modbus RTU or ASCII over a serial interface, a slave should not respond to a broadcast request or to a request for a different slave ID (this is necessary for RS485 multi-drop to work). When using Modbus TCP over a TCP socket interface, the slave/bridge should respond to all requests, including broadcasts and requests to unknown/unreachable slaves (responding to the latter with an exception 10 or 11 response). When using non-standard protocol variants (such as RTU encapsulated in TCP), the behaviour in these situations is not defined. You should select Always responds if you want the Modbus TCP behaviour, or deselect it if you want the serial behaviour.
The Interface Type and Packet Type together determine the variant of the Modbus protocol that will be used. The table below lists the possible combinations:
Table 1. Modbus protocol variants
|Interface type||Packet type||Protocol variant|
|Serial||TCP||Not recommended since no error checking (non-standard)|
|TCP Socket||RTU||Modbus RTU encapsulated in TCP (non-standard)|
|TCP Socket||ASCII||Modbus ASCII encapsulated in TCP (non-standard)|
|TCP Socket||TCP||Modbus TCP|
|UDP Socket||RTU||Modbus RTU encapsulated in UDP (non-standard)|
|UDP Socket||ASCII||Modbus ASCII encapsulated in UDP (non-standard)|
|UDP Socket||TCP||Modbus UDP (also known as Modbus TCP encapsulated in UDP) (non-standard)|
The following items must be configured for a socket interface:
For an interface to a master, you would normally leave this field empty, which allows connections/requests to be accepted via any network interface. But if you enter a host name or IP address of a network interface on the machine running Modsak, then Modsak will only accept connections/requests via that network interface. For example, if you enter
127.0.0.1) then Modsak will only accept connections/requests from processes running on the same machine.
For an interface to a master, you should enter the port that Modsak should listen on for connections/requests. The standard Modbus port number is 502, but this is a "privileged" port and you will not be able to listen on this port on a Unix/Linux machine unless you are "superuser". This is not normally advisable, so it's better for testing purposes to use a non-privileged port (above 1023).
Local host. You would normally leave this field empty. However, if you are using a computer that has multiple network interfaces, you can enter the host name or IP address of one of the network interfaces to force that interface to be used for the connection to the slave.
Local port. You would normally leave this field set to 0, which allows dynamic allocation of the local port to be used for the connection. However, some firewalls or NAT (Network Address Translation) systems may require you to set a specific port.
Port. Select or enter the name of the serial port that Modsak should use to talk to the master (for a master interface) or slave (for a slave interface). If (during testing) the connection between the master and slave is between two serial ports that are both on the same machine, then you must obviously use different port names for each. Don't forget to connect the two ports with a cable!
Parity. It's usual to use no parity, since the CRC in RTU packets is a good error check on its own, but some devices may require it. The serial specification requires even parity to be the default.
Data Bits. Must be 8 for RTU. Some ASCII devices may require 7 (the serial specification actually specifies 7 for ASCII).
Stop Bits. Usually 1, but some devices may require 2. The serial specification actually specifies 2 stop bits if parity is not being used, but this requirement is normally ignored.
Selecting Flow Control will enable hardware flow control ("handshaking") using RTS and CTS. Since Modbus messages are short, flow control is not normally necessary.
Selecting RS485 will use RTS to control a RS232 to RS485 converter: Modsak will raise RTS when it is transmitting data, and lower RTS to receive data. Note that the lowering of RTS may be delayed by the operating system, and this may cause loss of data. For this reason, we recommend the use of RS232-RS485 converters that do not require RTS control.