RUTX11 Modbus

Wiki mirrorView source
The information in this page is updated in accordance with firmware version RUTX_R_00.07.22.1.

Summary

Modbus is a serial communications protocol. Simple and robust, it has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices.
This manual page provides an overview of the Modbus functionality in RUTX11 devices.
Note: Modbus TCP Server/Client and MQTT Gateway is additional software on some devices that can be installed from the System → Package Manager page.

Modbus TCP Server

A Modbus TCP Server listens for connections from a TCP Client (client) and sends out a response or sets some system related parameter in accordance with the given query. This provides the user with the possibility to set or get system parameters.
The figure below is an example of the Modbus TCP Server window section and the table below provides information on the fields contained in that window:

General

Status section displays Modbus TCP Server status information:
Under the status section, you can configure the main server settings:
FieldValueDescription
Enableoff | on; default: offTurns Modbus TCP on or off.
Portinteger [0..65535]; default: 502TCP port used for Modbus communications.
Device IDinteger [0..255]; default: 1The device's Modbus server ID. When set to 0, it will respond to requests addressed to any ID.
Mobile Data typeBytes | Kilobytes | Megabytes; default: BytesSelects mobile data unit representation type.
Allow remote accessoff | on; default: offAllows remote Modbus connections by adding an exception to the device's firewall on the port specified in the field above.
Enable broadcastsoff | on; default: offProcess incoming Modbus broadcast messages.
Keep persistent connectionoff | on; default: onnAllows keep the connection open after responding a Modbus TCP client request.
Connection timeoutinteger [0..60]; default: 0Sets TCP timeout in seconds after which the connection is forcefully closed.
Enable custom register blockoff | on; default: offAllows the usage of custom register block.
Register file pathpath; default: /mnt/regfilePath to file in which the custom register block will be stored. Files inside /tmp or /var are stored in RAM. They vanish after reboot, but do not degrade flash memory. Files elsewhere are stored in flash memory. They remain after reboot, but degrade flash memory (severely, if operations are frequent).
First register numberinteger [1025..65536]; default: 1025First register in custom register block
Register countinteger [1..64512]; default: 128Register count in custom register block

Data Sources

Data sources transmit data from one or more data sources (can be a Modbus client, DNP3 client, M-BUS, IEC60870-5 client..) and write it to Modbus registers.
To add new data source, press `Add` button:
Register configuration:
FieldValueDescription
Enableoff | on; default: offTurns Register configuration on or off.
Register namestring; default: noneName of the register.
Register sourcelist; default: noneClient service which will be sending requests.
Register valuelist and permissions type; default: noneRequest value and its permissions (Read-Only, Write-Only or Read-Write).
Register rangeinteger [1..65535]; default: noneSpecify the start index and count for the range.
Register typeBinary | String | Bool | INT8 | UINT8 | INT16 | UINT16 | INT32 | UINT32 | INT64 | UINT64 | FLOAT32 | FLOAT64; default: BinaryValue data type.
Register size (with Binary and String data)integer [1..8064]; default: noneSize of the value in bytes.
Modbus register rangeinteger; default: noneStart and calculated end of the register numbers.
Modbus data typeCoils (1) | Input coils (2) | Holding registers (3) | Input registers (4); default: Coils (1)Modbus function code to be used for this request.

Modbus Serial Server

A Modbus Serial Server listens for connections from a serial client and sends out a response or sets some system related parameter in accordance with the given query. This provides the user with the possibility to set or get system parameters.

General

Example of what the status of a Modbus serial server instance on a device looks like:
The Modbus Serial Server Configuration section is used to configure serial servers. By default, the list is empty. To add a new server instance, enter the instance name, select serial interface and click the 'Add' button.
After clicking 'Add' you will be redirected to the newly added server instance configuration page.
FieldValueDescription
Enableoff | on; default: offEnables this Modbus Serial Server instance configuration.
Namestring; default: noneName of the serial server instance. Used for management purposes only.
DeviceUSB RS232 interface; default: USB RS232 interfaceSpecifies which serial port will be used for serial communication.
Device IDinteger [0..255]; default: 1Specifies which serial port will be used for serial communication.
Mobile Data typeBytes | Kilobytes | Megabytes; default: BytesSelects mobile data unit representation type.
Baud rate (USB)integer [300..4000000]; default:9600Data rate for serial data transmission (in bits per second (bps)).
Data bits5 | 6 | 7 |8; default: 8Number of data bits for each character.
Stop bits1| 2; default: 1Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. Two stop bits are required if slow electromechanical devices are used.
ParityEven | Odd| Mark | Space | None; default: NoneIn serial transmission, parity is a method of detecting errors. An extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1s, then it must have been corrupted. However, an even number of errors can pass the parity check.
  • None (N) - no parity method is used.
  • Odd (O) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.
  • Even (E) - the parity bit is set so that the number of "logical ones (1s)" has to be even.
  • Space (s) - the parity bit will always be a binary 0.
  • Mark (M) - the parity bit will always be a binary 1.
Flow controlNone | RTS/CTS | Xon/Xoff; default: NoneIn many circumstances a transmitter might be able to send data faster than the receiver is able to process it. To cope with this, serial lines often incorporate a "handshaking" method, usually distinguished between hardware and software handshaking.
  • RTS/CTS - hardware handshaking. RTS and CTS are turned OFF and ON from alternate ends to control data flow, for instance when a buffer is almost full.
  • Xon/Xoff - software handshaking. The Xon and Xoff characters are sent by the receiver to the sender to control when the sender will send data, i.e., these characters go in the opposite direction to the data being sent. The circuit starts in the "sending allowed" state. When the receiver's buffers approach capacity, the receiver sends the Xoff character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an Xon character to tell the sender to resume transmission.
Enable broadcastsoff | on; default: offProcess incoming Modbus broadcast messages.
Enable custom register blockoff | on; default: offAllows the usage of custom register block.
Register file pathpath; default: /tmp/regfilePath to file in which the custom register block will be stored. Files inside /tmp or /var are stored in RAM. They vanish after reboot, but do not degrade flash memory. Files elsewhere are stored in flash memory. They remain after reboot, but degrade flash memory (severely, if operations are frequent).
First register numberinteger [1025..65536]; default: 1025First register in custom register block
Register countinteger [1..64512]; default: 128Path to file in which the custom register block will be stored. Files inside /tmp or /var are stored in RAM. They vanish after reboot, but do not degrade flash memory. Files elsewhere are stored in flash memory. They remain after reboot, but degrade flash memory (severely, if operations are frequent).

Data Sources

Data sources transmit data from one or more data sources (can be a Modbus client, DNP3 client, M-BUS, IEC60870-5 client..) and write it to Modbus registers.
To add new data source, press `Add` button (Note: Modbus serial server instance is required when creating a new instance.):
Register configuration:
FieldValueDescription
Enableoff | on; default: offTurns Register configuration on or off.
Register namestring; default: noneName of the register.
Register sourcelist; default: noneClient service which will be sending requests.
Register valuelist and permissions type; default: noneRequest value and its permissions (Read-Only, Write-Only or Read-Write).
Register rangeinteger [1..65535]; default: noneSpecify the start index and count for the range.
Register typeBinary | String | Bool | INT8 | UINT8 | INT16 | UINT16 | INT32 | UINT32 | INT64 | UINT64 | FLOAT32 | FLOAT64; default: BinaryValue data type.
Register size (when Binary and String data is selected)integer [1..8064]; default: noneSize of the value in bytes.
Modbus serial serverlist; default: the first instance from Modbus Serial server pageModbus serial server instance name or ID.
Modbus register rangeinteger; default: noneStart and calculated end of the register numbers.
Modbus data typeCoils (1) | Input coils (2) | Holding registers (3) | Input registers (4); default: Coils (1)Modbus function code to be used for this request.

Modbus Registers

Get Parameters

Modbus parameters are held within registers. Each register contains 2 bytes of information. For simplification, the number of registers for storing numbers is 2 (4 bytes), while the number of registers for storing text information is 16 (32 bytes).
The register numbers and corresponding system values are described in the table below:

required valueregister addressregister numbernumber of registersrepresentation
System uptime12232 bit unsigned integer
Mobile signal strength (RSSI in dBm)34232 bit integer
Temperature (in 0.1 °C)56232 bit integer
System hostname7816ASCII
GSM operator name232416ASCII
Serial number394016ASCII
LAN MAC address555616ASCII
Device name717216ASCII
Active SIM card878816ASCII
Network registration info10310416ASCII
Network type11912016ASCII
WAN IP address13914028 bit unsigned integer
GPS latitude143144232 bit float
GPS longitude145146232 bit float
GPS fixed time14714816ASCII (YYYY-MM-DD hh:mm:ss) Note: returns UTC datetime.
GPS datetime16316416ASCII (YYYY-MM-DD hh:mm:ss) Note: returns formatted datetime, adjusted with systems timezone.
GPS speed179180232 bit float
GPS satellite count181182232 bit unsigned integer
GPS accuracy183184232 bit float
Mobile data received this day (SIM1)185186232 bit unsigned integer
Mobile data sent this day (SIM1)187188232 bit unsigned integer
Mobile data received this week (SIM1)189190232 bit unsigned integer
Mobile data sent this week (SIM1)191192232 bit unsigned integer
Mobile data received this month (SIM1)193194232 bit unsigned integer
Mobile data sent this month (SIM1)195196232 bit unsigned integer
Mobile data received last 24h (SIM1)197198232 bit unsigned integer
Mobile data sent last 24h (SIM1)199200232 bit unsigned integer
Active SIM card (Reading returns current sim card index)205206116 bit unsigned integer
Mobile data received last 7 days (SIM1)292293232 bit unsigned integer
Mobile data sent last 7 days (SIM1)294295232 bit unsigned integer
Mobile data received last 30 days (SIM1)296297232 bit unsigned integer
Mobile data sent last 30 days (SIM1)298299232 bit unsigned integer
Mobile data received this day (SIM2)300301232 bit unsigned integer
Mobile data sent this day (SIM2)302303232 bit unsigned integer
Mobile data received this week (SIM2)304305232 bit unsigned integer
Mobile data sent this week (SIM2)306307232 bit unsigned integer
Mobile data received this month (SIM2)308309232 bit unsigned integer
Mobile data sent this month (SIM2)310311232 bit unsigned integer
Mobile data received last 24h (SIM2)312313232 bit unsigned integer
Mobile data sent last 24h (SIM2)314315232 bit unsigned integer
Mobile data received last 7 days (SIM2)316317232 bit unsigned integer
Mobile data sent last 7 days (SIM2)318319232 bit unsigned integer
Mobile data received last 30 days (SIM2)320321232 bit unsigned integer
Mobile data sent last 30 days (SIM2)322323232 bit unsigned integer
Input (PIN3)324325116 bit unsigned integer
Output (PIN4)325326116 bit unsigned integer
Modem ID3283298ASCII
IMSI34834916ASCII
Unix timestamp364365232 bit unsigned integer
Local ISO time36636712ASCII
UTC time37837912ASCII
LAN IP394395216 bit unsigned integer
Add SMS39739890ASCII
Mobile data received last month (SIM1)487488432 bit unsigned integer
Mobile data sent last month (SIM1)491492432 bit unsigned integer
Mobile data received last month (SIM2)495496432 bit unsigned integer
Mobile data sent last month (SIM2)499500432 bit unsigned integer
Mobile data received last week (SIM1)503504432 bit unsigned integer
Mobile data sent last week (SIM1)507508432 bit unsigned integer
Mobile data received last week (SIM2)511512432 bit unsigned integer
Mobile data sent last week (SIM2)515516432 bit unsigned integer

Set Parameters

The Modbus daemon can also set some device parameters.

value to setregister addressregister numberregister valuedescription
Hostname78Hostname (in decimal form)Changes hostname
Device name7172Device name (in decimal form)Changes device name
Switch WiFi ON/OFF2032041 | 0Turns WiFi ON or OFF
Switch mobile data connection (ON/OFF*)2042051 | 0Turns mobile data connection ON or OFF
Switch SIM card2052061 | 2 | 0Changes the active SIM card slot
  • 1 - switch to SIM1
  • 2 - switch to SIM2
  • 0 - switch from the the SIM card opposite of the one currently in use (SIM1 → SIM2 or SIM2 → SIM1)
Reboot2062071Reboots the router
Change APN207208APN codeChanges APN.
The number of input registers may vary depending on the length of the APN, but the very first byte of the set APN command denotes the number of the SIM card for which to set the APN. This byte should be set to:
  • 1 - to set APN for SIM1
  • 2 - to set APN for SIM2
Output (PIN4)3253261 | 0Toggles PIN 4 ON or OFF
Switch 2.4GHz WiFi ON/OFF3903911 | 0Turns 2.4GHz WiFi ON or OFF
Switch 5GHz WiFi ON/OFF3913921 | 0Turns 5GHz WiFi ON or OFF
Change LAN IP394395IPv4 (in decimal form)Changes device LAN IP
Send SMS3963971 | 0Sends an SMS with content defined in Add SMS (397) register
Add SMS397398Message (in decimal form)Define SMS content which will be sent using Send SMS (396) register.
The register array is split into two parts that represent the recipient's "phone number" (first 10 registers) and the "SMS message contents" (remaining 80 registers).

Modbus TCP Client

A Modbus TCP Client can request data from Modbus servers. The Modbus TCP devices section is used to configure Modbus TCP servers and enable Client.
Notice the Global section config. It is used to outright turn the service off or on if any active configurations are present.
Clicking the Cog icon opens a modal window. The global configuration slider can be set and it's state saved.
FieldValueDescription
Enabledoff | on; default: offTurn on/off Modbus client service.
Database locationRAM | USB; default: RAMSelect Modbus database location.
Database sizesize in KiBCurrent database size.
By default, the client list is empty and client is disabled. To add a new client, click the 'Add' button
After clicking 'Add' you will be redirected to the newly added modbus device configuration page.
FieldValueDescription
Enabledoff | on; default: offTurns communication with the server device on or off.
Namestring; default: noneServer device's name, used for easier management purposes.
Server IDinteger [0..255]; default: 1Modbus server ID number (1-255). Note: ID 0 is a broadcast address that will target a specific server. If a true broadcast is desired request(s) must have Broadcast enabled.
IP addressip4; default: noneServer device's IP address.
Portinteger [0..65535]; default: noneServer device's Modbus TCP port.
Timeoutinteger [1..30]; default: 5Maximum response wait time.
Always reconnectoff | on; default: offCreate new connection after every Modbus request.
Number of timeoutsinteger [0..10]; default: 1Skip pending request and reset connection after number of request failures.
FrequencyPeriod | Schedule; default: Period
Delayinteger [0..999]; default: 0Wait in milliseconds after connection initialization.
Periodinteger [1..99999]; default: 60Interval in seconds for sending requests to this device
Schedule requesttime format string 'hh:mm:ss'; default: noneSchedule request time (format: Hours:Minutes:Seconds).

Requests Configuration

A Modbus request is a way of obtaining data from Modbus servers. The client sends a request to a server specifying the function code to be performed. The server then sends the requested data back to the Modbus client.
Note: Modbus TCP Client uses Register Number instead of Register Address for pointing to a register. For example, to request the Uptime of a device, you must use 2 in the First Register field.
The Request Configuration list is empty by default. To add a new Request Configuration loon to the Add New Instance section. Enter a custom name into the 'Name' field and click the 'Add' button:
The new Request Configuration should become visible in the list:
FieldValueDescription
Namestring; default: UnnamedName of this Request Configuration. Used for easier management purposes.
Data type8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float (various Byte order) | 32bit INT (various Byte order) | 32bit UINT (various Byte order) | 64bit INT (various Byte order) | 64bit UINT (various Byte order) | 64bit float (various Byte order) | ASCII | Hex | Bool | PDU; default: 16bit INT, high byte firstDefines how read data will be stored.
FunctionRead coils (1) | Read input coils (2) | Read holding registers (3) | Read input registers (4) | Set single coil (5) | Set single coil register (6) | Set multiple coils (15) | Set multiple holding registers (16); default: Read holding registers (3)Specifies the type of register being addressed by a Modbus request.
First Registerinteger [0..65535]; default: 1First Modbus register from which data will be read.
Register Count / Valuesinteger [1..2000]; default: 1Number of Registers/Coils/Inputs or actual values to be written (Multiple values must be separated by space character).
No bracketsoff | on; default: offRemoves the starting and ending brackets from the request (only for read requests).
Store on change onlyoff | on; default: offStore the response only if the value has changed.
Broadcastoff | on; default: offEnable to broadcast the request to all devices (only for write requests).
Enabledoff | on; default: offTurns the request on or off.
Actions- (interactive button)Deletes the request.
Additional note: by default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:
After having configured a request, you should see a new 'Request Configuration Testing' section appear. It is used to check whether the configuration works correctly. Simply click the 'Test' button and a response should appear in the box below. Note: to use test buttons, you need to enable Client section. A successful response to a test may look something like this:

Alarms Configuration

Alarms are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus TCP Client (this RUTX11 device) requests some information from a server device it compares that data to with the parameters set in an Alarm Configuration. If the comparison meets the specified condition (more than, less than, equal to, not equal to), the Client performs a user-specified action, for example, a Modbus write request or switching the state of an output.
The figure below is an example of the Alarms Configuration list. To create a new Alarm, click the 'Add' button.
After adding the Alarm you should be redirected to its configuration page which should look similar to this:
FieldValueDescription
Enabledoff | on; default: offTurns the alarm on or off.
Function codeRead Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4); default: Read Coil Status (1)Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this RUTX11 device) perform this request as often as specified in the 'Period' field in Server Device Configuration.
Compared condition data type8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float (various Byte order) | 32bit INT (various Byte order) | 32bit UINT (various Byte order) | 64bit INT (various Byte order) | 64bit UINT (various Byte order) | 64bit float (various Byte order) | ASCII | Hex | Bool; default: 16bit INT, high byte firstSelect data type that will be used for checking conditions.
First register numberinteger [1..65536]; default: noneNumber of the Modbus coil/input/holding-register/input-register to read from.
Valuesvarious; default: noneThe value against which the read data will be compared.
ConditionMore than | Less than | Equal to | Not Equal to | Less or equal | More or equal; default: More thanWhen a value is obtained it will be compared against the value specified in the following field. The comparison will be made in accordance with the condition specified in this field.
Action frequencyEvery trigger | First trigger; default: Every triggerDescribes how frequently the specified action will be taken.
Redundancy protectionoff | on; default: offProtection against executing a configured action too often.
Redundancy protection periodinteger [1..86400]; default: noneDuration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.
ActionUbus event | Email | SMS | MODBUS Write Request | Trigger output | MQTT message; default: MODBUS Write RequestAction that will be taken if the condition is met. Possible actions:
  • SMS - sends SMS message to a specified recipient(s).
  • Email - sends Email to a specified recipient(s).
  • Ubus event - sends Email to a specified recipient(s).
  • MQTT message - sends MQTT message to a specified broker.
  • Ubus event - sends ubus event.
  • Modbus Request - sends a Modbus Write request to a specified server.
  • Trigger output - changes state of selected I/O output pin.
SMS: Messagestring; default: noneSMS message text.
SMS: RecipientsSingle | Group; default: noneYou can choose to add a single number or use a phone group list.
SMS: Phone group (Group recipient)phone group; default: noneRecipient groups, including their associated phone numbers, can be configured here.
SMS: Phone number (Single recipient)phone number; default: noneRecipient's phone number.
Email: Subjectstring; default: noneSubject of an email. Allowed characters (a-zA-Z0-9!@#$%&*+-/=?^_`{|}~. ).
Email: Message textstring; default: noneMessage that will be sent if condition passes. Below this field you can find special codes that begin with the '%' sign. Each code represents a piece information related to the status of the device. Include these codes in the field for dynamic information reports. Possible values: Local time, Unix time, Router name, Device name, Serial number, Current FW version, LAN IP address, Monitoring status, UTC time in ISO, WAN IP address, New line, Modbus server ID, Modbus server IP, First register number, Register value, SIM slot in use, Mobile IP addresses, Signal strength, Signal quality, Operator name, Network type, Data connection state, Network state, IMSI, IMEI, Modem model, Modem serial number, SIM pin state, SIM state, RSCP, ECIO, RSRP, SINR, RSRQ, ICCID, CELLID, Neighbour cells, Network info, Network serving, WAN MAC address, Analog Current Loop (6,9), Analog Input (6,9), Input (3), Digital Input (1), Output (4), Isolated Output (3,4,8), Isolated Input (2,7), Relay (5,10)
Email: Sender's email accountstring; default: noneSender's email configuration (configure it here).
Email: Recipient's email addressemail address; default: noneFor whom you want to send an email to. Allowed characters (a-zA-Z0-9._%+@-).
MODBUS Write Request: IP addressip | host; default: noneModbus server's IP address.
MODBUS Write Request: Portinteger [0..65535]; default: noneModbus server's port.
MODBUS Write Request: Timeoutinteger [1..30]; default: 5Maximum time to wait for a response.
MODBUS Write Request: IDinteger [1..255]; default: noneModbus server ID.
MODBUS Write Request: Modbus functionSet Single Coil (5) | Set Single Register (6) | Set Multiple Coils (15) | Set Multiple Registers (16); default: Set Single Coil (5)A function code specifies the type of register being addressed by a Modbus request.
MODBUS Write Request: Executed action data type8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float (various Byte order) | 32bit INT (various Byte order) | 32bit UNIT (various Byte order) 64bit INT (various Byte order) | 64bit UINT (various Byte order) | 64bit float (various Byte order) | ASCII | Hex | Bool; default: BoolSelect data type that will be used for executing action.
MODBUS Write Request: First register numberinteger [0..65535]; default: noneBegins reading from the register specified in this field.
MODBUS Write Request: Valuesinteger [0..65535]; default: noneRegister/Coil values to be written (multiple values must be separated by space character).
Trigger output: OutputOutput (4); default: Output (4)Selects which output will be triggered.
Trigger output: I/O ActionTurn On | Turn Off | Invert; default: Turn OnSelects the action performed on the output.
MQTT message: JSON formatstring; default: none Below this field you can find special codes that begin with the '%' sign. Each code represents a piece information related to the status of the device. Include these codes in the field for dynamic information reports. Possible values: Local time, Unix time, Router name, Device name, Serial number, Current FW version, LAN IP address, Monitoring status, UTC time in ISO, WAN IP address, New line, Modbus server ID, Modbus server IP, First register number, Register value, SIM slot in use, Mobile IP addresses, Signal strength, Signal quality, Operator name, Network type, Data connection state, Network state, IMSI, IMEI, Modem model, Modem serial number, SIM pin state, SIM state, RSCP, ECIO, RSRP, SINR, RSRQ, ICCID, CELLID, Neighbour cells, Network info, Network serving, WAN MAC address, Analog Current Loop (6,9), Analog Input (6,9), Input (3), Digital Input (1), Output (4), Isolated Output (3,4,8), Isolated Input (2,7), Relay (5,10)
MQTT message: Hostnamehost | ip; default: none Broker’s IP address or hostname.
MQTT message: Portinteger [0..65535]; default: 1883Broker's port number.
MQTT message: Keepalivepositive integer; default: noneThe number of seconds after which the broker should send a PING message to the client if no other messages have been exchanged in that time
MQTT message: Topicstring; default: noneThe name of the topic that the broker will subscribe to.
MQTT message: Client IDpositive integer; default: noneClient ID to send with the data. If empty, a random client ID will be generated
MQTT message: QoSAt most once (0) | At least once (1) | Exactly once (2); default: At most once (0)A period of time (in seconds) which has to pass after a trigger event before this Action is executed.
MQTT message: Use root CAoff | on; default: offUse root CA for verifying the servers certificates
MQTT message: Use TLSoff | on; default: offTurns the use of TLS/SSL for this MQTT connection on or off.
MQTT message: Use credentialsoff | on; default: offTurns the use of username and password for this MQTT connection on or off.

Modbus Serial Client

The Modbus Serial Client page is used to configure the device as a Modbus RTU Client. Modbus RTU (remote terminal unit) is a serial communication protocol mainly used in communication via serial interfaces.
Notice the Global section config. It is used to outright turn the service off or on if any active configurations are present.
Clicking the Cog icon opens a modal window. The global configuration slider can be set and it's state saved.
FieldValueDescription
Enabledoff | on; default: offTurn on/off Modbus client service.
Database locationRAM | USB; default: RAMSelect Modbus database location.
Database sizesize in KiBCurrent database size.

General Status

This section displays Modbus Client general status information.

Modbus Serial Device Configuration

This section is used to create Modbus Serial Client's server device instances. You may create a Serial Device instance for each supported serial interface.
By default there are no instances created. To add a new serial device configuration, enter an instance name, select serial device and click the 'Add' button.
After clicking 'Add' you will be redirected to the newly added device's configuration page.

RS Device Modbus Client Configuration

This section is used to configure the Modbus Serial Client's server device interface settings.
FieldValueDescription
Enableoff | on; default: offEnables this Modbus Serial Device instance configuration.
Namestring; default: noneName of the serial device instance. Used for management purposes only.
DeviceUSB RS232 interface; default: USB RS232 interfaceSpecifies which serial port will be used for serial communication.
Baud rate (USB)integer [300..4000000]; default:9600Data rate for serial data transmission (in bits per second (bps)).
Data bits5 | 6 | 7 |8; default: 8Number of data bits for each character.
Stop bits1| 2; default: 1Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. Two stop bits are required if slow electromechanical devices are used.
ParityEven | Odd| Mark | Space | None; default: NoneIn serial transmission, parity is a method of detecting errors. An extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1s, then it must have been corrupted. However, an even number of errors can pass the parity check.
  • None (N) - no parity method is used.
  • Odd (O) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.
  • Even (E) - the parity bit is set so that the number of "logical ones (1s)" has to be even.
  • Space (s) - the parity bit will always be a binary 0.
  • Mark (M) - the parity bit will always be a binary 1.
Flow controlNone | RTS/CTS | Xon/Xoff; default: NoneIn many circumstances a transmitter might be able to send data faster than the receiver is able to process it. To cope with this, serial lines often incorporate a "handshaking" method, usually distinguished between hardware and software handshaking.
  • RTS/CTS - hardware handshaking. RTS and CTS are turned OFF and ON from alternate ends to control data flow, for instance when a buffer is almost full.
  • Xon/Xoff - software handshaking. The Xon and Xoff characters are sent by the receiver to the sender to control when the sender will send data, i.e., these characters go in the opposite direction to the data being sent. The circuit starts in the "sending allowed" state. When the receiver's buffers approach capacity, the receiver sends the Xoff character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an Xon character to tell the sender to resume transmission.
Inter-device delayinteger [0..1000]; default: noneDelay in milliseconds between requests when the device between those requests differs.

Modbus devices

This section is used to create server instances that the Client (this RUTX11 device) will be querying with requests.
By default there are no instances created. To add a new server configuration, enter an instance name, select a serial device instance and click the 'Add' button.
After clicking 'Add' you will be redirected to the newly added server's configuration page.

Modbus device configuration

The Modbus device configuration section is used to configure the parameters of Modbus RTU servers that the Client (this RUTX11 device) will be querying with requests. The figure below is an example of the Server Device Configuration and the table below provides information on the fields contained in that section:
FieldValueDescription
Enabledoff | on; default: offTurns communication with the server device on or off.
Namestring; default: noneServer device's name, used for easier management purposes.
Serial deviceserial device instance; default: noneSpecifies which serial device will be used on this server.
Server IDinteger [0..255]; default: 1Modbus server ID number (1-255). Note: ID 0 is a broadcast address that will target a specific server. If a true broadcast is desired request(s) must have Broadcast enabled.
Number of timeoutsinteger [0..10]; default: 0Skip pending request and reset connection after number of request failures.
FrequencyPeriod | Schedule; default: Period
Periodinteger [1..99999]; default: 60Interval at which requests are sent to the server device.
Timeoutinteger [1..60]; default: 1Maximum response wait time.
Schedule requesttime format string 'hh:mm:ss'; default: noneSchedule request time (format: Hours:Minutes:Seconds).
Requests Configuration
A Modbus request is a way of obtaining data from Modbus servers. The client sends a request to a servers specifying the function code to be performed. The server then sends the requested data back to the Modbus client.
Note: Modbus Serial Client uses Register Number instead of Register Address for pointing to a register. For example, to request the Uptime of a device, you must use 2 in the First Register field.
The Request Configuration list is empty by default. To add a new Request Configuration loon to the Add New Instance section. Enter a custom name into the 'Name' field and click the 'Add' button:
The new Request Configuration should become visible in the list:
FieldValueDescription
Namestring; default: UnnamedName of this Request Configuration. Used for easier management purposes.
Data type8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float (various Byte order) | 32bit INT (various Byte order) | 32bit UINT (various Byte order) | 64bit INT (various Byte order) | 64bit UINT (various Byte order) | 64bit float (various Byte order) | ASCII | Hex | Bool | PDU; default: 16bit INT, high byte firstDefines how read data will be stored.
FunctionRead coils (1) | Read input coils (2) | Read holding registers (3) | Read input registers (4) | Set single coil (5) | Set single coil register (6) | Set multiple coils (15) | Set multiple holding registers (16); default: Read holding registers (3)Specifies the type of register being addressed by a Modbus request.
First Registerinteger [0..65535]; default: 1First Modbus register from which data will be read.
Register Count / Valuesinteger [1..2000]; default: 1Number of Registers/Coils/Inputs or actual values to be written (Multiple values must be separated by space character).
No bracketsoff | on; default: offRemoves the starting and ending brackets from the request (only for read requests).
Store on change onlyoff | on; default: offStore the response only if the value has changed.
Broadcastoff | on; default: offEnable to broadcast the request to all devices (only for write requests).
Enabledoff | on; default: offTurns the request on or off.
Actions- (interactive button)Deletes the request.
Additional note: by default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:
After having configured a request, you should see a new 'Request Configuration Testing' section appear. It is used to check whether the configuration works correctly. Simply click the 'Test' button and a response should appear in the box below. Note: to use test buttons, you need to enable Client section. A successful response to a test may look something like this:
Modbus Client Alarms
Alarms are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Client (this RUTX11 device) requests some information from a server device it compares that data to with the parameters set in an Alarm Configuration. If the comparison meets the specified condition (more than, less than, equal to, not equal to), the Client performs a user-specified action, for example, a Modbus write request or switching the state of an output.
The figure below is an example of the Modbus Client Alarms list. To create a new Alarm, click the 'Add' button.
After this you should be redirected to that Alarm's configuration page which should look similar to this:
FieldValueDescription
Enabledoff | on; default: offTurns the alarm on or off.
Function codeRead Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4); default: Read Coil Status (1)Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this RUTX11 device) perform this request as often as specified in the 'Period' field in Server Device Configuration.
Compared condition data type8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float (various Byte order) | 32bit INT (various Byte order) | 32bit UINT (various Byte order) | 64bit INT (various Byte order) | 64bit UINT (various Byte order) | 64bit float (various Byte order) | ASCII | Hex | Bool; default: 16bit INT, high byte firstSelect data type that will be used for checking conditions.
First register numberinteger [1..65536]; default: noneNumber of the Modbus coil/input/holding-register/input-register to read from.
Valuesvarious; default: noneThe value against which the read data will be compared.
ConditionMore than | Less than | Equal to | Not Equal to | Less or equal | More or equal; default: More thanWhen a value is obtained it will be compared against the value specified in the following field. The comparison will be made in accordance with the condition specified in this field.
Action frequencyEvery trigger | First trigger; default: Every triggerDescribes how frequently the specified action will be taken.
Redundancy protectionoff | on; default: offProtection against executing a configured action too often.
Redundancy protection periodinteger [1..86400]; default: noneDuration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.
ActionUbus event | Email | SMS | MODBUS Write Request | Trigger output | MQTT message; default: MODBUS Write RequestAction that will be taken if the condition is met. Possible actions:
  • SMS - sends and SMS message to a specified recipient(s).
  • Email - sends Email to a specified recipient(s).
  • Ubus event - sends Email to a specified recipient(s).
  • MQTT message - sends MQTT message to a specified broker.
  • Ubus event - sends ubus event.
  • Modbus Request - sends a Modbus Write request to a specified server.
  • Trigger output - changes state of selected I/O output pin.
SMS: Messagestring; default: noneSMS message text.
SMS: RecipientsSingle | Group; default: noneYou can choose to add a single number or use a phone group list.
SMS: Phone group (Group recipient)phone group; default: noneRecipient groups, including their associated phone numbers, can be configured here.
SMS: Phone number (Single recipient)phone number; default: noneRecipient's phone number.
Email: Subjectstring; default: noneSubject of an email. Allowed characters (a-zA-Z0-9!@#$%&*+-/=?^_`{}~. ).
Email: Message textstring; default: noneMessage that will be sent if condition passes. Below this field you can find special codes that begin with the '%' sign. Each code represents a piece information related to the status of the device. Include these codes in the field for dynamic information reports. Possible values: Local time, Unix time, Router name, Device name, Serial number, Current FW version, LAN IP address, Monitoring status, UTC time in ISO, WAN IP address, New line, Modbus server ID, Modbus server IP, First register number, Register value, SIM slot in use, Mobile IP addresses, Signal strength, Signal quality, Operator name, Network type, Data connection state, Network state, IMSI, IMEI, Modem model, Modem serial number, SIM pin state, SIM state, RSCP, ECIO, RSRP, SINR, RSRQ, ICCID, CELLID, Neighbour cells, Network info, Network serving, WAN MAC address, Analog Current Loop (6,9), Analog Input (6,9), Input (3), Digital Input (1), Output (4), Isolated Output (3,4,8), Isolated Input (2,7), Relay (5,10)
Email: Sender's email accountstring; default: noneSender's email configuration (configure it here).
Email: Recipient's email addressemail address; default: noneFor whom you want to send an email to. Allowed characters (a-zA-Z0-9._%+@-).
MODBUS Write Request: Timeoutinteger [1..30]; default: 5Maximum time to wait for a response.
MODBUS Write Request: IDinteger [1..255]; default: noneModbus server ID.
MODBUS Write Request: Modbus functionRead Single Coil (5) | Set Single Register (6) | Set Multiple Coils (15) | Set Multiple Registers (16); default: Set Single Coil (5)A function code specifies the type of register being addressed by a Modbus request.
MODBUS Write Request: Executed action data type8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float (various Byte order) | 32bit INT (various Byte order) | 32bit UNIT (various Byte order) | 64bit INT (various Byte order) | 64bit UINT (various Byte order) | 64bit float (various Byte order) | ASCII | Hex | Bool; default: BoolSelect data type that will be used for executing action.
MODBUS Write Request: First register numberinteger [0..65535]; default: noneBegins reading from the register specified in this field.
MODBUS Write Request: Valuesinteger [0..65535]; default: noneRegister/Coil values to be written (multiple values must be separated by space character).
Trigger output: OutputOutput (4); default: Output (4)Selects which output will be triggered.
Trigger output: I/O ActionTurn On | Turn Off | Invert; default: Turn OnSelects the action performed on the output.
MQTT message: JSON formatstring; default: none Below this field you can find special codes that begin with the '%' sign. Each code represents a piece information related to the status of the device. Include these codes in the field for dynamic information reports. Possible values: Local time, Unix time, Router name, Device name, Serial number, Current FW version, LAN IP address, Monitoring status, UTC time in ISO, WAN IP address, New line, Modbus server ID, Modbus server IP, First register number, Register value, SIM slot in use, Mobile IP addresses, Signal strength, Signal quality, Operator name, Network type, Data connection state, Network state, IMSI, IMEI, Modem model, Modem serial number, SIM pin state, SIM state, RSCP, ECIO, RSRP, SINR, RSRQ, ICCID, CELLID, Neighbour cells, Network info, Network serving, WAN MAC address, Analog Current Loop (6,9), Analog Input (6,9), Input (3), Digital Input (1), Output (4), Isolated Output (3,4,8), Isolated Input (2,7), Relay (5,10)
MQTT message: Hostnamehost | ip; default: none Broker’s IP address or hostname.
MQTT message: Portinteger [0..65535]; default: 1883Broker's port number.
MQTT message: Keepalivepositive integer; default: noneThe number of seconds after which the broker should send a PING message to the client if no other messages have been exchanged in that time
MQTT message: Topicstring; default: noneThe name of the topic that the broker will subscribe to.
MQTT message: Client IDpositive integer; default: noneClient ID to send with the data. If empty, a random client ID will be generated
MQTT message: QoSAt most once (0) | At least once (1) | Exactly once (2); default: At most once (0)A period of time (in seconds) which has to pass after a trigger event before this Action is executed.
MQTT message: Use root CAoff | on; default: offUse root CA for verifying the servers certificates
MQTT message: Use TLSoff | on; default: offTurns the use of TLS/SSL for this MQTT connection on or off.
MQTT message: Use credentialsoff | on; default: offTurns the use of username and password for this MQTT connection on or off.

MQTT Modbus Gateway

The MQTT Modbus Gateway function is used to transfer Modbus data (send requests, receive responses) over MQTT. When it is enabled, the device (this RUTX11) subscribes to a REQUEST topic and publishes on a RESPONSE topic on a specified MQTT broker. It translates received MQTT message payload to a Modbus request and relays it to the specified Modbus TCP server.
When the MQTT Gateway receives a response from the server, it translates it to an MQTT message and publishes it on the RESPONSE topic.
Below is an example of the MQTT Gateway page. Refer to the table for information on MQTT Gateway configuration fields and status.
FieldValueDescription
Enableoff | on; default: offTurns MQTT gateway on or off.
Hostip | host; default: 127.0.0.1IP address or hostname of an MQTT broker.
Portinteger [0..65535]; default: 1883Port number of the MQTT broker.
Message typeASCII | JSON; default: ASCIIFormat in which requests and responses will be sent to MQTT broker.
Request topicalphanumeric string; default: request/$$SERIALTopic name.
  • Constants:
  • Serial number: $$SERIAL
  • Mac address: $$MAC
  • Device name: $$NAME
Response topicalphanumeric string; default: response/$$SERIALTopic name.
  • Constants:
  • Serial number: $$SERIAL
  • Mac address: $$MAC
  • Device name: $$NAME
QoSAt most once (0) | At least once (1) | Exactly once (2); default: Exactly once (2)Specifies quality of service.
Usernamestring; default: noneUsername for authentication to the MQTT broker.
Passwordstring; default: nonePassword for authentication to the MQTT broker.
Client IDinteger; default: noneSpecifies client ID for MQTT broker.
Keepaliveinteger; default: 5Keepalive message to MQTT broker (seconds)
Use TLS/SSLoff | on; default: offTurns TLS support on or off
TLS typeCertificate based | Pre-Shared-Key based; default: Certificate basedSelects the type of TLS encryption
TLS insecureoff | on; default: offDisables TLS security
Certificate files from deviceoff | on; default: offChoose this option if you want to use certificate files generated on device.
CA filestring; default: noneUpload/select certificate authority file.
Certificates filestring; default: noneUpload/select certificate file.
Key filestring; default: noneUpload/select key file.
PSKstring; default: noneSpecifies the pre-shared key.
Identitystring; default: noneSpecifies identity.

Serial Gateway Configuration

Serial Gateway Configuration section displays Serial gateway instances currently existing on the router.
By default the list is empty. To create a new gateway instance, enter the ID of serial device, select serial interface and click the 'Add' button.
After this you should be redirected to instance's configuration page which should look similar to this:
FieldValueDescription
Enableoff | on; default: offEnables this Serial Gateway instance configuration.
Namestring; default: noneName of the gateway instance. Used for management purposes only.
DeviceUSB RS232 interface; default: USB RS232 interfaceSpecifies which serial port will be used for serial communication.
Baud rate (USB)integer [300..4000000]; default:9600Data rate for serial data transmission (in bits per second (bps)).
Data bits5 | 6 | 7 |8; default: 8Number of data bits for each character.
Stop bits1| 2; default: 1Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. Two stop bits are required if slow electromechanical devices are used.
ParityEven | Odd| Mark | Space | None; default: NoneIn serial transmission, parity is a method of detecting errors. An extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1s, then it must have been corrupted. However, an even number of errors can pass the parity check.
  • None (N) - no parity method is used.
  • Odd (O) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.
  • Even (E) - the parity bit is set so that the number of "logical ones (1s)" has to be even.
  • Space (s) - the parity bit will always be a binary 0.
  • Mark (M) - the parity bit will always be a binary 1.
Flow controlNone | RTS/CTS | Xon/Xoff; default: NoneIn many circumstances a transmitter might be able to send data faster than the receiver is able to process it. To cope with this, serial lines often incorporate a "handshaking" method, usually distinguished between hardware and software handshaking.
  • RTS/CTS - hardware handshaking. RTS and CTS are turned OFF and ON from alternate ends to control data flow, for instance when a buffer is almost full.
  • Xon/Xoff - software handshaking. The Xon and Xoff characters are sent by the receiver to the sender to control when the sender will send data, i.e., these characters go in the opposite direction to the data being sent. The circuit starts in the "sending allowed" state. When the receiver's buffers approach capacity, the receiver sends the Xoff character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an Xon character to tell the sender to resume transmission.

Request messages

Note: MQTT Gateway uses Register Number instead of Register Address for pointing to a register. For example, to request the Uptime of a device, you must use 2 in the Register Number field.
Modbus request data sent in the MQTT payload should be generated in accordance with the one of the following formats:
  • TCP:
 
0 <COOKIE> <IP_TYPE> <IP> <PORT> <TIMEOUT> <SERVER_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES> <BROADCAST>

  • Serial:
 
1 <COOKIE> <SERIAL_DEVICE_ID> <TIMEOUT> <SERVER_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES> <BROADCAST>

  • MODBUS TCP connection management messages:
 
2 <COOKIE> <CONNECTION_INDEX> <ACTION>

 
2 <COOKIE> <CONNECTION_INDEX> 0 <IP_TYPE> <IP> <PORT> <TIMEOUT>

Explanation:
  • Cookie - a 64-bit unsigned integer in range [0..264-1]). A cookie is used in order to distinguish which response belongs to which request, each request and the corresponding response contain a matching cookie: a 64-bit unsigned integer.
  • IP type - host IP address type. Possible values:
    • 0 - IPv4 address;
    • 1 - IPv6 address;
    • 2 - hostname that will be resolved to an IP address.
  • IP - IP address of a Modbus TCP server. IPv6 must be presented in full form (e.g., 2001:0db8:0000:0000:0000:8a2e:0370:7334).
  • Port - port number of the Modbus TCP server.
  • Timeout - timeout for Modbus connection, in seconds. Range [1..999].
  • Server ID - Modbus TCP server ID. Range [1..255].
  • Modbus function - Modbus task type that will be executed. Possible values are:
    • 1 - read coils;
    • 2 - read input coils;
    • 3 - read holding registers;
    • 4 - read input registers;
    • 5 - set single coil;
    • 6 - write to a single holding register;
    • 15 - set multiple coils;
    • 16 - write to multiple holding registers.
  • First register - number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.
  • Register count/value - this value depends on the Modbus function:
    • 1 - coil count (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);
    • 2 - input count (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);
    • 3 - holding register count (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);
    • 4 - input register count (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);
    • 5 - coil value (in range [0..1]);
    • 6 - holding register value (in range [0..65535]);
    • 15 - coil count (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and coil values separated with commas, without spaces (e.g., 1,2,3,654,21,789); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].
    • 16 - register count (in range [1..123]); must not exceed the boundary (first register number + register count <= 65537); and register values separated with commas, without spaces (e.g., 1,2,3,654,21,789); there must be exactly as many values as specified (with register count); each value must be in the range of [0..65535].
  • Broadcast - number used to identify that the broadcast is ON (in range [0..1]). Note: that broadcast flag is not ignored only when 5,15,6,16 Modbus functions are used.
    • 0 - if 0 or not specified - message will be sent only to a Modbus server, that matches the provided <SERVER_ID> in the message.
    • 1 - message will be sent to all available Modbus servers on the network.
  • Serial device ID - a string used to identify a serial device. Must match with Device ID field in MQTT Gateway page Serial gateway configuration section.
  • Connection index - a number used to identify a connection on which an action will be preformed (in range [0..7]).
  • Action - a connection action. Possible values are:
    • 0 - OPEN. This will open a closed connection, reopen an already open connection with the same parameters or close an already open connection and open a new one with new parameters.
    • 1 - CLOSE. This will close an open connection and do nothing to the closed one.
    • 2 - STATUS. This will respond with either OK 1 for an open connection or OK 0 for a closed connection.

Response messages

A special response message can take one of the following forms:
<COOKIE> OK                              - 
for functions 6 and 16

<COOKIE> OK <VALUE> <VALUE> <VALUE>...   - 
for function 3, where <VALUE> <VALUE> <VALUE>... are read register values

<COOKIE> ERROR: ...                      - 
for failures, where ... is the error description

Examples

Below are a few examples of controlling/monitoring the internal Modbus TCP Server on RUTX11.
Reboot the device
  • Request:
    0 65432 0 192.168.1.1 502 5 1 6 206 1
  • Response:
    65432 OK
Retrieve uptime
  • Request:
    0 65432 0 192.168.1.1 502 5 1 3 2 2
  • Response:
    65432 OK 0 5590
If you're using Eclipse Mosquitto (MQTT implementation used on RUTX11), Publish/Subscribe commands may look something like this:
Retrieve uptime
  • Request:
    mosquitto_pub -h 192.168.1.1 -p 1883 -t request -m "0 65432 0 192.168.1.1 502 5 1 3 2 2"
  • Response:
    mosquitto_sub -h 192.168.1.1 -p 1883 -t response
    65432 OK 0 5590

JSON message structure

Request:
{
 "cookie":                  
Cookie - a 64-bit unsigned integer in range [0..264-1])

 "type":                    
Type - request type. Possible values:

                               
0 - TCP; (Serial)

                               
1 - Serial; (Serial)

                               
2 - Connection Control (Serial)

 "connection":              
Connection - Serial connection index. Optional if host is given.
 
 "host":                    
host - IPv4, IPv6, or FQDN address of server. Required if connection is not used or if type = 2 and action = open.

 
 "port":                    
Port - port number of the Modbus server.

 "timeout":                 
Timeout - timeout for Modbus connection, in seconds. Range [1..999].

 "server_id":               
Server ID - Modbus TCP/Serial server ID. Range [1..255].

 "device_id":               
Serial device ID - a string used to identify a serial device. Must match with Device ID field in MQTT Gateway page Serial gateway configuration section.

 
 "function":                
Modbus function - Modbus task type that will be executed. Possible values are:

                               
1 - read coils;

                               
2 - read input coils;

                               
3 - read holding registers;

                               
4 - read input registers;

                               
5 - set single coil;

                               
6 - write to a single holding register;

                               
15 - set multiple coils;

                               
16 - write to multiple holding registers.

 "register_number":         
First register - number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.

 
 "register_count":          
Register count/value - this value depends on the Modbus function.

 "coil_number":             
First coil address (for coil operations only)

 "coil_count":              
Number of coils to read (for coil operations only)

 "broadcast":               
Broadcast - number used to identify that the broadcast is ON (in range [0..1]). Note: that broadcast flag is not ignored only when 5,15,6,16 Modbus functions are used.

                               
0 - if 0 or not specified - message will be sent only to a Modbus server.

                               
1 - message will be sent to all available Modbus servers on the network.
   
 "value":                   
Single value to write (used with function 6). Must be from 0 to 65535

 "values":                  
Array of values (used with function 16). Comma-separated without spaces (e.g. 1,2,3,654,21,789). Number of values must match register count. Each value: 0–65535

 
 "action":                  
Action - a connection action. Possible values are:

                               
0 - OPEN. This will open a closed connection, reopen an already open connection with the same parameters or close an already open connection and open a new one with new parameters.

                               
1 - CLOSE. This will close an open connection and do nothing to the closed one.

                               
2 - STATUS. This will respond with either OK 1 for an open connection or OK 0 for a closed connection.

}
Response:
{
 "cookie":                  
Copied from request to identify it.

 "success":                 
True if the request succeeded, false otherwise.

 "data":                    
If success: can be a boolean or array of integers.

 "error":                   
If success is false: a string containing an error message.

}

Modbus TCP over Serial Gateway

The Modbus TCP over Serial gateway serial type allows redirecting TCP data coming to a specified port to an RTU specified by the Server ID. The Server ID can be specified by the user or be obtained directly from the Modbus header.
Note: Modbus TCP over Serial Gateway supports multiple connections of up to 10 clients.

Status

This section displays Modbus TCP over serial instances currently existing on the router.

Modbus TCP over Serial Gateway Configuration

Modbus TCP over Serial Gateway Configuration section displays gateway instances currently existing on the router.
By default the list is empty. To create a new gateway instance, enter the name of instance, select serial interface and click the 'Add' button.
After this you should be redirected to instance's configuration page which should look similar to this:
FieldValueDescription
Enableoff | on; default: offEnables this Modbus TCP over Serial Gateway instance configuration.
Namestring; default: noneName of the gateway instance. Used for management purposes only.
Timeoutinteger [1..60]; default: 10Set the timeout in seconds to ensure reliable communication.
DeviceUSB RS232 interface; default: USB RS232 interfaceSpecifies which serial port will be used for serial communication.
Baud rate (USB)integer [300..4000000]; default:9600Data rate for serial data transmission (in bits per second (bps)).
Data bits
  1. default=5 | 6 | 7 |8; default: 8
Number of data bits for each character.
Stop bits1| 2; default: 1Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. Two stop bits are required if slow electromechanical devices are used.
ParityEven | Odd| Mark | Space | None; default: NoneIn serial transmission, parity is a method of detecting errors. An extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1s, then it must have been corrupted. However, an even number of errors can pass the parity check.
  • None (N) - no parity method is used.
  • Odd (O) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.
  • Even (E) - the parity bit is set so that the number of "logical ones (1s)" has to be even.
  • Space (s) - the parity bit will always be a binary 0.
  • Mark (M) - the parity bit will always be a binary 1.
Flow controlNone| RTS/CTS | Xon/Xoff; default: NoneIn many circumstances a transmitter might be able to send data faster than the receiver is able to process it. To cope with this, serial lines often incorporate a "handshaking" method, usually distinguished between hardware and software handshaking.
  • RTS/CTS - hardware handshaking. RTS and CTS are turned OFF and ON from alternate ends to control data flow, for instance when a buffer is almost full.
  • Xon/Xoff - software handshaking. The Xon and Xoff characters are sent by the receiver to the sender to control when the sender will send data, i.e., these characters go in the opposite direction to the data being sent. The circuit starts in the "sending allowed" state. When the receiver's buffers approach capacity, the receiver sends the Xoff character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an Xon character to tell the sender to resume transmission.
Listening IPip; default: noneIP address to listen for incoming connections. (0.0.0.0) value may be used to listen for incoming connections on any interface or IP address.
Portinteger [0..65535]; default: nonePort number to listen for incoming connections.
Server ID configuration typeUser defined | Obtained from TCP; default: User definedSpecifies whether server IDs are user defined or automatically obtained from TCP.
Server IDinteger [1..247]; default: noneSpecifies the server ID of range of permitted server IDs. The way this field is named and its function depends on the value of the Server ID configuration field.
A range of IDs can be specified by placing a hyphen (-) between two integer numbers. For example, if you permit server IDs in the range of 10 to 20, you would specify it as: 10-20
You can also specify multiple values that are not connected in a range using commas (,). For example, to specify 6, 50 and 100 as permitted server IDs, you would have to use: 6,50,100
Permitted server IDsrange of integers; default: 1-247Read Server ID field description.
CRC verificationoff | on; default: offChecks if sent serial message is not disturbed.
Repeat serial message0 | 1 | 2 | 3; default: 0How many times serial message is repeated if CRC has failed.

IP Filter

The IP Filter section is used for configuring which network is allowed to communicate with the device. You may add a new instance by selecting the Interface and pressing Add.
Then enter the IP address and save.

See also