Jump to content

Template:Networking rutos manual modbus: Difference between revisions

From Teltonika Networks Wiki
No edit summary
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 21: Line 21:
A <b>Modbus TCP Server</b> 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.  
A <b>Modbus TCP Server</b> 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 window section and the table below provides information on the fields contained in that window:
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:


===Status===
===General===


This section displays Modbus TCP Server status information.
Status section displays Modbus TCP Server status information:


[[File:Networking_rutos_manual_modbus_modbus_tcp_server_status.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_server_status.png|border|class=tlt-border]]


===General settings===
Under the status section, you can configure the main server settings:


[[File:Networking_rutos_manual_modbus_modbus_tcp_server_v2.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_server_v3.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
Line 63: Line 63:
         <td>off | on; default: <b>off</b></td>
         <td>off | on; default: <b>off</b></td>
         <td>Allows remote Modbus connections by adding an exception to the device's firewall on the port specified in the field above.</td>
         <td>Allows remote Modbus connections by adding an exception to the device's firewall on the port specified in the field above.</td>
    </tr>
    <tr>
    <td>Enable broadcasts</td>
        <td>off | on; default: <b>off</b></td>
        <td>Process incoming Modbus broadcast messages.</td>
     </tr>
     </tr>
     <tr>
     <tr>
Line 81: Line 86:
     <tr>
     <tr>
     <td><span style="color:blue">Register file path</span></td>
     <td><span style="color:blue">Register file path</span></td>
         <td>path; default: <b>/tmp/regfile</b></td>
         <td>path; default: <b>/mnt/regfile</b></td>
         <td>Path 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).</td>
         <td>Path 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).</td>
     </tr>
     </tr>
Line 96: Line 101:
</table>
</table>


{{#ifeq: {{{serial}}} | 1 |
===Data Sources===
==Modbus Serial Server==
A <b>Modbus Serial Server</b> 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.
 
===Status===
This section displays Modbus Serial Server instances currently existing on the router.


[[File:Networking_rutos_manual_modbus_modbus_serial_server_status.png|border|class=tlt-border]]
<b>Data sources</b> transmit data from one or more data sources (can be a Modbus client) and write it to Modbus registers.


===Modbus Serial Server Configuration===
To add new data source, press `Add` button:
----
The <b>Modbus Serial Server Configuration</b> 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.


[[File:Networking_rutos_manual_modbus_modbus_serial_server_add_button_rs232_{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|1|0}}_v1.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_server_data_sources_add.png|border|class=tlt-border]]


After clicking 'Add' you will be redirected to the newly added server instance configuration page.
Register configuration:


[[File:Networking_rutos_manual_modbus_modbus_serial_server_configuration_rs232_{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|1|0}}_v2.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_server_data_sources_register_configuration.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <th>Field</th>
        <th>Value</th>
      <th>Value</th>
        <th>Description</th>
      <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Enable</td>
      <td>Enable</td>
        <td>off {{!}} on; default: <b>off</b></td>
      <td>off {{!}} on; default: <b>off</b></td>
        <td>Enables this Modbus Serial Server instance configuration.</td>
      <td>Turns Register configuration on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Name</td>
      <td>Register name</td>
        <td>string; default: <b>none</b></td>
      <td>string; default: <b>none</b></td>
        <td>Name of the serial server instance. Used for management purposes only.</td>
      <td>Name of the register.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Device</td>
      <td>Register source</td>
        <td>{{Template: Networking rutos manual serial ports| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}; default: <b>{{Template: Networking rutos manual default serial port| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}</b></td>  
      <td>list; default: <b>none</b></td>
        <td>Specifies which serial port will be used for serial communication.</td>
      <td>Client service which will be sending requests.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Device ID</td>
      <td>Register value</td>
        <td>integer [0..255]; default: <b>1</b></td>  
      <td>list and permissions type; default: <b>none</b></td>
        <td>Specifies which serial port will be used for serial communication.</td>
      <td>Request value and its permissions (Read-Only, Write-Only or Read-Write).</td>
    </tr>
    <tr>
      <td>Register range</td>
      <td>integer [1..65535]; default: <b>none</b></td>
      <td>Specify the start index and count for the range.</td>
     </tr>
     </tr>
     <tr>
     <tr>
    <td>Mobile Data type</td>
      <td>Register type</td>
        <td>Bytes {{!}} Kilobytes {{!}} Megabytes; default: <b>Bytes</b></td>
      <td>Binary {{!}} String {{!}} Bool {{!}} INT8 {{!}} UINT8 {{!}} INT16 {{!}} UINT16 {{!}} INT32 {{!}} UINT32 {{!}} INT64 {{!}} UINT64 {{!}} FLOAT32 {{!}} FLOAT64; default: <b>Binary</b></td>
        <td>Selects mobile data unit representation type.</td>
      <td>Value data type.</td>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (RS485)</td>
      <td>Register size (with Binary and String data)</td>
        <td>integer [300..230400]; default:<b>9600</b></td>
      <td>integer [1..8064]; default: <b>none</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
      <td>Size of the value in bytes.</td>
     </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (RS232)</td>
      <td>Modbus register range</td>
        <td>integer [300..115200]; default:<b>9600</b></td>
      <td>integer; default: <b>none</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
      <td>Start and calculated end of the register numbers.</td>
    </tr>|}}{{#ifeq: {{{usb}}} | 1 |
     </tr>
    <tr>
    <td>Baud rate (USB)</td>
        <td>integer [300..4000000]; default:<b>9600</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
     </tr>|}}
     <tr>
     <tr>
        <td>Data bits</td>
      <td>Modbus data type</td>
        <td>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|{{#switch:{{{series}}}|TRB2|TRB2M=|#default=5 {{!}} 6 {{!}}}} 7 {{!}} |}}8; default: <b>8</b></td>
      <td>Coils (1) {{!}} Input coils (2) {{!}} Holding registers (3) {{!}} Input registers (4); default: <b>Coils (1)</b></td>
        <td>Number of data bits for each character.</td>
      <td>Modbus function code to be used for this request.</td>
     </tr>
     </tr>
    <tr>
</table>
        <td>Stop bits</td>
 
        <td>1{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} 2|}}; default: <b>1</b></td>
{{#ifeq: {{{serial}}} | 1 |
        <td>Stop 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.</td>
==Modbus Serial Server==
A <b>Modbus Serial Server</b> 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===
 
<b>Example</b> of what the status of a Modbus serial server instance on a device looks like:
 
[[File:Networking_rutos_manual_modbus_modbus_serial_server_status.png|border|class=tlt-border]]
 
The <b>Modbus Serial Server Configuration</b> 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.
 
[[File:Networking_rutos_manual_modbus_modbus_serial_server_device configuration.png|border|class=tlt-border]]
 
<table class="nd-mantable">
    <tr>
        <th>Field</th>
        <th>Value</th>
        <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Parity</td>
         <td>Enable</td>
         <td>Even {{!}} Odd{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} Mark {{!}} Space|}} {{!}} None; default: <b>None</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>In 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.
         <td>Enables this Modbus Serial Server instance configuration.</td>
            <ul>
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<li><b>Space</b> (<b>s</b>) - the parity bit will always be a binary 0.</li>
                <li><b>Mark</b> (<b>M</b>) - the parity bit will always be a binary 1.</li>|}}
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Flow control</td>
         <td>Name</td>
         <td>None {{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} RTS/CTS {{!}} Xon/Xoff|}}; default: <b>None</b></td>
         <td>string; default: <b>none</b></td>
         <td>In 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.
         <td>Name of the serial server instance. Used for management purposes only.</td>
{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<ul>
     </tr>
                <li><b>RTS/CTS</b> - 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.</li>
                <li><b>Xon/Xoff</b> - 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.</li>
            </ul>|}}
        </td>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     <tr>
     <tr>
         <td><span style="color:blue">RS485:</span> Full Duplex</td>
         <td>Device</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>{{Template: Networking rutos manual serial ports| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}; default: <b>{{Template: Networking rutos manual default serial port| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}</b></td>  
         <td>Enables RS485 full duplex.</td>
         <td>Specifies which serial port will be used for serial communication.</td>
     </tr>|}}
     </tr>
     <tr>
     <tr>
    <td>Enable custom register block</td>
        <td>Device ID</td>
         <td>off {{!}} <span style="color:blue">on</span>; default: <b>off</b></td>
         <td>integer [0..255]; default: <b>1</b></td>  
         <td>Allows the usage of custom register block.</td>
         <td>Specifies which serial port will be used for serial communication.</td>
     </tr>
     </tr>
     <tr>
     <tr>
     <td><span style="color:blue">Register file path</span></td>
     <td>Mobile Data type</td>
         <td>path; default: <b>/tmp/regfile</b></td>
         <td>Bytes {{!}} Kilobytes {{!}} Megabytes; default: <b>Bytes</b></td>
         <td>Path 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).</td>
         <td>Selects mobile data unit representation type.</td>
     </tr>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     <tr>
     <tr>
     <td><span style="color:blue">First register number</span></td>
     <td>Baud rate (RS485)</td>
         <td>integer [1025..65536]; default: <b>1025</b></td>
         <td>integer [300..230400]; default:<b>9600</b></td>
         <td>First register in custom register block</td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
     </tr>
     </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
     <tr>
     <tr>
     <td><span style="color:blue">Register count</span></td>
     <td>Baud rate (RS232)</td>
         <td>integer [1..64512]; default: <b>128</b></td>
        <td>integer [300..115200]; default:<b>9600</b></td>
         <td>Path 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).</td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}{{#ifeq: {{{usb}}} | 1 |
    <tr>
    <td>Baud rate (USB)</td>
         <td>integer [300..4000000]; default:<b>9600</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}
    <tr>
        <td>Data bits</td>
        <td>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|{{#switch:{{{series}}}|TRB2|TRB2M=|#default=5 {{!}} 6 {{!}}}} 7 {{!}} |}}8; default: <b>8</b></td>
        <td>Number of data bits for each character.</td>
    </tr>
    <tr>
        <td>Stop bits</td>
        <td>1{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} 2|}}; default: <b>1</b></td>
        <td>Stop 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.</td>
     </tr>
     </tr>
</table>|}}
    <tr>
 
        <td>Parity</td>
==Modbus Registers==
        <td>Even {{!}} Odd{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} Mark {{!}} Space|}} {{!}} None; default: <b>None</b></td>
 
        <td>In 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.
{{Template:Networking_rutos_manual_modbus_modbus_tcp_get_parameters_table
            <ul>
|series = {{{series}}}
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
|name = {{{name}}}
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
|mobile = {{{mobile}}}  
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<li><b>Space</b> (<b>s</b>) - the parity bit will always be a binary 0.</li>
|analog = {{{analog}}}
                <li><b>Mark</b> (<b>M</b>) - the parity bit will always be a binary 1.</li>|}}
|gps = {{{gps}}}
            </ul>
|dualsim = {{{dualsim}}}
        </td>
|digital_input = {{{digital_input}}}
    </tr>
|isolated_input = {{{isolated_input}}}
    <tr>
|isolated_output = {{{isolated_output}}}
        <td>Flow control</td>
|relay = {{{relay}}}
        <td>None {{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} RTS/CTS {{!}} Xon/Xoff|}}; default: <b>None</b></td>
|latching_relay = {{{latching_relay}}}
        <td>In 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.
|power_socket = {{{power_socket}}}
{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<ul>
|configurable = {{{configurable}}}
                <li><b>RTS/CTS</b> - 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.</li>
|acl = {{{acl}}}
                <li><b>Xon/Xoff</b> - 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.</li>
}}
            </ul>|}}
 
        </td>
{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table
    </tr>{{#ifeq: {{{rs485}}} | 1 |
|series = {{{series}}}
    <tr>
|name = {{{name}}}
        <td><span style="color:blue">RS485:</span> Full Duplex</td>
|mobile = {{{mobile}}}
        <td>off {{!}} on; default: <b>off</b></td>
|wifi = {{{wifi}}}
        <td>Enables RS485 full duplex.</td>
|wifi5 = {{{wifi5}}}
    </tr>|}}
|analog = {{{analog}}}
    <tr>
|dualsim = {{{dualsim}}}
    <td>Enable broadcasts</td>
|isolated_output = {{{isolated_output}}}
        <td>off {{!}} on; default: <b>off</b></td>
|relay = {{{relay}}}
        <td>Process incoming Modbus broadcast messages.</td>
|latching_relay = {{{latching_relay}}}
    </tr>
|power_socket = {{{power_socket}}}
    <tr>
|configurable = {{{configurable}}}
    <td>Enable custom register block</td>
|acl = {{{acl}}}
        <td>off {{!}} <span style="color:blue">on</span>; default: <b>off</b></td>
}}
        <td>Allows the usage of custom register block.</td>
==Modbus TCP Client==
    </tr>
    <tr>
    <td><span style="color:blue">Register file path</span></td>
        <td>path; default: <b>/tmp/regfile</b></td>
        <td>Path 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).</td>
    </tr>
    <tr>
    <td><span style="color:blue">First register number</span></td>
        <td>integer [1025..65536]; default: <b>1025</b></td>
        <td>First register in custom register block</td>
    </tr>
    <tr>
    <td><span style="color:blue">Register count</span></td>
        <td>integer [1..64512]; default: <b>128</b></td>
        <td>Path 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).</td>
    </tr>
</table>


A <b>Modbus TCP Client</b> can request data from Modbus servers. The Modbus TCP devices section is used to configure Modbus TCP servers and enable Client.  
===Data Sources===
 
<b>Data sources</b> transmit data from one or more data sources (can be a Modbus serial client) and write it to Modbus registers.


Notice the Global section config. It is used to outright turn the service off or on if any active configurations are present.
To add new data source, press `Add` button (<b>Note:</b> Modbus serial server instance is required when creating a new instance.):


[[File:Networking rutos manual modbus modbus tcp client modbus tcp server devices global button v3.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_serial_server_data_sources_add.png|border|class=tlt-border]]


Clicking the Cog icon opens a modal window. The global configuration slider can be set and it's state saved.
Register configuration:


[[File:Networking_rutos_manual_modbus_modbus_tcp_client_modbus_tcp_server_devices_global_config_modal_v2.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_serial_server_data_sources_register_configuration.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <th>Field</th>
        <th>Value</th>
      <th>Value</th>
        <th>Description</th>
      <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Enabled</td>
      <td>Enable</td>
        <td>off {{!}} on; default: <b>off</b></td>
      <td>off {{!}} on; default: <b>off</b></td>
        <td>Turn on/off Modbus client service.</td>
      <td>Turns Register configuration on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Database location</td>
      <td>Register name</td>
        <td>RAM {{#ifeq: {{{usb}}} | 1 | {{!}} USB|}}; default: <b>RAM</b></td>
      <td>string; default: <b>none</b></td>
        <td>Select Modbus database location.</td>
      <td>Name of the register.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Database size</td>
      <td>Register source</td>
        <td>size in KiB</td>
      <td>list; default: <b>none</b></td>
        <td>Current database size.</td>
      <td>Client service which will be sending requests.</td>
     </tr>
     </tr>
</table>
By default, the client list is empty and client is disabled. To add a new client, click the 'Add' button
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_modbus_tcp_server_devices_add_button_v3.png|border|class=tlt-border]]
After clicking 'Add' you will be redirected to the newly added modbus device configuration page.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_server_device_configuration_v1.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
        <th>Field</th>
      <td>Register value</td>
        <th>Value</th>
      <td>list and permissions type; default: <b>none</b></td>
        <th>Description</th>
      <td>Request value and its permissions (Read-Only, Write-Only or Read-Write).</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Enabled</td>
      <td>Register range</td>
        <td>off | on; default: <b>off</b></td>
      <td>integer [1..65535]; default: <b>none</b></td>
        <td>Turns communication with the server device on or off.</td>
      <td>Specify the start index and count for the range.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Name</td>
      <td>Register type</td>
        <td>string; default: <b>none</b></td>
      <td>Binary {{!}} String {{!}} Bool {{!}} INT8 {{!}} UINT8 {{!}} INT16 {{!}} UINT16 {{!}} INT32 {{!}} UINT32 {{!}} INT64 {{!}} UINT64 {{!}} FLOAT32 {{!}} FLOAT64; default: <b>Binary</b></td>
        <td>Server device's name, used for easier management purposes.</td>
      <td>Value data type.</td>
    </tr>
    <tr>
        <td>Server ID</td>
        <td>integer [0..255]; default: <b>none</b></td>
        <td>Server ID. Each server in a network is assigned a unique identifier ranging from 1 to 255. When the client requests data from a server, the first byte it sends is the Server ID. When set to 0, the server will respond to requests addressed to any ID.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>IP address</td>
      <td>Register size (when Binary and String data is selected)</td>
        <td>ip4; default: <b>none</b></td>
      <td>integer [1..8064]; default: <b>none</b></td>
        <td>Server device's IP address.</td>
      <td>Size of the value in bytes.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Port</td>
      <td>Modbus serial server</td>
        <td>integer [0..65535]; default: <b>none</b></td>
      <td>list; default: <b>the first instance from Modbus Serial server page</b></td>
        <td>Server device's Modbus TCP port.</td>
      <td>Modbus serial server instance name or ID.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Timeout</td>
      <td>Modbus register range</td>
        <td>integer [1..30]; default: '''5'''</td>
      <td>integer; default: <b>none</b></td>
        <td>Maximum response wait time.</td>
      <td>Start and calculated end of the register numbers.</td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Always reconnect</td>
      <td>Modbus data type</td>
        <td>off | on; default: <b>off</b></td>
      <td>Coils (1) {{!}} Input coils (2) {{!}} Holding registers (3) {{!}} Input registers (4); default: <b>Coils (1)</b></td>
        <td>Create new connection after every Modbus request.</td>
      <td>Modbus function code to be used for this request.</td>
     </tr>
     </tr>
    <tr>
</table>|}}
        <td>Number of timeouts</td>
 
        <td>integer [0..10]; default: <b>1</b></td>
==Modbus Registers==
        <td>Skip pending request and reset connection after number of request failures.</td>
 
    </tr>
{{Template:Networking_rutos_manual_modbus_modbus_tcp_get_parameters_table
    <tr>
|series = {{{series}}}
        <td>Frequency</td>
|name = {{{name}}}
        <td>Period {{!}} <span style="color:blue">Schedule</span>; default: <b>Period</b></td>
|mobile = {{{mobile}}}
        <td></td>
|analog = {{{analog}}}
    </tr>
|gps = {{{gps}}}
    <tr>
|dualsim = {{{dualsim}}}
        <td>Delay</td>
|digital_input = {{{digital_input}}}
        <td>integer [0..999]; default: <b>0</b></td>
|isolated_input = {{{isolated_input}}}
        <td>Wait in milliseconds after connection initialization.</td>
|isolated_output = {{{isolated_output}}}
    </tr>
|relay = {{{relay}}}
    <tr>
|latching_relay = {{{latching_relay}}}
        <td>Period</td>
|power_socket = {{{power_socket}}}
        <td>integer [1..99999]; default: <b>none</b></td>
|configurable = {{{configurable}}}
        <td>Interval in seconds for sending requests to this device</td>
|acl = {{{acl}}}
    </tr>
}}
    <tr>
 
        <td><span style="color:blue">Schedule request</span></td>
{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table
        <td>time format string 'hh:mm:ss'; default: <b>none</b></td>
|series = {{{series}}}
        <td>Schedule request time (format: Hours:Minutes:Seconds).</td>
|name = {{{name}}}
    </tr>
|mobile = {{{mobile}}}
</table>
|wifi = {{{wifi}}}
|wifi5 = {{{wifi5}}}
|analog = {{{analog}}}
|dualsim = {{{dualsim}}}
|isolated_output = {{{isolated_output}}}
|relay = {{{relay}}}
|latching_relay = {{{latching_relay}}}
|power_socket = {{{power_socket}}}
|configurable = {{{configurable}}}
|acl = {{{acl}}}
}}
==Modbus TCP Client==
 
A <b>Modbus TCP Client</b> can request data from Modbus servers. The Modbus TCP devices section is used to configure Modbus TCP servers and enable Client.  


===Requests Configuration===
Notice the Global section config. It is used to outright turn the service off or on if any active configurations are present.
----
A Modbus <b>request</b> 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.


<span style="color:red"> <b>Note: </b></span> Modbus TCP Client uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>First Register</i> field.
[[File:Networking rutos manual modbus modbus tcp client modbus tcp server devices global button v3.png|border|class=tlt-border]]


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:
Clicking the Cog icon opens a modal window. The global configuration slider can be set and it's state saved.


[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_add_new_instance_v1.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_modbus_tcp_server_devices_global_config_modal_v2.png|border|class=tlt-border]]
 
The new Request Configuration should become visible in the list:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_v3.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
Line 386: Line 415:
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Name</td>
         <td>Enabled</td>
         <td>string; default: <b>Unnamed</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Name of this Request Configuration. Used for easier management purposes.</td>
         <td>Turn on/off Modbus client service.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Data type</td>
         <td>Database location</td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>RAM {{#ifeq: {{{usb}}} | 1 | {{!}} USB|}}; default: <b>RAM</b></td>
         <td>Defines how read data will be stored.</td>
         <td>Select Modbus database location.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function</td>
         <td>Database size</td>
         <td>Read 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: <b>Read holding registers (3)</b></td>
         <td>size in KiB</td>
         <td>Specifies the type of register being addressed by a Modbus request.  
         <td>Current database size.</td>
        </td>
     </tr>
     </tr>
</table>
By default, the client list is empty and client is disabled. To add a new client, click the 'Add' button
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_modbus_tcp_server_devices_add_button_v3.png|border|class=tlt-border]]
After clicking 'Add' you will be redirected to the newly added modbus device configuration page.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_server_device_configuration_v1.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <td>First Register</td>
         <th>Field</th>
         <td>integer [0..65535]; default: <b>1</b></td>
         <th>Value</th>
         <td>First Modbus register from which data will be read.</td>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Register Count / Values</td>
         <td>Enabled</td>
         <td>integer [1..2000]; default: <b>1</b></td>
         <td>off | on; default: <b>off</b></td>
         <td>Number of Modbus registers that will be read during the request.</td>
         <td>Turns communication with the server device on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Remove Brackets</td>
         <td>Name</td>
         <td>off | on; default: <b>off</b></td>
         <td>string; default: <b>none</b></td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
         <td>Server device's name, used for easier management purposes.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Store on change only</td>
         <td>Server ID</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>integer [0..255]; default: <b>1</b></td>
         <td>Store the response only if the value has changed.</td>
         <td>Modbus 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.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>off/on slider</td>
         <td>IP address</td>
         <td>off | on; default: <b>off</b></td>
         <td>ip4; default: <b>none</b></td>
         <td>Turns the request on or off.</td>
         <td>Server device's IP address.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Delete [ X ]</td>
         <td>Port</td>
         <td>- (interactive button)</td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Deletes the request.</td>
         <td>Server device's Modbus TCP port.</td>
     </tr>
     </tr>
</table>
    <tr>
 
        <td>Timeout</td>
<b>Additional note:</b> 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:
        <td>integer [1..30]; default: '''5'''</td>
 
         <td>Maximum response wait time.</td>
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_on_off_slider_v1.png|border|class=tlt-border]]
----
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. <b>Note:</b> to use test buttons, you need to enable [[#Modbus_TCP_Client|Client section]]. A successful response to a test may look something like this:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
 
===Alarms Configuration===
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus TCP Client (this {{{name}}} 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.
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_alarms_configuration_add_button_v2.png|border|class=tlt-border]]
 
After adding the Alarm you should be redirected to its configuration page which should look similar to this:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_v1.png|border|class=tlt-border]]
 
<table class="nd-mantable">
    <tr>
        <th>Field</th>
         <th>Value</th>
        <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enabled</td>
         <td>Always reconnect</td>
         <td>off | on; default: <b>off</b></td>
         <td>off | on; default: <b>off</b></td>
         <td>Turns the alarm on or off.</td>
         <td>Create new connection after every Modbus request.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function code</td>
         <td>Number of timeouts</td>
         <td>Read Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>integer [0..10]; default: <b>1</b></td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#Server_Device_Configuration|Server Device Configuration]].</td>
         <td>Skip pending request and reset connection after number of request failures.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Compared condition data type</td>
         <td>Frequency</td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>Period {{!}} <span style="color:blue">Schedule</span>; default: <b>Period</b></td>
         <td>Select data type that will be used for checking conditions.</td>
         <td></td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>First register number</td>
         <td>Delay</td>
         <td>integer [1..65536]; default: <b>none</b></td>
         <td>integer [0..999]; default: <b>0</b></td>
         <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
         <td>Wait in milliseconds after connection initialization.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Values</td>
         <td>Period</td>
         <td>various; default: <b>none</b></td>
         <td>integer [1..99999]; default: <b>60</b></td>
         <td>The value against which the read data will be compared.</td>
         <td>Interval in seconds for sending requests to this device</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Condition</td>
         <td><span style="color:blue">Schedule request</span></td>
         <td>More than | Less than | Equal to | Not Equal to | Less or equal | More or equal; default: <b>More than</b></td>
         <td>time format string 'hh:mm:ss'; default: <b>none</b></td>
         <td>When 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.</td>
         <td>Schedule request time (format: Hours:Minutes:Seconds).</td>
     </tr>
     </tr>
</table>
===Requests Configuration===
----
A Modbus <b>request</b> 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.
<span style="color:red"> <b>Note: </b></span> Modbus TCP Client uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>First Register</i> 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:
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_add_new_instance_v1.png|border|class=tlt-border]]
The new Request Configuration should become visible in the list:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_v3.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <td>Action frequency</td>
         <th>Field</th>
         <td>Every trigger | First trigger; default: <b>Every trigger</b></td>
         <th>Value</th>
         <td>Describes how frequently the specified action will be taken.</td>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Redundancy protection</td>
         <td>Name</td>
         <td>off | <span style="color:blue">on</span>; default: <b>off</b></td>
         <td>string; default: <b>Unnamed</b></td>
         <td>Protection against executing a configured action too often.</td>
         <td>Name of this Request Configuration. Used for easier management purposes.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">Redundancy protection period</span></td>
         <td>Data type</td>
         <td>integer [1..86400]; default: <b>none</b></td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>Duration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.</td>
         <td>Defines how read data will be stored.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Action</td>
         <td>Function</td>
         <td>Ubus event {{!}} <span style="color: brown;">Email</span> {{!}} {{#ifeq:{{{mobile}}}|1|<span style="color: #0054a6;">SMS</span> {{!}}|}} <span style="color: purple;">MODBUS Write Request</span> {{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default= {{!}} <span style="color: green;">Trigger output</span>}} {{!}} <span style="color: red;">MQTT message</span>; default: <b>MODBUS Write Request</b></td>
         <td>Read 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: <b>Read holding registers (3)</b></td>
         <td>Action that will be taken if the condition is met. Possible actions:
         <td>Specifies the type of register being addressed by a Modbus request.  
            <ul>{{#ifeq: {{{mobile}}} | 1 |
                <li><b>SMS</b> - sends SMS message to a specified recipient(s).</li>|}}
                <li><b>Email</b> - sends Email to a specified recipient(s).</li>
                <li><b>Ubus event</b> - sends Email to a specified recipient(s).</li>
                <li><b>MQTT message</b> - sends MQTT message to a specified broker.</li>
                <li><b>Ubus event</b> - sends ubus event.</li>
                <li><b>Modbus Request</b> - sends a Modbus Write request to a specified server.</li>
{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=<li><b>Trigger output</b> - changes state of selected I/O output pin.</li>}}
            </ul>
         </td>
         </td>
    </tr>{{#ifeq: {{{mobile}}} | 1 |
    <tr>
        <td><span style="color: #0054a6;">SMS: Message</span></td>
        <td>string; default: <b>none</b></td>
        <td>SMS message text.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Recipients</span></td>
         <td>First Register</td>
         <td>Single {{!}} Group; default: <b>none</b></td>
         <td>integer [0..65535]; default: <b>1</b></td>
         <td>You can choose to add a single number or use a phone group list.</td>
         <td>First Modbus register from which data will be read.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Phone group (Group recipient)</span></td>
         <td>Register Count / Values</td>
         <td>phone group; default: <b>none</b></td>
         <td>integer [1..2000]; default: <b>1</b></td>
         <td>Recipient groups, including their associated phone numbers, can be configured [[{{{name}}}_Administration#Recipients | here]].</td>
         <td>Number of Registers/Coils/Inputs or actual values to be written (Multiple values must be separated by space character).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Phone number (Single recipient)</span></td>
         <td>No brackets</td>
         <td>phone number; default: <b>none</b></td>
         <td>off | on; default: <b>off</b></td>
         <td>Recipient's phone number.</td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
     </tr>|}}
     </tr>
     <tr>
     <tr>
         <td><span style="color: brown;">Email: Subject</span></td>
         <td>Store on change only</td>
         <td>string; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Subject of an email. Allowed characters (a-zA-Z0-9!@#$%&*+-/=?^_`{|}~. ).</td>
         <td>Store the response only if the value has changed.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: brown;">Email: Message text</span></td>
         <td>Broadcast</td>
         <td>string; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Message that will be sent if condition passes.</td>
         <td>Enable to broadcast the request to all devices (only for write requests).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: brown;">Email: Sender's email account</span></td>
         <td>Enabled</td>
         <td>string; default: <b>none</b></td>
         <td>off | on; default: <b>off</b></td>
         <td>Sender's email configuration (configure it [[{{{name}}}_Administration#Recipients | here]]).</td>
         <td>Turns the request on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: brown;">Email: Recipient's email address</span></td>
         <td>Actions</td>
         <td>email address; default: <b>none</b></td>
         <td>- (interactive button)</td>
        <td>For whom you want to send an email to. Allowed characters (a-zA-Z0-9._%+@-).</td>
         <td>Deletes the request.</td>
    </tr>
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
        <td>ip | host; default: <b>none</b></td>
        <td>Modbus server's IP address.</td>
    </tr>
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: Port</span></td>
        <td>integer [0..65535]; default: <b>none</b></td>
        <td>Modbus server's port.</td>
    </tr>
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
        <td>integer [1..30]; default: <b>5</b></td>
         <td>Maximum time to wait for a response.</td>
     </tr>
     </tr>
</table>
<b>Additional note:</b> 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:
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_on_off_slider_v1.png|border|class=tlt-border]]
----
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. <b>Note:</b> to use test buttons, you need to enable [[#Modbus_TCP_Client|Client section]]. A successful response to a test may look something like this:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
===Alarms Configuration===
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus TCP Client (this {{{name}}} 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.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_alarms_configuration_add_button_v2.png|border|class=tlt-border]]
After adding the Alarm you should be redirected to its configuration page which should look similar to this:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_v1.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: ID</span></td>
         <th>Field</th>
         <td>integer [1..255]; default: <b>none</b></td>
         <th>Value</th>
         <td>Modbus server ID.</td>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>Enabled</td>
         <td>Set Single Coil (5) | Set Single Register (6) | Set Multiple Coils (15) | Set Multiple Registers (16); default: <b>Set Single Coil (5)</b></td>
         <td>off | on; default: <b>off</b></td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
         <td>Turns the alarm on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Executed action data type</span></td>
         <td>Function code</td>
         <td>8bit 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: <b>Bool</b></td>
         <td>Read Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>Select data type that will be used for executing action.</td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#Server_Device_Configuration|Server Device Configuration]].</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: First register number</span></td>
         <td>Compared condition data type</td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>Begins reading from the register specified in this field.</td>
         <td>Select data type that will be used for checking conditions.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
         <td>First register number</td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>integer [1..65536]; default: <b>none</b></td>
         <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
         <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
     </tr>{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=
     </tr>
     <tr>
     <tr>
         <td><span style="color: green;">Trigger output: Output</span></td>{{#switch:{{{series}}}
         <td>Values</td>
| RUTX|RUT2|RUT2M =<td>Output (4); default: <b>Output (4)</b></td>
        <td>various; default: <b>none</b></td>
| TRB1={{#ifeq:{{{name}}}|TRB141|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4) {{!}} Relay (3,4,5) {{!}} Latching Relay (11,12,13); default: <b>Configurable Input/Output (3)</b></td>|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>}}|RUT30X|RUT301|RUT36X|RUT361|TRB5 =<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>
         <td>The value against which the read data will be compared.</td>
| TRB2|TRB2M =<td>Configurable Input/Output (2) {{!}} Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (2)</b></td>
| RUT9|RUT9M =<td>Output (4) {{!}} Isolated Output (3,4,8)  {{!}} Relay (5,10); default: <b>Output (4)</b></td>}}
         <td>Selects which output will be triggered.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: green;">Trigger output: I/O Action</span></td>
         <td>Condition</td>
         <td>Turn On {{!}} Turn Off {{!}} Invert; default: <b>Turn On</b></td>
         <td>More than | Less than | Equal to | Not Equal to | Less or equal | More or equal; default: <b>More than</b></td>
         <td>Selects the action performed on the output.</td>
         <td>When 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.</td>
     </tr>}}
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: JSON format</span></td>
         <td>Action frequency</td>
         <td>string; default: <b>none</b> </td>
         <td>Every trigger | First trigger; default: <b>Every trigger</b></td>
         <td>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, Mobile IP addresses, Signal strength, 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)
         <td>Describes how frequently the specified action will be taken.</td>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Hostname</span></td>
         <td>Redundancy protection</td>
        <td>host {{!}} ip; default: <b>none</b> </td>
        <td>off | <span style="color:blue">on</span>; default: <b>off</b></td>
         <td>Broker’s IP address or hostname.</td>
         <td>Protection against executing a configured action too often.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Port</span></td>
         <td><span style="color:blue">Redundancy protection period</span></td>
         <td>integer [0..65535]; default: <b>1883</b></td>
         <td>integer [1..86400]; default: <b>none</b></td>
         <td>Broker's port number.</td>
         <td>Duration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Keepalive</span></td>
         <td>Action</td>
         <td>positive integer; default: <b>none</b></td>
        <td>Ubus event {{!}} <span style="color: brown;">Email</span> {{!}} {{#ifeq:{{{mobile}}}|1|<span style="color: #0054a6;">SMS</span> {{!}}|}} <span style="color: purple;">MODBUS Write Request</span> {{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default= {{!}} <span style="color: green;">Trigger output</span>}} {{!}} <span style="color: red;">MQTT message</span>; default: <b>MODBUS Write Request</b></td>
        <td>The 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</td>
         <td>Action that will be taken if the condition is met. Possible actions:
     </tr>
            <ul>{{#ifeq: {{{mobile}}} | 1 |
                <li><b>SMS</b> - sends SMS message to a specified recipient(s).</li>|}}
                <li><b>Email</b> - sends Email to a specified recipient(s).</li>
                <li><b>Ubus event</b> - sends Email to a specified recipient(s).</li>
                <li><b>MQTT message</b> - sends MQTT message to a specified broker.</li>
                <li><b>Ubus event</b> - sends ubus event.</li>
                <li><b>Modbus Request</b> - sends a Modbus Write request to a specified server.</li>
{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=<li><b>Trigger output</b> - changes state of selected I/O output pin.</li>}}
            </ul>
        </td>
     </tr>{{#ifeq: {{{mobile}}} | 1 |
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Topic</span></td>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
         <td>string; default: <b>none</b></td>
         <td>string; default: <b>none</b></td>
         <td>The name of the topic that the broker will subscribe to.</td>
         <td>SMS message text.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Client ID</span></td>
         <td><span style="color: #0054a6;">SMS: Recipients</span></td>
         <td>positive integer; default: <b>none</b></td>
         <td>Single {{!}} Group; default: <b>none</b></td>
         <td>Client ID to send with the data. If empty, a random client ID will be generated </td>
         <td>You can choose to add a single number or use a phone group list.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: QoS</span></td>
         <td><span style="color: #0054a6;">SMS: Phone group (Group recipient)</span></td>
         <td>At most once (0) {{!}} At least once (1) {{!}} Exactly once (2); default: <b>At most once (0)</b></td>
         <td>phone group; default: <b>none</b></td>
         <td>A period of time (in seconds) which has to pass after a trigger event before this Action is executed.</td>
         <td>Recipient groups, including their associated phone numbers, can be configured [[{{{name}}}_Administration#Recipients | here]].</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Use root CA</span></td>
         <td><span style="color: #0054a6;">SMS: Phone number (Single recipient)</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>phone number; default: <b>none</b></td>
         <td>Use root CA for verifying the servers certificates </td>
        <td>Recipient's phone number.</td>
    </tr>|}}
    <tr>
        <td><span style="color: brown;">Email: Subject</span></td>
        <td>string; default: <b>none</b></td>
         <td>Subject of an email. Allowed characters (a-zA-Z0-9!@#$%&*+-/=?^_`{|}~. ).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Use TLS</span></td>
         <td><span style="color: brown;">Email: Message text</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>string; default: <b>none</b></td>
         <td>Turns the use of TLS/SSL for this MQTT connection on or off.</td>
         <td>Message that will be sent if condition passes.</td>
    </tr><tr>
        <td><span style="color: red;">MQTT message: Use credentials</span></td>
        <td>off {{!}} on; default: <b>off</b></td>
        <td>Turns the use of username and password for this MQTT connection on or off.</td>
     </tr>
     </tr>
</table>
{{#ifeq: {{{serial}}} | 1 |
==Modbus Serial Client==
The <b>Modbus Serial Client</b> 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.
[[File:Networking_rutos_manual_modbus_modbus_serial_client_v2.png|border|class=tlt-border]]
<!--<u><b>Note:</b> Modbus Serial Client is additional software that can be installed from the <b>System → [[{{{name}}} Package Manager|Package Manager]]</b> page.</u>-->
Notice the Global section config. It is used to outright turn the service off or on if any active configurations are present.
[[File:Networking rutos manual modbus modbus serial client global button v1.png|border|class=tlt-border]]
Clicking the Cog icon opens a modal window. The global configuration slider can be set and it's state saved.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_modbus_tcp_server_devices_global_config_modal_v2.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <td><span style="color: brown;">Email: Sender's email account</span></td>
         <th>Value</th>
         <td>string; default: <b>none</b></td>
         <th>Description</th>
         <td>Sender's email configuration (configure it [[{{{name}}}_Administration#Recipients | here]]).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enabled</td>
         <td><span style="color: brown;">Email: Recipient's email address</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>email address; default: <b>none</b></td>
         <td>Turn on/off Modbus client service.</td>
         <td>For whom you want to send an email to. Allowed characters (a-zA-Z0-9._%+@-).</td>
    </tr>
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
        <td>ip | host; default: <b>none</b></td>
        <td>Modbus server's IP address.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Database location</td>
         <td><span style="color: purple;">MODBUS Write Request: Port</span></td>
         <td>RAM {{#ifeq: {{{usb}}} | 1 | {{!}} USB|}}; default: <b>RAM</b></td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Select Modbus database location.</td>
         <td>Modbus server's port.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Database size</td>
         <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
         <td>size in KiB</td>
        <td>integer [1..30]; default: <b>5</b></td>
         <td>Current database size.</td>
        <td>Maximum time to wait for a response.</td>
    </tr>
    <tr>
         <td><span style="color: purple;">MODBUS Write Request: ID</span></td>
        <td>integer [1..255]; default: <b>none</b></td>
         <td>Modbus server ID.</td>
     </tr>
     </tr>
</table>
===General Status===
----
This section displays Modbus Client general status information.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_status.png|border|class=tlt-border]]
===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.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_device_configuration.png|border|class=tlt-border]]
By default there are no instances created. To add a new serial device configuration, enter an instance name and click the 'Add' button.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_device_configuration_add_button_{{#ifexpr:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|0}}.png|border|class=tlt-border]]
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.
[[File:Networking_rutos_manual_modbus_modbus_serial_client_device_configuration_rs_device_modbus_client_configuration_v1_{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|1|0}}.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <th>Value</th>
         <td>Set Single Coil (5) | Set Single Register (6) | Set Multiple Coils (15) | Set Multiple Registers (16); default: <b>Set Single Coil (5)</b></td>
         <th>Description</th>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enable</td>
         <td><span style="color: purple;">MODBUS Write Request: Executed action data type</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>8bit 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: <b>Bool</b></td>
         <td>Enables this Modbus Serial Device instance configuration.</td>
         <td>Select data type that will be used for executing action.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Name</td>
         <td><span style="color: purple;">MODBUS Write Request: First register number</span></td>
         <td>string; default: <b>none</b></td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Name of the serial device instance. Used for management purposes only.</td>
         <td>Begins reading from the register specified in this field.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Device</td>
         <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
         <td>{{Template: Networking rutos manual serial ports| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}; default: <b>{{Template: Networking rutos manual default serial port| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}</b></td>  
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Specifies which serial port will be used for serial communication.</td>
         <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     </tr>{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=
     <tr>
     <tr>
    <td>Baud rate (RS485)</td>
        <td><span style="color: green;">Trigger output: Output</span></td>{{#switch:{{{series}}}
        <td>integer [300..230400]; default:<b>9600</b></td>
| RUTX|RUT2|RUT2M =<td>Output (4); default: <b>Output (4)</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
| TRB1={{#ifeq:{{{name}}}|TRB141|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4) {{!}} Relay (3,4,5) {{!}} Latching Relay (11,12,13); default: <b>Configurable Input/Output (3)</b></td>|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>}}|RUT30X|RUT301|RUT36X|RUT361|TRB5 =<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>
    </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
| TRB2|TRB2M =<td>Configurable Input/Output (2) {{!}} Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (2)</b></td>
| RUT9|RUT9M =<td>Output (4) {{!}} Isolated Output (3,4,8)  {{!}} Relay (5,10); default: <b>Output (4)</b></td>}}
        <td>Selects which output will be triggered.</td>
    </tr>
     <tr>
     <tr>
    <td>Baud rate (RS232)</td>
        <td><span style="color: green;">Trigger output: I/O Action</span></td>
         <td>integer [300..115200]; default:<b>9600</b></td>
         <td>Turn On {{!}} Turn Off {{!}} Invert; default: <b>Turn On</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>Selects the action performed on the output.</td>
     </tr>|}}{{#ifeq: {{{usb}}} | 1 |
     </tr>}}
     <tr>
     <tr>
    <td>Baud rate (USB)</td>
        <td><span style="color: red;">MQTT message: JSON format</span></td>
         <td>integer [300..4000000]; default:<b>9600</b></td>
         <td>string; default: <b>none</b> </td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>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, Mobile IP addresses, Signal strength, 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)
     </tr>|}}
        </td>
     </tr>
     <tr>
     <tr>
         <td>Data bits</td>
         <td><span style="color: red;">MQTT message: Hostname</span></td>
         <td>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|{{#switch:{{{series}}}|TRB2|TRB2M=|#default=5 {{!}} 6 {{!}}}} 7 {{!}} |}}8; default: <b>8</b></td>
         <td>host {{!}} ip; default: <b>none</b> </td>
         <td>Number of data bits for each character.</td>
         <td>Broker’s IP address or hostname.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Stop bits</td>
         <td><span style="color: red;">MQTT message: Port</span></td>
         <td>1{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} 2|}}; default: <b>1</b></td>
        <td>integer [0..65535]; default: <b>1883</b></td>
         <td>Stop 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.</td>
        <td>Broker's port number.</td>
    </tr>
    <tr>
         <td><span style="color: red;">MQTT message: Keepalive</span></td>
        <td>positive integer; default: <b>none</b></td>
         <td>The 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</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Parity</td>
         <td><span style="color: red;">MQTT message: Topic</span></td>
        <td>Even {{!}} Odd{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} Mark {{!}} Space|}} {{!}} None; default: <b>None</b></td>
         <td>string; default: <b>none</b></td>
         <td>In 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.
        <td>The name of the topic that the broker will subscribe to.</td>
            <ul>
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<li><b>Space</b> (<b>s</b>) - the parity bit will always be a binary 0.</li>
                <li><b>Mark</b> (<b>M</b>) - the parity bit will always be a binary 1.</li>|}}
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Flow control</td>
         <td><span style="color: red;">MQTT message: Client ID</span></td>
         <td>None {{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} RTS/CTS {{!}} Xon/Xoff|}}; default: <b>None</b></td>
         <td>positive integer; default: <b>none</b></td>
         <td>In 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.
         <td>Client ID to send with the data. If empty, a random client ID will be generated </td>
{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<ul>
    </tr>
                <li><b>RTS/CTS</b> - 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.</li>
    <tr>
                <li><b>Xon/Xoff</b> - 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.</li>
        <td><span style="color: red;">MQTT message: QoS</span></td>
            </ul>|}}
        <td>At most once (0) {{!}} At least once (1) {{!}} Exactly once (2); default: <b>At most once (0)</b></td>
         </td>
        <td>A period of time (in seconds) which has to pass after a trigger event before this Action is executed.</td>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
    </tr>
    <tr>
        <td><span style="color: red;">MQTT message: Use root CA</span></td>
        <td>off {{!}} on; default: <b>off</b></td>
         <td>Use root CA for verifying the servers certificates </td>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">RS485:</span> Full Duplex</td>
         <td><span style="color: red;">MQTT message: Use TLS</span></td>
        <td>off {{!}} on; default: <b>off</b></td>
        <td>Turns the use of TLS/SSL for this MQTT connection on or off.</td>
    </tr><tr>
        <td><span style="color: red;">MQTT message: Use credentials</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Enables RS485 full duplex.</td>
         <td>Turns the use of username and password for this MQTT connection on or off.</td>
     </tr>|}}
     </tr>
</table>
</table>
{{#ifeq: {{{serial}}} | 1 |
==Modbus Serial Client==


===Modbus Server Device Configuration===
The <b>Modbus Serial Client</b> 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.
----
This section is used to create server instances that the Client (this {{{name}}} device) will be querying with requests.


[[File:Networking_rutos_manual_modbus_modbus_serial_client_modbus_server_device_configuration.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_serial_client_v3.png|border|class=tlt-border]]
<!--<u><b>Note:</b> Modbus Serial Client is additional software that can be installed from the <b>System → [[{{{name}}} Package Manager|Package Manager]]</b> page.</u>-->


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.
Notice the Global section config. It is used to outright turn the service off or on if any active configurations are present.


[[File:Networking_rutos_manual_modbus_modbus_serial_client_modbus_server_device_configuration_add_button.png|border|class=tlt-border]]
[[File:Networking rutos manual modbus modbus serial client global button v1.png|border|class=tlt-border]]


After clicking 'Add' you will be redirected to the newly added server's configuration page.
Clicking the Cog icon opens a modal window. The global configuration slider can be set and it's state saved.


====Server Device Configuration====
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_modbus_tcp_server_devices_global_config_modal_v2.png|border|class=tlt-border]]
----
The <b>Server Device Configuration</b> section is used to configure the parameters of Modbus RTU servers that the Client (this {{{name}}} 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:
 
[[File:Networking_rutos_manual_modbus_modbus_serial_client_server_device_configuration.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
Line 828: Line 835:
         <td>Enabled</td>
         <td>Enabled</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Turns communication with the server device on or off.</td>
         <td>Turn on/off Modbus client service.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Name</td>
         <td>Database location</td>
         <td>string; default: <b>none</b></td>
         <td>RAM {{#ifeq: {{{usb}}} | 1 | {{!}} USB|}}; default: <b>RAM</b></td>
         <td>Server device's name, used for easier management purposes.</td>
         <td>Select Modbus database location.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Serial device</td>
         <td>Database size</td>
         <td><i>serial device instance</i>; default: <b>none</b></td>
         <td>size in KiB</td>
         <td>Specifies which serial device will be used on this server.</td>
         <td>Current database size.</td>
     </tr>
     </tr>
</table>
===General Status===
----
This section displays Modbus Client general status information.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_status.png|border|class=tlt-border]]
===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.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_device_configuration_v1.png|border|class=tlt-border]]
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.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_device_configuration_add_button.png|border|class=tlt-border]]
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.
[[File:Networking_rutos_manual_modbus_modbus_serial_client_device_configuration_rs_device_modbus_client_configuration_v3.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <td>Server ID</td>
         <th>Field</th>
         <td>integer [0..255]; default: <b>1</b></td>
         <th>Value</th>
         <td>Server ID. Each server in a network is assigned a unique identifier ranging from 1 to 255. When the client requests data from a server, the first byte it sends is the Server ID. When set to 0, the server will respond to requests addressed to any ID.</td>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Number of timeouts</td>
         <td>Enable</td>
         <td>integer [0..10]; default: <b>0</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Skip pending request and reset connection after number of request failures.</td>
         <td>Enables this Modbus Serial Device instance configuration.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Frequency</td>
         <td>Name</td>
         <td>Period {{!}} <span style="color:blue">Schedule</span>; default: <b>Period</b></td>
         <td>string; default: <b>none</b></td>
         <td></td>
         <td>Name of the serial device instance. Used for management purposes only.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Period</td>
         <td>Device</td>
         <td>integer [1..99999]; default: <b>none</b></td>
         <td>{{Template: Networking rutos manual serial ports| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}; default: <b>{{Template: Networking rutos manual default serial port| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}</b></td>  
         <td>Interval at which requests are sent to the server device.</td>
         <td>Specifies which serial port will be used for serial communication.</td>
     </tr>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     <tr>
     <tr>
        <td>Timeout</td>
    <td>Baud rate (RS485)</td>
         <td>integer [1..60]; default: <b>1</b></td>
         <td>integer [300..230400]; default:<b>9600</b></td>
         <td>Maximum response wait time.</td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
     </tr>
     </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
     <tr>
     <tr>
         <td><span style="color:blue">Schedule request</span></td>
    <td>Baud rate (RS232)</td>
         <td>time format string 'hh:mm:ss'; default: <b>none</b></td>
         <td>integer [300..115200]; default:<b>9600</b></td>
         <td>Schedule request time (format: Hours:Minutes:Seconds).</td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}{{#ifeq: {{{usb}}} | 1 |
    <tr>
    <td>Baud rate (USB)</td>
        <td>integer [300..4000000]; default:<b>9600</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}
    <tr>
        <td>Data bits</td>
        <td>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|{{#switch:{{{series}}}|TRB2|TRB2M=|#default=5 {{!}} 6 {{!}}}} 7 {{!}} |}}8; default: <b>8</b></td>
        <td>Number of data bits for each character.</td>
     </tr>
     </tr>
</table>
    <tr>
 
        <td>Stop bits</td>
=====Requests Configuration=====
        <td>1{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} 2|}}; default: <b>1</b></td>
----
        <td>Stop 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.</td>
A Modbus <b>request</b> 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.
 
<span style="color:red"> <b>Note: </b></span> Modbus Serial Client uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>First Register</i> 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:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_add_new_instance.png|border|class=tlt-border]]
 
The new Request Configuration should become visible in the list:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_v3.png|border|class=tlt-border]]
 
<table class="nd-mantable">
    <tr>
        <th>Field</th>
        <th>Value</th>
        <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Name</td>
         <td>Parity</td>
         <td>string; default: <b>Unnamed</b></td>
         <td>Even {{!}} Odd{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} Mark {{!}} Space|}} {{!}} None; default: <b>None</b></td>
         <td>Name of this Request Configuration. Used for easier management purposes.</td>
         <td>In 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.
            <ul>
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<li><b>Space</b> (<b>s</b>) - the parity bit will always be a binary 0.</li>
                <li><b>Mark</b> (<b>M</b>) - the parity bit will always be a binary 1.</li>|}}
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Data type</td>
         <td>Flow control</td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>None {{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} RTS/CTS {{!}} Xon/Xoff|}}; default: <b>None</b></td>
         <td>Defines how read data will be stored.</td>
         <td>In 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.
    </tr>
{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<ul>
    <tr>
                <li><b>RTS/CTS</b> - 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.</li>
        <td>Function</td>
                <li><b>Xon/Xoff</b> - 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.</li>
        <td>Read 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: <b>Read holding registers (3)</b></td>
            </ul>|}}
        <td>Specifies the type of register being addressed by a Modbus request.  
         </td>
         </td>
     </tr>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     <tr>
     <tr>
         <td>First Register</td>
         <td><span style="color:blue">RS485:</span> Full Duplex</td>
         <td>integer [0..65535]; default: <b>1</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>First Modbus register from which data will be read.</td>
         <td>Enables RS485 full duplex.</td>
     </tr>
     </tr>|}}
     <tr>
     <tr>
         <td>Register Count / Values</td>
         <td>Inter-device delay</td>
         <td>integer [1..2000]; default: <b>1</b></td>
         <td>integer [0..1000]; default: <b>none</b></td>
         <td>Number of Modbus registers that will be read during the request.</td>
         <td>Delay in milliseconds between requests when the device between those requests differs.</td>
     </tr>
     </tr>
    <tr>
</table>
        <td>Brackets</td>
 
        <td>off {{!}} on; default: <b>off</b></td>
===Modbus devices===
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
----
This section is used to create server instances that the Client (this {{{name}}} device) will be querying with requests.
 
[[File:Networking_rutos_manual_modbus_modbus_serial_client_modbus_server_device_configuration_v1.png|border|class=tlt-border]]
 
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.
 
[[File:Networking_rutos_manual_modbus_modbus_serial_client_modbus_server_device_configuration_add_button_v1.png|border|class=tlt-border]]
 
After clicking 'Add' you will be redirected to the newly added server's configuration page.
 
====Modbus device configuration====
----
The <b>Modbus device configuration</b> section is used to configure the parameters of Modbus RTU servers that the Client (this {{{name}}} 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:
 
[[File:Networking_rutos_manual_modbus_modbus_serial_client_server_device_configuration_v1.png|border|class=tlt-border]]
 
<table class="nd-mantable">
    <tr>
        <th>Field</th>
        <th>Value</th>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Store on change only</td>
         <td>Enabled</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Store the response only if the value has changed.</td>
         <td>Turns communication with the server device on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>off/on slider</td>
         <td>Name</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>string; default: <b>none</b></td>
         <td>Turns the request on or off.</td>
         <td>Server device's name, used for easier management purposes.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Delete [ X ]</td>
         <td>Serial device</td>
         <td>- (interactive button)</td>
         <td><i>serial device instance</i>; default: <b>none</b></td>
         <td>Deletes the request.</td>
         <td>Specifies which serial device will be used on this server.</td>
     </tr>
     </tr>
</table>
<b>Additional note:</b> 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:
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_on_off_slider.png|border|class=tlt-border]]
----
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. <b>Note:</b> to use test buttons, you need to enable [[#Modbus_Serial_Client|Client section]]. A successful response to a test may look something like this:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
=====Modbus Client Alarms=====
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Client (this {{{name}}} 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.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_alarms_configuration_add_button.png|border|class=tlt-border]]
After this you should be redirected to that Alarm's configuration page which should look similar to this:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_v1.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <td>Server ID</td>
         <th>Value</th>
         <td>integer [0..255]; default: <b>1</b></td>
         <th>Description</th>
         <td>Modbus 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.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enabled</td>
         <td>Number of timeouts</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>integer [0..10]; default: <b>0</b></td>
         <td>Turns the alarm on or off.</td>
         <td>Skip pending request and reset connection after number of request failures.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function code</td>
         <td>Frequency</td>
         <td>Read Coil Status (1) {{!}} Read Input Status (2) {{!}} Read Holding Registers (3) {{!}} Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>Period {{!}} <span style="color:blue">Schedule</span>; default: <b>Period</b></td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#Server_Device_Configuration|Server Device Configuration]].</td>
         <td></td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Compared condition data type</td>
         <td>Period</td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>integer [1..99999]; default: <b>60</b></td>
         <td>Select data type that will be used for checking conditions.</td>
         <td>Interval at which requests are sent to the server device.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>First register number</td>
         <td>Timeout</td>
         <td>integer [1..65536]; default: <b>none</b></td>
         <td>integer [1..60]; default: <b>1</b></td>
         <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
         <td>Maximum response wait time.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Values</td>
         <td><span style="color:blue">Schedule request</span></td>
         <td>various; default: <b>none</b></td>
         <td>time format string 'hh:mm:ss'; default: <b>none</b></td>
         <td>The value against which the read data will be compared.</td>
         <td>Schedule request time (format: Hours:Minutes:Seconds).</td>
     </tr>
     </tr>
</table>
=====Requests Configuration=====
----
A Modbus <b>request</b> 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.
<span style="color:red"> <b>Note: </b></span> Modbus Serial Client uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>First Register</i> 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:
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_add_new_instance_v1.png|border|class=tlt-border]]
The new Request Configuration should become visible in the list:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_v3.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <td>Condition</td>
        <th>Field</th>
         <td>More than {{!}} Less than {{!}} Equal to {{!}} Not Equal to {{!}} Less or equal {{!}} More or equal; default: <b>More than</b></td>
        <th>Value</th>
         <td>When 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.</td>
        <th>Description</th>
    </tr>
    <tr>
         <td>Name</td>
         <td>string; default: <b>Unnamed</b></td>
         <td>Name of this Request Configuration. Used for easier management purposes.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Action frequency</td>
         <td>Data type</td>
         <td>Every trigger {{!}} First trigger; default: <b>Every trigger</b></td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>Describes how frequently the specified action will be taken.</td>
         <td>Defines how read data will be stored.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Redundancy protection</td>
         <td>Function</td>
         <td>off {{!}} <span style="color:blue">on</span>; default: <b>off</b></td>
         <td>Read 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: <b>Read holding registers (3)</b></td>
         <td>Protection against executing a configured action too often.</td>
         <td>Specifies the type of register being addressed by a Modbus request.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">Redundancy protection period</span></td>
         <td>First Register</td>
         <td>integer [1..86400]; default: <b>none</b></td>
         <td>integer [0..65535]; default: <b>1</b></td>
         <td>Duration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.</td>
         <td>First Modbus register from which data will be read.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Action</td>
         <td>Register Count / Values</td>
         <td>Ubus event {{!}} <span style="color: brown;">Email</span> {{!}} {{#ifeq:{{{mobile}}}|1|<span style="color: #0054a6;">SMS</span> {{!}}|}} <span style="color: purple;">MODBUS Write Request</span> {{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default= {{!}} <span style="color: green;">Trigger output</span>}} {{!}} <span style="color: red;">MQTT message</span>; default: <b>MODBUS Write Request</b></td>
         <td>integer [1..2000]; default: <b>1</b></td>
         <td>Action that will be taken if the condition is met. Possible actions:
         <td>Number of Registers/Coils/Inputs or actual values to be written (Multiple values must be separated by space character).</td>
            <ul>{{#ifeq: {{{mobile}}} | 1 |
     </tr>
                <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>|}}
                <li><b>Email</b> - sends Email to a specified recipient(s).</li>
                <li><b>Ubus event</b> - sends Email to a specified recipient(s).</li>
                <li><b>MQTT message</b> - sends MQTT message to a specified broker.</li>
                <li><b>Ubus event</b> - sends ubus event.</li>
                <li><b>Modbus Request</b> - sends a Modbus Write request to a specified server.</li>
{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=<li><b>Trigger output</b> - changes state of selected I/O output pin.</li>}}
            </ul>
        </td>
     </tr>{{#ifeq: {{{mobile}}} | 1 |
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
         <td>No brackets</td>
         <td>string; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>SMS message text.</td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Recipients</span></td>
         <td>Store on change only</td>
         <td>Single {{!}} Group; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>You can choose to add a single number or use a phone group list.</td>
         <td>Store the response only if the value has changed.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Phone group (Group recipient)</span></td>
         <td>Broadcast</td>
         <td>phone group; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Recipient groups, including their associated phone numbers, can be configured [[{{{name}}}_Administration#Recipients | here]].</td>
         <td>Enable to broadcast the request to all devices (only for write requests).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Phone number (Single recipient)</span></td>
         <td>Enabled</td>
         <td>phone number; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
        <td>Recipient's phone number.</td>
         <td>Turns the request on or off.</td>
    </tr>|}}
    <tr>
        <td><span style="color: brown;">Email: Subject</span></td>
        <td>string; default: <b>none</b></td>
         <td>Subject of an email. Allowed characters (a-zA-Z0-9!@#$%&*+-/=?^_`{}~. ).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: brown;">Email: Message text</span></td>
         <td>Actions</td>
         <td>string; default: <b>none</b></td>
         <td>- (interactive button)</td>
        <td>Message that will be sent if condition passes.</td>
         <td>Deletes the request.</td>
    </tr>
    <tr>
        <td><span style="color: brown;">Email: Sender's email account</span></td>
        <td>string; default: <b>none</b></td>
        <td>Sender's email configuration (configure it [[{{{name}}}_Administration#Recipients | here]]).</td>
    </tr>
    <tr>
        <td><span style="color: brown;">Email: Recipient's email address</span></td>
        <td>email address; default: <b>none</b></td>
         <td>For whom you want to send an email to. Allowed characters (a-zA-Z0-9._%+@-).</td>
     </tr>
     </tr>
</table>
<b>Additional note:</b> 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:
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_requests_configuration_on_off_slider.png|border|class=tlt-border]]
----
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. <b>Note:</b> to use test buttons, you need to enable [[#Modbus_Serial_Client|Client section]]. A successful response to a test may look something like this:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
=====Modbus Client Alarms=====
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Client (this {{{name}}} 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.
[[File:Networking_rutos_manual_modbus_modbus_tcp_client_alarms_configuration_add_button.png|border|class=tlt-border]]
After this you should be redirected to that Alarm's configuration page which should look similar to this:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_v1.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
         <th>Field</th>
         <td>integer [1..30]; default: <b>5</b></td>
         <th>Value</th>
         <td>Maximum time to wait for a response.</td>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: ID</span></td>
         <td>Enabled</td>
         <td>integer [1..255]; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Modbus server ID.</td>
         <td>Turns the alarm on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>Function code</td>
         <td>Read Single Coil (5) {{!}} Set Single Register (6) {{!}} Set Multiple Coils (15) {{!}} Set Multiple Registers (16); default: <b>Set Single Coil (5)</b></td>
         <td>Read Coil Status (1) {{!}} Read Input Status (2) {{!}} Read Holding Registers (3) {{!}} Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#Server_Device_Configuration|Server Device Configuration]].</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Executed action data type</span></td>
         <td>Compared condition data type</td>
         <td>8bit 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: <b>Bool</b></td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>Select data type that will be used for executing action.</td>
         <td>Select data type that will be used for checking conditions.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: First register number</span></td>
         <td>First register number</td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>integer [1..65536]; default: <b>none</b></td>
         <td>Begins reading from the register specified in this field.</td>
         <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
         <td>Values</td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>various; default: <b>none</b></td>
         <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
         <td>The value against which the read data will be compared.</td>
     </tr>{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=
     </tr>
     <tr>
     <tr>
         <td><span style="color: green;">Trigger output: Output</span></td>{{#switch:{{{series}}}
         <td>Condition</td>
| RUTX|RUT2|RUT2M =<td>Output (4); default: <b>Output (4)</b></td>
        <td>More than {{!}} Less than {{!}} Equal to {{!}} Not Equal to {{!}} Less or equal {{!}} More or equal; default: <b>More than</b></td>
| TRB1={{#ifeq:{{{name}}}|TRB141|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4) {{!}} Relay (3,4,5) {{!}} Latching Relay (11,12,13); default: <b>Configurable Input/Output (3)</b></td>|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>}}|RUT30X|RUT301|RUT36X|RUT361|TRB5 =<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>
         <td>When 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.</td>
| TRB2|TRB2M =<td>Configurable Input/Output (2) {{!}} Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (2)</b></td>
| RUT9|RUT9M =<td>Output (4) {{!}} Isolated Output (3,4,8)  {{!}} Relay (5,10); default: <b>Output (4)</b></td>}}
         <td>Selects which output will be triggered.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: green;">Trigger output: I/O Action</span></td>
         <td>Action frequency</td>
         <td>Turn On {{!}} Turn Off {{!}} Invert; default: <b>Turn On</b></td>
         <td>Every trigger {{!}} First trigger; default: <b>Every trigger</b></td>
         <td>Selects the action performed on the output.</td>
         <td>Describes how frequently the specified action will be taken.</td>
     </tr>}}
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: JSON format</span></td>
         <td>Redundancy protection</td>
        <td>string; default: <b>none</b> </td>
        <td>off {{!}} <span style="color:blue">on</span>; default: <b>off</b></td>
         <td>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, Mobile IP addresses, Signal strength, 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)
         <td>Protection against executing a configured action too often.</td>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Hostname</span></td>
         <td><span style="color:blue">Redundancy protection period</span></td>
         <td>host {{!}} ip; default: <b>none</b> </td>
         <td>integer [1..86400]; default: <b>none</b></td>
         <td>Broker’s IP address or hostname.</td>
         <td>Duration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Port</span></td>
         <td>Action</td>
         <td>integer [0..65535]; default: <b>1883</b></td>
        <td>Ubus event {{!}} <span style="color: brown;">Email</span> {{!}} {{#ifeq:{{{mobile}}}|1|<span style="color: #0054a6;">SMS</span> {{!}}|}} <span style="color: purple;">MODBUS Write Request</span> {{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default= {{!}} <span style="color: green;">Trigger output</span>}} {{!}} <span style="color: red;">MQTT message</span>; default: <b>MODBUS Write Request</b></td>
        <td>Broker's port number.</td>
         <td>Action that will be taken if the condition is met. Possible actions:
     </tr>
            <ul>{{#ifeq: {{{mobile}}} | 1 |
                <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>|}}
                <li><b>Email</b> - sends Email to a specified recipient(s).</li>
                <li><b>Ubus event</b> - sends Email to a specified recipient(s).</li>
                <li><b>MQTT message</b> - sends MQTT message to a specified broker.</li>
                <li><b>Ubus event</b> - sends ubus event.</li>
                <li><b>Modbus Request</b> - sends a Modbus Write request to a specified server.</li>
{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=<li><b>Trigger output</b> - changes state of selected I/O output pin.</li>}}
            </ul>
        </td>
     </tr>{{#ifeq: {{{mobile}}} | 1 |
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Keepalive</span></td>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
         <td>positive integer; default: <b>none</b></td>
         <td>string; default: <b>none</b></td>
         <td>The 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</td>
         <td>SMS message text.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Topic</span></td>
         <td><span style="color: #0054a6;">SMS: Recipients</span></td>
         <td>string; default: <b>none</b></td>
         <td>Single {{!}} Group; default: <b>none</b></td>
         <td>The name of the topic that the broker will subscribe to.</td>
         <td>You can choose to add a single number or use a phone group list.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Client ID</span></td>
         <td><span style="color: #0054a6;">SMS: Phone group (Group recipient)</span></td>
         <td>positive integer; default: <b>none</b></td>
         <td>phone group; default: <b>none</b></td>
         <td>Client ID to send with the data. If empty, a random client ID will be generated </td>
         <td>Recipient groups, including their associated phone numbers, can be configured [[{{{name}}}_Administration#Recipients | here]].</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: QoS</span></td>
         <td><span style="color: #0054a6;">SMS: Phone number (Single recipient)</span></td>
         <td>At most once (0) {{!}} At least once (1) {{!}} Exactly once (2); default: <b>At most once (0)</b></td>
         <td>phone number; default: <b>none</b></td>
         <td>A period of time (in seconds) which has to pass after a trigger event before this Action is executed.</td>
         <td>Recipient's phone number.</td>
     </tr>
     </tr>|}}
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Use root CA</span></td>
         <td><span style="color: brown;">Email: Subject</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>string; default: <b>none</b></td>
         <td>Use root CA for verifying the servers certificates </td>
         <td>Subject of an email. Allowed characters (a-zA-Z0-9!@#$%&*+-/=?^_`{}~. ).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: red;">MQTT message: Use TLS</span></td>
         <td><span style="color: brown;">Email: Message text</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>string; default: <b>none</b></td>
         <td>Turns the use of TLS/SSL for this MQTT connection on or off.</td>
         <td>Message that will be sent if condition passes.</td>
    </tr><tr>
        <td><span style="color: red;">MQTT message: Use credentials</span></td>
        <td>off {{!}} on; default: <b>off</b></td>
        <td>Turns the use of username and password for this MQTT connection on or off.</td>
     </tr>
     </tr>
</table>
|}}
{{#ifeq: {{{console}}} | 1 |
===Console===
----
This section is used to configure the Modbus Serial Client's <b>Console</b> serial interface settings. Refer to the figure and table below for information on Console configuration.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_console_configuration.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <td><span style="color: brown;">Email: Sender's email account</span></td>
         <th>Value</th>
         <td>string; default: <b>none</b></td>
         <th>Description</th>
         <td>Sender's email configuration (configure it [[{{{name}}}_Administration#Recipients | here]]).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enabled</td>
         <td><span style="color: brown;">Email: Recipient's email address</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>email address; default: <b>none</b></td>
         <td>Turns Modbus Serial Client configuration via RS232 on or off. Both this and RS232 from Services → [[{{{name}}} RS232|RS232]] cannot be enabled at the same time.</td>
         <td>For whom you want to send an email to. Allowed characters (a-zA-Z0-9._%+@-).</td>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (RS485)</td>
        <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
         <td>integer [300..230400]; default:<b>9600</b></td>
         <td>integer [1..30]; default: <b>5</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>Maximum time to wait for a response.</td>
     </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (RS232)</td>
        <td><span style="color: purple;">MODBUS Write Request: ID</span></td>
         <td>integer [300..115200]; default:<b>9600</b></td>
         <td>integer [1..255]; default: <b>none</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>Modbus server ID.</td>
     </tr>|}}{{#ifeq: {{{usb}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (USB)</td>
        <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>integer [300..4000000]; default:<b>9600</b></td>
         <td>Read Single Coil (5) {{!}} Set Single Register (6) {{!}} Set Multiple Coils (15) {{!}} Set Multiple Registers (16); default: <b>Set Single Coil (5)</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
     </tr>|}}
     </tr>
     <tr>
     <tr>
         <td>Data bits</td>
         <td><span style="color: purple;">MODBUS Write Request: Executed action data type</span></td>
         <td>5 {{!}} 6 {{!}} 7 {{!}} 8; default: <b>8</b></td>
         <td>8bit 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: <b>Bool</b></td>
         <td>Number of data bits for each character.</td>
         <td>Select data type that will be used for executing action.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Parity</td>
         <td><span style="color: purple;">MODBUS Write Request: First register number</span></td>
        <td>None {{!}} Even {{!}} Odd; default: <b>None</b></td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>In 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.
        <td>Begins reading from the register specified in this field.</td>
            <ul>
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Stop bits</td>
         <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
         <td>1 {{!}} 2; default: <b>1</b></td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Stop 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.</td>
         <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
     </tr>
     </tr>{{#switch:{{{series}}}|TCR1|OTD140|OTD160|OTD500|RUT14X=|#default=
     <tr>
     <tr>
         <td>Flow control</td>
         <td><span style="color: green;">Trigger output: Output</span></td>{{#switch:{{{series}}}
        <td>None {{!}} RTS/CTS {{!}} Xon/Xoff; default: <b>None</b></td>
| RUTX|RUT2|RUT2M =<td>Output (4); default: <b>Output (4)</b></td>
         <td>In 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.
| TRB1={{#ifeq:{{{name}}}|TRB141|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4) {{!}} Relay (3,4,5) {{!}} Latching Relay (11,12,13); default: <b>Configurable Input/Output (3)</b></td>|<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>}}|RUT30X|RUT301|RUT36X|RUT361|TRB5 =<td>Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (3)</b></td>
            <ul>
| TRB2|TRB2M =<td>Configurable Input/Output (2) {{!}} Configurable Input/Output (3) {{!}} Configurable Input/Output (4); default: <b>Configurable Input/Output (2)</b></td>
                <li><b>RTS/CTS</b> - 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.</li>
| RUT9|RUT9M =<td>Output (4) {{!}} Isolated Output (3,4,8)  {{!}} Relay (5,10); default: <b>Output (4)</b></td>}}
                <li><b>Xon/Xoff</b> - 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.</li>
         <td>Selects which output will be triggered.</td>
            </ul>
    </tr>
    <tr>
        <td><span style="color: green;">Trigger output: I/O Action</span></td>
        <td>Turn On {{!}} Turn Off {{!}} Invert; default: <b>Turn On</b></td>
        <td>Selects the action performed on the output.</td>
    </tr>}}
    <tr>
        <td><span style="color: red;">MQTT message: JSON format</span></td>
        <td>string; default: <b>none</b> </td>
        <td>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, Mobile IP addresses, Signal strength, 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)
         </td>
         </td>
     </tr>
     </tr>
</table>
====Console Server Devices List====
----
The <b>Console Server Devices List</b> section is used to configure the parameters of Modbus RTU servers that the Client (this {{{name}}} device) will be querying with requests.
The list is empty by default. In order to create a new server device configuration, click the 'Add' button. A new configuration window should pop up.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_console_slave_devices_list_add_button.png|border|class=tlt-border]]
=====Server Device Configuration=====
----
The <b>Server Device Configuration</b> section is used to configure the parameters of Modbus RTU servers that the Client (this {{{name}}} 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:
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs232_slave_device_configuration.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <td><span style="color: red;">MQTT message: Hostname</span></td>
         <th>Value</th>
        <td>host {{!}} ip; default: <b>none</b> </td>
         <th>Description</th>
        <td>Broker’s IP address or hostname.</td>
    </tr>
    <tr>
        <td><span style="color: red;">MQTT message: Port</span></td>
         <td>integer [0..65535]; default: <b>1883</b></td>
         <td>Broker's port number.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enabled</td>
         <td><span style="color: red;">MQTT message: Keepalive</span></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>positive integer; default: <b>none</b></td>
         <td>Turns communication with the server device on or off.</td>
         <td>The 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</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Name</td>
         <td><span style="color: red;">MQTT message: Topic</span></td>
         <td>string; default: <b>none</b></td>
         <td>string; default: <b>none</b></td>
         <td>Server device's name, used for easier management purposes.</td>
         <td>The name of the topic that the broker will subscribe to.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Server ID</td>
         <td><span style="color: red;">MQTT message: Client ID</span></td>
         <td>integer [0..255]; default: <b>none</b></td>
         <td>positive integer; default: <b>none</b></td>
         <td>Server ID. Each server in a network is assigned a unique identifier ranging from 1 to 255. When the client requests data from a server, the first byte it sends is the Server ID. When set to 0, the server will respond to requests addressed to any ID.</td>
         <td>Client ID to send with the data. If empty, a random client ID will be generated </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Period</td>
         <td><span style="color: red;">MQTT message: QoS</span></td>
         <td>integer [1..86400]; default: <b>60</b></td>
         <td>At most once (0) {{!}} At least once (1) {{!}} Exactly once (2); default: <b>At most once (0)</b></td>
         <td>Interval at which requests are sent to the server device.</td>
         <td>A period of time (in seconds) which has to pass after a trigger event before this Action is executed.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Timeout</td>
         <td><span style="color: red;">MQTT message: Use root CA</span></td>
         <td>integer [1..30]; default: <b>5</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Maximum response wait time.</td>
         <td>Use root CA for verifying the servers certificates </td>
     </tr>
     </tr>
</table>
    <tr>
=====Requests Configuration=====
        <td><span style="color: red;">MQTT message: Use TLS</span></td>
----
        <td>off {{!}} on; default: <b>off</b></td>
A Modbus <b>request</b> 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.
        <td>Turns the use of TLS/SSL for this MQTT connection on or off.</td>
    </tr><tr>
        <td><span style="color: red;">MQTT message: Use credentials</span></td>
        <td>off {{!}} on; default: <b>off</b></td>
        <td>Turns the use of username and password for this MQTT connection on or off.</td>
    </tr>
</table>
|}}
{{#ifeq: {{{console}}} | 1 |
===Console===
----
This section is used to configure the Modbus Serial Client's <b>Console</b> serial interface settings. Refer to the figure and table below for information on Console configuration.


<span style="color:red"> <b>Note: </b></span> Modbus Serial Client uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>First Register</i> field.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_console_configuration.png|border|class=tlt-border]]
 
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:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_add_new_instance.png|border|class=tlt-border]]
 
The new Request Configuration should become visible in the list:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_v3.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
Line 1,294: Line 1,331:
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Name</td>
         <td>Enabled</td>
         <td>string; default: <b>Unnamed</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Name of this Request Configuration. Used for easier management purposes.</td>
         <td>Turns Modbus Serial Client configuration via RS232 on or off. Both this and RS232 from Services → [[{{{name}}} RS232|RS232]] cannot be enabled at the same time.</td>
     </tr>
    </tr>{{#ifeq: {{{rs485}}} | 1 |
    <tr>
    <td>Baud rate (RS485)</td>
        <td>integer [300..230400]; default:<b>9600</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
    <tr>
    <td>Baud rate (RS232)</td>
        <td>integer [300..115200]; default:<b>9600</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
     </tr>|}}{{#ifeq: {{{usb}}} | 1 |
     <tr>
     <tr>
        <td>Data type</td>
    <td>Baud rate (USB)</td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>integer [300..4000000]; default:<b>9600</b></td>
         <td>Defines how read data will be stored.</td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
     </tr>
     </tr>|}}
     <tr>
     <tr>
         <td>Function</td>
         <td>Data bits</td>
         <td>Read 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: <b>Read holding registers (3)</b></td>
         <td>5 {{!}} 6 {{!}} 7 {{!}} 8; default: <b>8</b></td>
         <td>Specifies the type of register being addressed by a Modbus request.  
         <td>Number of data bits for each character.</td>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>First Register</td>
         <td>Parity</td>
         <td>integer [0..65535]; default: <b>1</b></td>
         <td>None {{!}} Even {{!}} Odd; default: <b>None</b></td>
         <td>First Modbus register from which data will be read.</td>
         <td>In 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.
            <ul>
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Register Count / Values</td>
         <td>Stop bits</td>
         <td>integer [1..2000]; default: <b>1</b></td>
         <td>1 {{!}} 2; default: <b>1</b></td>
         <td>Number of Modbus registers that will be read during the request.</td>
         <td>Stop 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.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Remove Brackets</td>
         <td>Flow control</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>None {{!}} RTS/CTS {{!}} Xon/Xoff; default: <b>None</b></td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
         <td>In 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.
            <ul>
                <li><b>RTS/CTS</b> - 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.</li>
                <li><b>Xon/Xoff</b> - 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.</li>
            </ul>
        </td>
     </tr>
     </tr>
</table>
====Console Server Devices List====
----
The <b>Console Server Devices List</b> section is used to configure the parameters of Modbus RTU servers that the Client (this {{{name}}} device) will be querying with requests.
The list is empty by default. In order to create a new server device configuration, click the 'Add' button. A new configuration window should pop up.
[[File:Networking_rutos_manual_modbus_modbus_serial_master_console_slave_devices_list_add_button.png|border|class=tlt-border]]
=====Server Device Configuration=====
----
The <b>Server Device Configuration</b> section is used to configure the parameters of Modbus RTU servers that the Client (this {{{name}}} 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:
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs232_slave_device_configuration.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <td>Store on change only</td>
         <th>Field</th>
         <td>off {{!}} on; default: <b>off</b></td>
         <th>Value</th>
         <td>Store the response only if the value has changed.</td>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>off/on slider</td>
         <td>Enabled</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Turns the request on or off.</td>
         <td>Turns communication with the server device on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Delete [ X ]</td>
         <td>Name</td>
         <td>- (interactive button)</td>
        <td>string; default: <b>none</b></td>
         <td>Deletes the request.</td>
        <td>Server device's name, used for easier management purposes.</td>
    </tr>
    <tr>
        <td>Server ID</td>
        <td>integer [0..255]; default: <b>none</b></td>
        <td>Server ID. Each server in a network is assigned a unique identifier ranging from 1 to 255. When the client requests data from a server, the first byte it sends is the Server ID. When set to 0, the server will respond to requests addressed to any ID.</td>
    </tr>
    <tr>
         <td>Period</td>
         <td>integer [1..86400]; default: <b>60</b></td>
        <td>Interval at which requests are sent to the server device.</td>
    </tr>
    <tr>
        <td>Timeout</td>
        <td>integer [1..30]; default: <b>5</b></td>
        <td>Maximum response wait time.</td>
     </tr>
     </tr>
</table>
</table>
=====Requests Configuration=====
----
A Modbus <b>request</b> 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.


<b>Additional note:</b> 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:
<span style="color:red"> <b>Note: </b></span> Modbus Serial Client uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>First Register</i> field.


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
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:
----
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. A successful response to a test may look something like this:


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_add_new_instance.png|border|class=tlt-border]]


=====Modbus Client Alarms=====
The new Request Configuration should become visible in the list:
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Client (this {{{name}}} 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.
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_v3.png|border|class=tlt-border]]
 
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_add_button.png|border|class=tlt-border]]
 
After this you should be redirected to that Alarm's configuration page which should look similar to this:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_v1.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
Line 1,368: Line 1,450:
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enabled</td>
         <td>Name</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>string; default: <b>Unnamed</b></td>
         <td>Turns the alarm on or off.</td>
         <td>Name of this Request Configuration. Used for easier management purposes.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function code</td>
         <td>Data type</td>
        <td>Read Coil Status (1) {{!}} Read Input Status (2) {{!}} Read Holding Registers (3) {{!}} Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
        <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#Server_Device_Configuration|Server Device Configuration]].</td>
    </tr>
    <tr>
        <td>Compared condition data type</td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>Select data type that will be used for checking conditions.</td>
         <td>Defines how read data will be stored.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>First register number</td>
         <td>Function</td>
         <td>integer [1..65536]; default: <b>none</b></td>
         <td>Read 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: <b>Read holding registers (3)</b></td>
         <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
         <td>Specifies the type of register being addressed by a Modbus request.  
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Values</td>
         <td>First Register</td>
         <td>various; default: <b>none</b></td>
         <td>integer [0..65535]; default: <b>1</b></td>
         <td>The value against which the read data will be compared.</td>
         <td>First Modbus register from which data will be read.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Condition</td>
         <td>Register Count / Values</td>
         <td>More than {{!}} Less than {{!}} Equal to {{!}} Not Equal to {{!}} Less or equal {{!}} More or equal; default: <b>More than</b></td>
         <td>integer [1..2000]; default: <b>1</b></td>
         <td>When 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.</td>
         <td>Number of Registers/Coils/Inputs or actual values to be written (Multiple values must be separated by space character).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Action frequency</td>
         <td>Remove Brackets</td>
         <td>Every trigger {{!}} First trigger; default: <b>Every trigger</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Describes how frequently the specified action will be taken.</td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Redundancy protection</td>
         <td>Store on change only</td>
         <td>off {{!}} <span style="color:blue">on</span>; default: <b>off</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Protection against executing a configured action too often.</td>
         <td>Store the response only if the value has changed.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">Redundancy protection period</span></td>
         <td>off/on slider</td>
         <td>integer [1..86400]; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Duration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.</td>
         <td>Turns the request on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Action</td>
         <td>Actions</td>
         <td>{{#ifeq:{{{mobile}}}|1|SMS {{!}}|}} MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>- (interactive button)</td>
        <td>Action that will be taken if the condition is met. Possible actions:
         <td>Deletes the request.</td>
            <ul>{{#ifeq: {{{mobile}}} | 1 |
                <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>|}}
                <li><b>Modbus Request</b> - sends a Modbus Write request to a specified server.</li>
            </ul>
        </td>
    </tr>{{#ifeq: {{{mobile}}} | 1 |
    <tr>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
        <td>string; default: <b>none</b></td>
        <td>SMS message text.</td>
     </tr>
     </tr>
    <tr>
</table>
        <td><span style="color: #0054a6;">SMS: Recipients</span></td>
 
        <td>Single {{!}} Group; default: <b>none</b></td>
<b>Additional note:</b> 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:
         <td>You can choose to add a single number or use a phone group list.</td>
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
----
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. A successful response to a test may look something like this:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
 
=====Modbus Client Alarms=====
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Client (this {{{name}}} 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.
 
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_add_button.png|border|class=tlt-border]]
 
After this you should be redirected to that Alarm's configuration page which should look similar to this:
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_v1.png|border|class=tlt-border]]
 
<table class="nd-mantable">
    <tr>
        <th>Field</th>
        <th>Value</th>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Phone group (Group recipient)</span></td>
         <td>Enabled</td>
         <td>phone group; default: <b>none</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Recipient groups, including their associated phone numbers, can be configured [[{{{name}}}_Administration#Recipients | here]].</td>
         <td>Turns the alarm on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Phone number (Single recipient)</span></td>
         <td>Function code</td>
         <td>phone number; default: <b>none</b></td>
         <td>Read Coil Status (1) {{!}} Read Input Status (2) {{!}} Read Holding Registers (3) {{!}} Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>Recipient's phone number.</td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Client (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#Server_Device_Configuration|Server Device Configuration]].</td>
    </tr>|}}
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
        <td>integer [1..30]; default: <b>5</b></td>
        <td>Maximum time to wait for a response.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: ID</span></td>
         <td>Compared condition data type</td>
         <td>integer [1..255]; default: <b>none</b></td>
         <td>8bit 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: <b>16bit INT, high byte first</b></td>
         <td>Modbus server ID.</td>
         <td>Select data type that will be used for checking conditions.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>First register number</td>
         <td>Read Single Coil (5) {{!}} Set Single Register (6) {{!}} Set Multiple Coils (15) {{!}} Set Multiple Registers (16); default: <b>Set Single Coil (5)</b></td>
         <td>integer [1..65536]; default: <b>none</b></td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
         <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Executed action data type</span></td>
         <td>Values</td>
         <td>8bit 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: <b>Bool</b></td>
        <td>various; default: <b>none</b></td>
         <td>Select data type that will be used for executing action.</td>
        <td>The value against which the read data will be compared.</td>
    </tr>
    <tr>
        <td>Condition</td>
         <td>More than {{!}} Less than {{!}} Equal to {{!}} Not Equal to {{!}} Less or equal {{!}} More or equal; default: <b>More than</b></td>
         <td>When 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.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: First register number</span></td>
         <td>Action frequency</td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Every trigger {{!}} First trigger; default: <b>Every trigger</b></td>
         <td>Begins reading from the register specified in this field.</td>
         <td>Describes how frequently the specified action will be taken.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
         <td>Redundancy protection</td>
        <td>integer [0..65535]; default: <b>none</b></td>
        <td>off {{!}} <span style="color:blue">on</span>; default: <b>off</b></td>
         <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
         <td>Protection against executing a configured action too often.</td>
     </tr>
     </tr>
</table>
    <tr>
|}}
        <td><span style="color:blue">Redundancy protection period</span></td>
 
        <td>integer [1..86400]; default: <b>none</b></td>
==MQTT Modbus Gateway==
         <td>Duration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.</td>
 
The <b>MQTT Modbus Gateway</b> function is used to transfer Modbus data (send requests, receive responses) over MQTT. When it is enabled, the device (this {{{name}}}) 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.
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway_scheme.png]]
 
Below is an example of the MQTT Gateway page. Refer to the table for information on MQTT Gateway configuration fields and status.
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway_status.png|border|class=tlt-border]]
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway_v2.png|border|class=tlt-border]]
 
<table class="nd-mantable">
    <tr>
        <th>Field</th>
        <th>Value</th>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enable</td>
         <td>Action</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>{{#ifeq:{{{mobile}}}|1|SMS {{!}}|}} MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>Turns MQTT gateway on or off.</td>
         <td>Action that will be taken if the condition is met. Possible actions:
     </tr>
            <ul>{{#ifeq: {{{mobile}}} | 1 |
                <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>|}}
                <li><b>Modbus Request</b> - sends a Modbus Write request to a specified server.</li>
            </ul>
        </td>
     </tr>{{#ifeq: {{{mobile}}} | 1 |
     <tr>
     <tr>
         <td>Host</td>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
         <td>ip {{!}} host; default: <b>127.0.0.1</b></td>
         <td>string; default: <b>none</b></td>
         <td>IP address or hostname of an MQTT broker.</td>
         <td>SMS message text.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Port</td>
         <td><span style="color: #0054a6;">SMS: Recipients</span></td>
         <td>integer [0..65535]; default: <b>1883</b></td>
         <td>Single {{!}} Group; default: <b>none</b></td>
         <td>Port number of the MQTT broker.</td>
         <td>You can choose to add a single number or use a phone group list.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Message type</td>
         <td><span style="color: #0054a6;">SMS: Phone group (Group recipient)</span></td>
         <td>ASCII {{!}} JSON; default: <b>ASCII</b></td>
         <td>phone group; default: <b>none</b></td>
         <td>Format in which requests and responses will be sent to MQTT broker.</td>
         <td>Recipient groups, including their associated phone numbers, can be configured [[{{{name}}}_Administration#Recipients | here]].</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Request topic</td>
         <td><span style="color: #0054a6;">SMS: Phone number (Single recipient)</span></td>
         <td>alphanumeric string; default: <b>request/$$SERIAL</b></td>
         <td>phone number; default: <b>none</b></td>
         <td>Topic name.
         <td>Recipient's phone number.</td>
          <ul>
    </tr>|}}
              <li><b>Constants:</b></li>
    <tr>
              <li><b>Serial number:</b> $$SERIAL</li>
        <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
              <li><b>Mac address:</b> $$MAC</li>
        <td>integer [1..30]; default: <b>5</b></td>
              <li><b>Device name:</b> $$NAME</li>
        <td>Maximum time to wait for a response.</td>
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Response topic</td>
         <td><span style="color: purple;">MODBUS Write Request: ID</span></td>
        <td>alphanumeric string; default: <b>response/$$SERIAL</b></td>
         <td>integer [1..255]; default: <b>none</b></td>
         <td>Topic name.
        <td>Modbus server ID.</td>
          <ul>
              <li><b>Constants:</b></li>
              <li><b>Serial number:</b> $$SERIAL</li>
              <li><b>Mac address:</b> $$MAC</li>
              <li><b>Device name:</b> $$NAME</li>
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>QoS</td>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>At most once (0) {{!}} At least once (1) {{!}} Exactly once (2); default: <b>Exactly once (2)</b></td>
         <td>Read Single Coil (5) {{!}} Set Single Register (6) {{!}} Set Multiple Coils (15) {{!}} Set Multiple Registers (16); default: <b>Set Single Coil (5)</b></td>
         <td>Specifies quality of service.</td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Username</td>
         <td><span style="color: purple;">MODBUS Write Request: Executed action data type</span></td>
         <td>string; default: <b>none</b></td>
         <td>8bit 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: <b>Bool</b></td>
         <td>Username for authentication to the MQTT broker.</td>
         <td>Select data type that will be used for executing action.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Password</td>
         <td><span style="color: purple;">MODBUS Write Request: First register number</span></td>
         <td>string; default: <b>none</b></td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Password for authentication to the MQTT broker.</td>
         <td>Begins reading from the register specified in this field.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Client ID</td>
         <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
         <td>integer; default: <b>none</b></td>
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Specifies client ID for MQTT broker.</td>
         <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
     </tr>
     </tr>
    <tr>
</table>
        <td>Keepalive</td>
|}}
         <td>integer; default: <b>5</b></td>
 
         <td>Keepalive message to MQTT broker (seconds)</td>
==MQTT Modbus Gateway==
 
The <b>MQTT Modbus Gateway</b> function is used to transfer Modbus data (send requests, receive responses) over MQTT. When it is enabled, the device (this {{{name}}}) 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.
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway_scheme.png]]
 
Below is an example of the MQTT Gateway page. Refer to the table for information on MQTT Gateway configuration fields and status.
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway_status.png|border|class=tlt-border]]
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway_v2.png|border|class=tlt-border]]
 
<table class="nd-mantable">
    <tr>
         <th>Field</th>
        <th>Value</th>
         <th>Description</th>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Use TLS/SSL</td>
         <td>Enable</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Turns TLS support on or off</td>
         <td>Turns MQTT gateway on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>TLS type</td>
         <td>Host</td>
         <td><span style="color:blue">cert</span> {{!}} <span style="color:red">psk</span>; default: <b>cert</b></td>
         <td>ip {{!}} host; default: <b>127.0.0.1</b></td>
         <td>Selects the type of TLS encryption</td>
         <td>IP address or hostname of an MQTT broker.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>TLS insecure</td>
         <td>Port</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>integer [0..65535]; default: <b>1883</b></td>
         <td>Disables TLS security</td>
         <td>Port number of the MQTT broker.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">Certificate files from device</span></td>
         <td>Message type</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>ASCII {{!}} JSON; default: <b>ASCII</b></td>
         <td>Choose this option if you want to use certificate files generated on device.</td>
         <td>Format in which requests and responses will be sent to MQTT broker.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">CA file</span></td>
         <td>Request topic</td>
         <td>string; default: <b>none</b></td>
        <td>alphanumeric string; default: <b>request/$$SERIAL</b></td>
        <td>Upload/select certificate authority file.</td>
         <td>Topic name.
          <ul>
              <li><b>Constants:</b></li>
              <li><b>Serial number:</b> $$SERIAL</li>
              <li><b>Mac address:</b> $$MAC</li>
              <li><b>Device name:</b> $$NAME</li>
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">Certificates file</span></td>
         <td>Response topic</td>
         <td>string; default: <b>none</b></td>
        <td>alphanumeric string; default: <b>response/$$SERIAL</b></td>
        <td>Upload/select certificate file.</td>
         <td>Topic name.
          <ul>
              <li><b>Constants:</b></li>
              <li><b>Serial number:</b> $$SERIAL</li>
              <li><b>Mac address:</b> $$MAC</li>
              <li><b>Device name:</b> $$NAME</li>
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:blue">Key file</span></td>
         <td>QoS</td>
         <td>string; default: <b>none</b></td>
         <td>At most once (0) {{!}} At least once (1) {{!}} Exactly once (2); default: <b>Exactly once (2)</b></td>
         <td>Upload/select certificate key file.</td>
         <td>Specifies quality of service.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:red">PSK</span></td>
         <td>Username</td>
         <td>string; default: <b>none</b></td>
         <td>string; default: <b>none</b></td>
         <td>Specifies the pre-shared key.</td>
         <td>Username for authentication to the MQTT broker.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td><span style="color:red">Identity</span></td>
         <td>Password</td>
         <td>string; default: <b>none</b></td>
         <td>string; default: <b>none</b></td>
         <td>Specifies identity.</td>
        <td>Password for authentication to the MQTT broker.</td>
    </tr>
    <tr>
        <td>Client ID</td>
        <td>integer; default: <b>none</b></td>
         <td>Specifies client ID for MQTT broker.</td>
     </tr>
     </tr>
</table>
{{#ifeq:{{{serial}}}|1|
===Serial Gateway Configuration===
----
<b>Serial Gateway Configuration</b> 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.
[[File:Networking_rutos_manual_modbus_mqtt_gateway_serial_gateway_configuration_add_button_v1_rs232_{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|1|0}}.png|border|class=tlt-border]]
After this you should be redirected to instance's configuration page which should look similar to this:
[[File:Networking_rutos_manual_modbus_mqtt_gateway_serial_gateway_configuration_rs232_{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|1|0}}_v1.png|border|class=tlt-border]]
<table class="nd-mantable">
     <tr>
     <tr>
         <th>Field</th>
         <td>Keepalive</td>
         <th>Value</th>
         <td>integer; default: <b>5</b></td>
         <th>Description</th>
         <td>Keepalive message to MQTT broker (seconds)</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Enable</td>
         <td>Use TLS/SSL</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Enables this Serial Gateway instance configuration.</td>
         <td>Turns TLS support on or off</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Name</td>
         <td>TLS type</td>
         <td>string; default: <b>none</b></td>
         <td><span style="color:blue">Certificate based</span> {{!}} <span style="color:red">Pre-Shared-Key based</span>; default: <b>Certificate based</b></td>
         <td>Name of the gateway instance. Used for management purposes only.</td>
         <td>Selects the type of TLS encryption</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Device</td>
         <td><span style="color:blue">TLS insecure</span></td>
         <td>{{Template: Networking rutos manual serial ports| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}; default: <b>{{Template: Networking rutos manual default serial port| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}</b></td>  
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Specifies which serial port will be used for serial communication.</td>
         <td>Disables TLS security</td>
     </tr>{{#ifeq: {{{rs485}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (RS485)</td>
        <td><span style="color:blue">Certificate files from device</span></td>
         <td>integer [300..230400]; default:<b>9600</b></td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>Choose this option if you want to use certificate files generated on device.</td>
     </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (RS232)</td>
        <td><span style="color:blue">CA file</span></td>
         <td>integer [300..115200]; default:<b>9600</b></td>
         <td>string; default: <b>none</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>Upload/select certificate authority file.</td>
     </tr>|}}{{#ifeq: {{{usb}}} | 1 |
     </tr>
     <tr>
     <tr>
    <td>Baud rate (USB)</td>
        <td><span style="color:blue">Certificates file</span></td>
        <td>integer [300..4000000]; default:<b>9600</b></td>
         <td>string; default: <b>none</b></td>
         <td>Data rate for serial data transmission (in bits per second (bps)).</td>
         <td>Upload/select certificate file.</td>
    </tr>|}}
    <tr>
        <td>Data bits</td>
        <td>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|{{#switch:{{{series}}}|TRB2|TRB2M=|#default=5 {{!}} 6 {{!}}}} 7 {{!}} |}}8; default: <b>8</b></td>
         <td>Number of data bits for each character.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Stop bits</td>
         <td><span style="color:blue">Key file</span></td>
         <td>1{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} 2|}}; default: <b>1</b></td>
         <td>string; default: <b>none</b></td>
         <td>Stop 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.</td>
         <td>Upload/select key file.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Parity</td>
         <td><span style="color:red">PSK</span></td>
         <td>Even {{!}} Odd{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} Mark {{!}} Space|}} {{!}} None; default: <b>None</b></td>
         <td>string; default: <b>none</b></td>
         <td>In 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.
         <td>Specifies the pre-shared key.</td>
            <ul>
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<li><b>Space</b> (<b>s</b>) - the parity bit will always be a binary 0.</li>
                <li><b>Mark</b> (<b>M</b>) - the parity bit will always be a binary 1.</li>|}}
            </ul>
        </td>
     </tr>
     </tr>
     <tr>
     <tr>
        <td>Flow control</td>
         <td><span style="color:red">Identity</span></td>
        <td>None {{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} RTS/CTS {{!}} Xon/Xoff|}}; default: <b>None</b></td>
         <td>string; default: <b>none</b></td>
        <td>In 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.
         <td>Specifies identity.</td>
{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<ul>
     </tr>
                <li><b>RTS/CTS</b> - 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.</li>
                <li><b>Xon/Xoff</b> - 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.</li>
            </ul>|}}
        </td>
    </tr>{{#ifeq: {{{rs485}}} | 1 |
    <tr>
         <td><span style="color:blue">RS485:</span> Full Duplex</td>
         <td>off {{!}} on; default: <b>off</b></td>
         <td>Enables RS485 full duplex.</td>
     </tr>|}}
</table>
</table>
|}}
{{#ifeq:{{{serial}}}|1|
===Request messages===
===Serial Gateway Configuration===
----
----
<span style="color:red"> <b>Note: </b></span>MQTT Gateway uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>Register Number</i> field.
<b>Serial Gateway Configuration</b> 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.


Modbus request data sent in the MQTT payload should be generated in accordance with the one of the following formats:
[[File:Networking_rutos_manual_modbus_mqtt_gateway_serial_gateway_configuration_add_button_v1_rs232_{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|1|0}}.png|border|class=tlt-border]]


* TCP:
After this you should be redirected to instance's configuration page which should look similar to this:
  <b>0 <COOKIE> <IP_TYPE> <IP> <PORT> <TIMEOUT> <SERVER_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES></b>
* Serial:
  <b>1 <COOKIE> <SERIAL_DEVICE_ID> <TIMEOUT> <SERVER_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES></b>
* MODBUS TCP connection management messages:
  <b>2 <COOKIE> <CONNECTION_INDEX> <ACTION></b><br>
  <b>2 <COOKIE> <CONNECTION_INDEX> 0 <IP_TYPE> <IP> <PORT> <TIMEOUT></b>


Explanation:
[[File:Networking_rutos_manual_modbus_mqtt_gateway_serial_gateway_configuration_rs232_{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|1|0}}_v1.png|border|class=tlt-border]]


<ul>
<table class="nd-mantable">
     <li><b>Cookie</b> - a 64-bit unsigned integer in range [0..2<sup>64</sup>-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.</li>
    <tr>
     <li><b>IP type</b> - host IP address type. Possible values:
        <th>Field</th>
         <ul>
        <th>Value</th>
             <li><b>0</b> - IPv4 address;</li>
        <th>Description</th>
    </tr>
    <tr>
        <td>Enable</td>
        <td>off {{!}} on; default: <b>off</b></td>
        <td>Enables this Serial Gateway instance configuration.</td>
    </tr>
    <tr>
        <td>Name</td>
        <td>string; default: <b>none</b></td>
        <td>Name of the gateway instance. Used for management purposes only.</td>
    </tr>
    <tr>
        <td>Device</td>
        <td>{{Template: Networking rutos manual serial ports| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}; default: <b>{{Template: Networking rutos manual default serial port| rs232={{{rs232}}}| rs485={{{rs485}}}| usb = {{{usb}}}}}</b></td>
        <td>Specifies which serial port will be used for serial communication.</td>
    </tr>{{#ifeq: {{{rs485}}} | 1 |
    <tr>
    <td>Baud rate (RS485)</td>
        <td>integer [300..230400]; default:<b>9600</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}{{#ifeq: {{{rs232}}} | 1 |
    <tr>
    <td>Baud rate (RS232)</td>
        <td>integer [300..115200]; default:<b>9600</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}{{#ifeq: {{{usb}}} | 1 |
    <tr>
    <td>Baud rate (USB)</td>
        <td>integer [300..4000000]; default:<b>9600</b></td>
        <td>Data rate for serial data transmission (in bits per second (bps)).</td>
    </tr>|}}
    <tr>
        <td>Data bits</td>
        <td>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|{{#switch:{{{series}}}|TRB2|TRB2M=|#default=5 {{!}} 6 {{!}}}} 7 {{!}} |}}8; default: <b>8</b></td>
        <td>Number of data bits for each character.</td>
    </tr>
    <tr>
        <td>Stop bits</td>
        <td>1{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} 2|}}; default: <b>1</b></td>
        <td>Stop 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.</td>
    </tr>
    <tr>
        <td>Parity</td>
        <td>Even {{!}} Odd{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} Mark {{!}} Space|}} {{!}} None; default: <b>None</b></td>
        <td>In 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.
            <ul>
                <li><b>None</b> (<b>N</b>) - no parity method is used.</li>
                <li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li>
                <li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li>{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<li><b>Space</b> (<b>s</b>) - the parity bit will always be a binary 0.</li>
                <li><b>Mark</b> (<b>M</b>) - the parity bit will always be a binary 1.</li>|}}
            </ul>
        </td>
    </tr>
    <tr>
        <td>Flow control</td>
        <td>None {{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1| {{!}} RTS/CTS {{!}} Xon/Xoff|}}; default: <b>None</b></td>
        <td>In 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.
{{#ifeq:{{#expr: {{{rs232}}} or {{{usb}}}}} |1|<ul>
                <li><b>RTS/CTS</b> - 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.</li>
                <li><b>Xon/Xoff</b> - 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.</li>
            </ul>|}}
        </td>
    </tr>{{#ifeq: {{{rs485}}} | 1 |
    <tr>
        <td><span style="color:blue">RS485:</span> Full Duplex</td>
        <td>off {{!}} on; default: <b>off</b></td>
        <td>Enables RS485 full duplex.</td>
    </tr>|}}
</table>
|}}
===Request messages===
----
<span style="color:red"> <b>Note: </b></span>MQTT Gateway uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>Register Number</i> field.
 
Modbus request data sent in the MQTT payload should be generated in accordance with the one of the following formats:
 
* TCP:
  <b>0 <COOKIE> <IP_TYPE> <IP> <PORT> <TIMEOUT> <SERVER_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES> <BROADCAST></b>
* Serial:
  <b>1 <COOKIE> <SERIAL_DEVICE_ID> <TIMEOUT> <SERVER_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES> <BROADCAST></b>
* MODBUS TCP connection management messages:
  <b>2 <COOKIE> <CONNECTION_INDEX> <ACTION></b><br>
  <b>2 <COOKIE> <CONNECTION_INDEX> 0 <IP_TYPE> <IP> <PORT> <TIMEOUT></b>
 
Explanation:
 
<ul>
     <li><b>Cookie</b> - a 64-bit unsigned integer in range [0..2<sup>64</sup>-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.</li>
     <li><b>IP type</b> - host IP address type. Possible values:
         <ul>
             <li><b>0</b> - IPv4 address;</li>
             <li><b>1</b> - IPv6 address;</li>
             <li><b>1</b> - IPv6 address;</li>
             <li><b>2</b> - hostname that will be resolved to an IP address.</li>
             <li><b>2</b> - hostname that will be resolved to an IP address.</li>
         </ul>
         </ul>
     </li>
     </li>
     <li><b>IP</b> - IP address of a Modbus TCP server. IPv6 must be presented in full form (e.g., <i>2001:0db8:0000:0000:0000:8a2e:0370:7334</i>).</li>
     <li><b>IP</b> - IP address of a Modbus TCP server. IPv6 must be presented in full form (e.g., <i>2001:0db8:0000:0000:0000:8a2e:0370:7334</i>).</li>
     <li><b>Port</b> - port number of the Modbus TCP server.</li>
     <li><b>Port</b> - port number of the Modbus TCP server.</li>
     <li><b>Timeout</b> - timeout for Modbus connection, in seconds. Range [1..999].</li>
     <li><b>Timeout</b> - timeout for Modbus connection, in seconds. Range [1..999].</li>
     <li><b>Server ID</b> - Modbus TCP server ID. Range [1..255].</li>
     <li><b>Server ID</b> - Modbus TCP server ID. Range [1..255].</li>
     <li><b>Modbus function</b> - Modbus task type that will be executed. Possible values are:
     <li><b>Modbus function</b> - Modbus task type that will be executed. Possible values are:
         <ul>
         <ul>
             <li><b>1</b> - read coils;</li>
             <li><b>1</b> - read coils;</li>
             <li><b>2</b> - read input coils;</li>
             <li><b>2</b> - read input coils;</li>
             <li><b>3</b> - read holding registers;</li>
             <li><b>3</b> - read holding registers;</li>
             <li><b>4</b> - read input registers;</li>
             <li><b>4</b> - read input registers;</li>
             <li><b>5</b> - set single coil;</li>
             <li><b>5</b> - set single coil;</li>
             <li><b>6</b> - write to a single holding register;</li>
             <li><b>6</b> - write to a single holding register;</li>
             <li><b>15</b> - set multiple coils;</li>
             <li><b>15</b> - set multiple coils;</li>
             <li><b>16</b> - write to multiple holding registers.</li>
             <li><b>16</b> - write to multiple holding registers.</li>
        </ul>
    </li>
    <li><b>First register</b> - number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.</li>
    <li><b>Register count/value</b> - this value depends on the Modbus function:
        <ul>
            <li><b>1</b> - <u>coil count</u> (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);</li>
            <li><b>2</b> - <u>input count</u> (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);</li>
            <li><b>3</b> - <u>holding register count</u> (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);</li>
            <li><b>4</b> - <u>input register count</u> (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);</li>
            <li><b>5</b> - <u>coil value</u> (in range [0..1]);</li>
            <li><b>6</b> - <u>holding register value</u> (in range [0..65535]);</li>
            <li><b>15</b> - <u>coil count</u> (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and <u>coil values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].</li>
            <li><b>16</b> - <u>register count</u> (in range [1..123]); must not exceed the boundary (first register number + register count <= 65537); and <u>register values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with register count); each value must be in the range of [0..65535].</li>
         </ul>
         </ul>
     </li>
     </li>
     <li><b>First register</b> - number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.</li>
     <li><b>Broadcast</b> - number used to identify that the broadcast is ON (in range [0..1]). <b>Note:</b> that broadcast flag is not ignored only when 5,15,6,16 Modbus functions are used.
    <li><b>Register count/value</b> - this value depends on the Modbus function:
         <ul>
         <ul>
             <li><b>1</b> - <u>coil count</u> (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);</li>
             <li><b>0</b> - if <b>0</b> or not specified - message will be sent only to a Modbus server, that matches the provided <SERVER_ID> in the message.</li>
            <li><b>2</b> - <u>input count</u> (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);</li>
             <li><b>1</b> - message will be sent to all available Modbus servers on the network.</li>
            <li><b>3</b> - <u>holding register count</u> (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);</li>
            <li><b>4</b> - <u>input register count</u> (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);</li>
            <li><b>5</b> - <u>coil value</u> (in range [0..1]);</li>
             <li><b>6</b> - <u>holding register value</u> (in range [0..65535]);</li>
            <li><b>15</b> - <u>coil count</u> (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and <u>coil values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].</li>
            <li><b>16</b> - <u>register count</u> (in range [1..123]); must not exceed the boundary (first register number + register count <= 65537); and <u>register values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with register count); each value must be in the range of [0..65535].</li>
         </ul>
         </ul>
     </li>
     </li>  
     <li><b>Serial device ID</b> - a string used to identify a serial device. Must match with <u>Device ID</u> field in MQTT Gateway page Serial gateway configuration section.</li>
     <li><b>Serial device ID</b> - a string used to identify a serial device. Must match with <u>Device ID</u> field in MQTT Gateway page Serial gateway configuration section.</li>
     <li><b>Connection index</b> - a number used to identify a connection on which an action will be preformed (in range [0..7]).</li>
     <li><b>Connection index</b> - a number used to identify a connection on which an action will be preformed (in range [0..7]).</li>

Latest revision as of 11:54, 24 October 2025

The information in this page is updated in accordance with firmware version .


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 {{{name}}} devices.

Note: Modbus TCP Server/Client and MQTT Gateway is additional software on some devices that can be installed from the System → [[{{{name}}} Package Manager|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:

Field Value Description
Enable off | on; default: off Turns Modbus TCP on or off.
Port integer [0..65535]; default: 502 TCP port used for Modbus communications.
Device ID integer [0..255]; default: 1 The device's Modbus server ID. When set to 0, it will respond to requests addressed to any ID.
Mobile Data type Bytes | Kilobytes | Megabytes; default: Bytes Selects mobile data unit representation type.
Allow remote access off | on; default: off Allows remote Modbus connections by adding an exception to the device's firewall on the port specified in the field above.
Enable broadcasts off | on; default: off Process incoming Modbus broadcast messages.
Keep persistent connection off | on; default: onn Allows keep the connection open after responding a Modbus TCP client request.
Connection timeout integer [0..60]; default: 0 Sets TCP timeout in seconds after which the connection is forcefully closed.
Enable custom register block off | on; default: off Allows the usage of custom register block.
Register file path path; default: /mnt/regfile Path 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 number integer [1025..65536]; default: 1025 First register in custom register block
Register count integer [1..64512]; default: 128 Register count in custom register block

Data Sources

Data sources transmit data from one or more data sources (can be a Modbus client) and write it to Modbus registers.

To add new data source, press `Add` button:

Register configuration:

Field Value Description
Enable off | on; default: off Turns Register configuration on or off.
Register name string; default: none Name of the register.
Register source list; default: none Client service which will be sending requests.
Register value list and permissions type; default: none Request value and its permissions (Read-Only, Write-Only or Read-Write).
Register range integer [1..65535]; default: none Specify the start index and count for the range.
Register type Binary | String | Bool | INT8 | UINT8 | INT16 | UINT16 | INT32 | UINT32 | INT64 | UINT64 | FLOAT32 | FLOAT64; default: Binary Value data type.
Register size (with Binary and String data) integer [1..8064]; default: none Size of the value in bytes.
Modbus register range integer; default: none Start and calculated end of the register numbers.
Modbus data type Coils (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 value register address register number number of registers representation
System uptime 1 2 2 32 bit unsigned integer
System hostname 7 8 16 ASCII
Serial number 39 40 16 ASCII
LAN MAC address 55 56 16 ASCII
Device name 71 72 16 ASCII
WAN IP address 139 140 2 8 bit unsigned integer
Unix timestamp 364 365 2 32 bit unsigned integer
Local ISO time 366 367 12 ASCII
UTC time 378 379 12 ASCII
LAN IP 394 395 2 16 bit unsigned integer

Set Parameters


The Modbus daemon can also set some device parameters.

value to set register address register number register value description
Hostname 7 8 Hostname (in decimal form) Changes hostname
Device name 71 72 Device name (in decimal form) Changes device name
Reboot 206 207 1 Reboots the router
Change LAN IP 394 395 IPv4 (in decimal form) Changes device LAN IP

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.

Field Value Description
Enabled off | on; default: off Turn on/off Modbus client service.
Database location RAM ; default: RAM Select Modbus database location.
Database size size in KiB Current 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.

Field Value Description
Enabled off | on; default: off Turns communication with the server device on or off.
Name string; default: none Server device's name, used for easier management purposes.
Server ID integer [0..255]; default: 1 Modbus 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 address ip4; default: none Server device's IP address.
Port integer [0..65535]; default: none Server device's Modbus TCP port.
Timeout integer [1..30]; default: 5 Maximum response wait time.
Always reconnect off | on; default: off Create new connection after every Modbus request.
Number of timeouts integer [0..10]; default: 1 Skip pending request and reset connection after number of request failures.
Frequency Period | Schedule; default: Period
Delay integer [0..999]; default: 0 Wait in milliseconds after connection initialization.
Period integer [1..99999]; default: 60 Interval in seconds for sending requests to this device
Schedule request time format string 'hh:mm:ss'; default: none Schedule 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:

Field Value Description
Name string; default: Unnamed Name of this Request Configuration. Used for easier management purposes.
Data type 8bit 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 first Defines how read data will be stored.
Function Read 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 Register integer [0..65535]; default: 1 First Modbus register from which data will be read.
Register Count / Values integer [1..2000]; default: 1 Number of Registers/Coils/Inputs or actual values to be written (Multiple values must be separated by space character).
No brackets off | on; default: off Removes the starting and ending brackets from the request (only for read requests).
Store on change only off | on; default: off Store the response only if the value has changed.
Broadcast off | on; default: off Enable to broadcast the request to all devices (only for write requests).
Enabled off | on; default: off Turns 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 {{{name}}} 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:

Field Value Description
Enabled off | on; default: off Turns the alarm on or off.
Function code Read 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 {{{name}}} device) perform this request as often as specified in the 'Period' field in Server Device Configuration.
Compared condition data type 8bit 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 first Select data type that will be used for checking conditions.
First register number integer [1..65536]; default: none Number of the Modbus coil/input/holding-register/input-register to read from.
Values various; default: none The value against which the read data will be compared.
Condition More than | Less than | Equal to | Not Equal to | Less or equal | More or equal; default: More than When 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 frequency Every trigger | First trigger; default: Every trigger Describes how frequently the specified action will be taken.
Redundancy protection off | on; default: off Protection against executing a configured action too often.
Redundancy protection period integer [1..86400]; default: none Duration to activate redundancy protection for, measured in seconds. This field becomes visible only when 'Redundancy protection' is turned on.
Action Ubus event | Email | MODBUS Write Request | Trigger output | MQTT message; default: MODBUS Write Request Action that will be taken if the condition is met. Possible actions:
  • 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.
Email: Subject string; default: none Subject of an email. Allowed characters (a-zA-Z0-9!@#$%&*+-/=?^_`{|}~. ).
Email: Message text string; default: none Message that will be sent if condition passes.
Email: Sender's email account string; default: none Sender's email configuration (configure it [[{{{name}}}_Administration#Recipients | here]]).
Email: Recipient's email address email address; default: none For whom you want to send an email to. Allowed characters (a-zA-Z0-9._%+@-).
MODBUS Write Request: IP address ip | host; default: none Modbus server's IP address.
MODBUS Write Request: Port integer [0..65535]; default: none Modbus server's port.
MODBUS Write Request: Timeout integer [1..30]; default: 5 Maximum time to wait for a response.
MODBUS Write Request: ID integer [1..255]; default: none Modbus server ID.
MODBUS Write Request: Modbus function Set 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 type 8bit 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: Bool Select data type that will be used for executing action.
MODBUS Write Request: First register number integer [0..65535]; default: none Begins reading from the register specified in this field.
MODBUS Write Request: Values integer [0..65535]; default: none Register/Coil values to be written (multiple values must be separated by space character).
Trigger output: Output Selects which output will be triggered.
Trigger output: I/O Action Turn On | Turn Off | Invert; default: Turn On Selects the action performed on the output.
MQTT message: JSON format string; 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, Mobile IP addresses, Signal strength, 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: Hostname host | ip; default: none Broker’s IP address or hostname.
MQTT message: Port integer [0..65535]; default: 1883 Broker's port number.
MQTT message: Keepalive positive integer; default: none The 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: Topic string; default: none The name of the topic that the broker will subscribe to.
MQTT message: Client ID positive integer; default: none Client ID to send with the data. If empty, a random client ID will be generated
MQTT message: QoS At 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 CA off | on; default: off Use root CA for verifying the servers certificates
MQTT message: Use TLS off | on; default: off Turns the use of TLS/SSL for this MQTT connection on or off.
MQTT message: Use credentials off | on; default: off Turns 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 {{{name}}}) 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.

Field Value Description
Enable off | on; default: off Turns MQTT gateway on or off.
Host ip | host; default: 127.0.0.1 IP address or hostname of an MQTT broker.
Port integer [0..65535]; default: 1883 Port number of the MQTT broker.
Message type ASCII | JSON; default: ASCII Format in which requests and responses will be sent to MQTT broker.
Request topic alphanumeric string; default: request/$$SERIAL Topic name.
  • Constants:
  • Serial number: $$SERIAL
  • Mac address: $$MAC
  • Device name: $$NAME
Response topic alphanumeric string; default: response/$$SERIAL Topic name.
  • Constants:
  • Serial number: $$SERIAL
  • Mac address: $$MAC
  • Device name: $$NAME
QoS At most once (0) | At least once (1) | Exactly once (2); default: Exactly once (2) Specifies quality of service.
Username string; default: none Username for authentication to the MQTT broker.
Password string; default: none Password for authentication to the MQTT broker.
Client ID integer; default: none Specifies client ID for MQTT broker.
Keepalive integer; default: 5 Keepalive message to MQTT broker (seconds)
Use TLS/SSL off | on; default: off Turns TLS support on or off
TLS type Certificate based | Pre-Shared-Key based; default: Certificate based Selects the type of TLS encryption
TLS insecure off | on; default: off Disables TLS security
Certificate files from device off | on; default: off Choose this option if you want to use certificate files generated on device.
CA file string; default: none Upload/select certificate authority file.
Certificates file string; default: none Upload/select certificate file.
Key file string; default: none Upload/select key file.
PSK string; default: none Specifies the pre-shared key.
Identity string; default: none Specifies identity.

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 {{{name}}}.


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 {{{name}}}), 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


See also

[[Category:{{{name}}} Services section]]