Changes

no edit summary
Line 1: Line 1: −
{{Template:Networking_rutos_manual_fw_disclosure
+
{{Template: Networking_rutos_manual_fw_disclosure
| fw_version = {{{series}}}_R_00.02.05
+
| fw_version = {{{series}}}_R_00.07.01
 
| series    = {{{series}}}
 
| series    = {{{series}}}
 
}}
 
}}
 
+
{{#ifeq: {{{series}}} | RUT9 |<br><i><b>Note</b>: <b>[[{{{name}}} Modbus (legacy WebUI)|click here]]</b> for the old style WebUI (FW version RUT9XX_R_00.06.08.3 and earlier) user manual page.</i>|}}
 +
{{#ifeq: {{{series}}} | RUT2 |<br><i><b>Note</b>: <b>[[{{{name}}} Modbus (legacy WebUI)|click here]]</b> for the old style WebUI (FW version RUT2XX_R_00.01.14.1 and earlier) user manual page.</i>|}}
 
==Summary==
 
==Summary==
   Line 9: Line 10:     
This manual page provides an overview of the Modbus functionality in {{{name}}} devices.
 
This manual page provides an overview of the Modbus functionality in {{{name}}} devices.
 +
{{#switch: {{{series}}}
 +
| RUTX =
 +
| TRB1 =
 +
| TRB2 =
 +
| RUT9 =
 +
| #default =
 +
<u><b>
    +
Note:</b> On {{{name}}}, Modbus TCP Slave/Master and MQTT Gateway is additional software that can be installed from the <b>Services → [[{{{name}}} Package Manager|Package Manager]]</b> page.</u><br>}}
 
{{Template:Networking_rutos_manual_basic_advanced_webui_disclaimer
 
{{Template:Networking_rutos_manual_basic_advanced_webui_disclaimer
 
| series = {{{series}}}
 
| series = {{{series}}}
Line 30: Line 39:  
     <tr>
 
     <tr>
 
       <td>Enable</td>
 
       <td>Enable</td>
       <td>off | on; default: <b>none</b></td>
+
       <td>off | on; default: <b>off</b></td>
 
       <td>Turns Modbus TCP on or off.</td>
 
       <td>Turns Modbus TCP on or off.</td>
 
     </tr>
 
     </tr>
Line 71: Line 80:  
|analog = {{{analog}}}
 
|analog = {{{analog}}}
 
|gps = {{{gps}}}
 
|gps = {{{gps}}}
 +
|dualsim = {{{dualsim}}}
 
}}
 
}}
    
{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table  
 
{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table  
|wifi={{{wifi}}}
+
|wifi = {{{wifi}}}
|mobile={{{mobile}}}
+
|mobile = {{{mobile}}}
|series={{{series}}}
+
|series = {{{series}}}
|name={{{name}}}
+
|name = {{{name}}}
 +
|dualsim = {{{dualsim}}}
 
}}
 
}}
 
==Modbus TCP Master==
 
==Modbus TCP Master==
Line 272: Line 283:  
     <tr>
 
     <tr>
 
         <td>Action</td>
 
         <td>Action</td>
         <td>SMS | MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
+
         <td>{{#ifeq:{{{mobile}}}|1|SMS {{!}}|}} MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
 
         <td>Action that will be taken if the condition is met. Possible actions:
 
         <td>Action that will be taken if the condition is met. Possible actions:
             <ul>
+
             <ul>{{#ifeq: {{{mobile}}} | 1 |
                 <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>
+
                 <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 slave.</li>
 
                 <li><b>Modbus Request</b> - sends a Modbus Write request to a specified slave.</li>
 
             </ul>
 
             </ul>
 
         </td>
 
         </td>
     </tr>
+
     </tr>{{#ifeq: {{{mobile}}} | 1 |
 
     <tr>
 
     <tr>
 
         <td><span style="color: #0054a6;">SMS: Message</span></td>
 
         <td><span style="color: #0054a6;">SMS: Message</span></td>
Line 289: Line 300:  
         <td>phone number; default: <b>none</b></td>
 
         <td>phone number; default: <b>none</b></td>
 
         <td>Recipient's phone number.</td>
 
         <td>Recipient's phone number.</td>
     </tr>
+
     </tr>|}}
 
     <tr>
 
     <tr>
 
         <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
 
         <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
Line 330: Line 341:     
The <b>Modbus Serial Master</b> page is used to configure the device as a Modbus RTU Master. Modbus RTU (remote terminal unit) is a serial communication protocol mainly used in communication via serial interfaces.
 
The <b>Modbus Serial Master</b> page is used to configure the device as a Modbus RTU Master. Modbus RTU (remote terminal unit) is a serial communication protocol mainly used in communication via serial interfaces.
 +
 +
<u><b>Note:</b> Modbus Serial Master is additional software that can be installed from the <b>Services → [[{{{name}}} Package Manager|Package Manager]]</b> page.</u>
 
{{#ifeq: {{{rs232}}} | 1 |
 
{{#ifeq: {{{rs232}}} | 1 |
 
===RS232===
 
===RS232===
Line 436: Line 449:  
     </tr>
 
     </tr>
 
</table>
 
</table>
====Requests Configuration====
+
=====Requests Configuration=====
 
----
 
----
 
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
 
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
Line 505: Line 518:  
[[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_testing.png|border|class=tlt-border]]
   −
====Modbus Master Alarms====
+
=====Modbus Master Alarms=====
 
----
 
----
 
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Master (this {{{name}}} device) requests some information from a slave 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 Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
 
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Master (this {{{name}}} device) requests some information from a slave 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 Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
Line 574: Line 587:  
     <tr>
 
     <tr>
 
         <td>Action</td>
 
         <td>Action</td>
         <td>SMS <nowiki>|</nowiki> MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
+
         <td>{{#ifeq:{{{mobile}}}|1|SMS {{!}}|}} MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
 
         <td>Action that will be taken if the condition is met. Possible actions:
 
         <td>Action that will be taken if the condition is met. Possible actions:
             <ul>
+
             <ul>{{#ifeq: {{{mobile}}} | 1 |
                 <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>
+
                 <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 slave.</li>
 
                 <li><b>Modbus Request</b> - sends a Modbus Write request to a specified slave.</li>
 
             </ul>
 
             </ul>
 
         </td>
 
         </td>
     </tr>
+
     </tr>{{#ifeq: {{{mobile}}} | 1 |
 
     <tr>
 
     <tr>
 
         <td><span style="color: #0054a6;">SMS: Message</span></td>
 
         <td><span style="color: #0054a6;">SMS: Message</span></td>
Line 591: Line 604:  
         <td>phone number; default: <b>none</b></td>
 
         <td>phone number; default: <b>none</b></td>
 
         <td>Recipient's phone number.</td>
 
         <td>Recipient's phone number.</td>
     </tr>
+
     </tr>|}}
 
     <tr>
 
     <tr>
 
         <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
 
         <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
Line 619: Line 632:  
</table>
 
</table>
 
|}}|}}{{#ifeq: {{{rs485}}} | 1 |
 
|}}|}}{{#ifeq: {{{rs485}}} | 1 |
===RS485===
+
<h3>RS485</h3>
 
----
 
----
 
This section is used to configure the Modbus Serial Master's <b>RS485</b> serial interface settings. Refer to the figure and table below for information on RS485 configuration.
 
This section is used to configure the Modbus Serial Master's <b>RS485</b> serial interface settings. Refer to the figure and table below for information on RS485 configuration.
Line 634: Line 647:  
         <td>Enabled</td>
 
         <td>Enabled</td>
 
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Turns Modbus Serial Master configuration via RS232 on or off. Both this and RS232 from Services → [[{{{name}}} RS232|RS232]] cannot be enabled at the same time.</td>
+
         <td>Turns Modbus Serial Master configuration via RS485 on or off. Both this and RS485 from Services → [[{{{name}}} RS485|RS485]] cannot be enabled at the same time.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
Line 724: Line 737:  
     </tr>
 
     </tr>
 
</table>
 
</table>
====Requests Configuration====
+
=====Requests Configuration=====
 
----
 
----
 
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
 
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
Line 793: Line 806:  
[[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_testing.png|border|class=tlt-border]]
   −
====Modbus Master Alarms====
+
=====Modbus Master Alarms=====
 
----
 
----
 
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Master (this {{{name}}} device) requests some information from a slave 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 Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
 
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Master (this {{{name}}} device) requests some information from a slave 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 Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
Line 906: Line 919:  
     </tr>
 
     </tr>
 
</table>
 
</table>
|}}|}}
+
|}}
 +
 
 
==MQTT Gateway==
 
==MQTT Gateway==
   −
The <b>MQTT Gateway</b> function is used to transfer Modbus data over MQTT. Refer to the table for information on MQTT Gateway configuration fields.
+
The <b>MQTT 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 slave.
 +
 
 +
When the MQTT Gateway receives a response from the slave, 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.
    
[[File:Networking_rutos_manual_modbus_mqtt_gateway.png|border|class=tlt-border]]
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway.png|border|class=tlt-border]]
Line 937: Line 957:  
         <td>Request topic</td>
 
         <td>Request topic</td>
 
         <td>alphanumeric string; default: <b>request</b></td>
 
         <td>alphanumeric string; default: <b>request</b></td>
         <td>.</td>
+
         <td>MQTT topic for sending requests.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
 
         <td>Response topic</td>
 
         <td>Response topic</td>
 
         <td>alphanumeric string; default: <b>response</b></td>
 
         <td>alphanumeric string; default: <b>response</b></td>
         <td>.</td>
+
         <td>MQTT topic for subscribing to responses.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
Line 955: Line 975:  
     </tr>
 
     </tr>
 
</table>
 
</table>
 +
 +
===Request messages===
 +
----
 +
Modbus request data sent in the MQTT payload should be generated in accordance with the following format:
 +
 +
<b>0 <COOKIE> <IP_TYPE> <IP> <PORT> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <REGISTER_NUMBER> <REGISTER_COUNT/VALUE></b>
 +
 +
Explanation:
 +
 +
<ul>
 +
    <li><b>0</b> - must be 0, which signifies a textual format (currently the only one implemented).</li>
 +
    <li><b>Cookie</b> - a 64-bit unsigned integer in range [0..2<sup>64</sup>]). 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>2</b> - hostname that will be resolved to an IP address.</li>
 +
        </ul></li>
 +
    <li><b>IP</b> - IP address of a Modbus TCP slave. 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 slave.</li>
 +
    <li><b>Timeout</b> - timeout for Modbus TCP connection, in seconds. Range [1..999].</li>
 +
    <li><b>Slave ID</b> - Modbus TCP slave ID. Range [1..255].</li>
 +
    <li><b>Modbus function</b> - Modbus task type that will be executed. Possible values are:
 +
        <ul>
 +
            <li><b>3</b> - read holding registers;</li>
 +
            <li><b>6</b> - write to a single holding register;</li>
 +
            <li><b>16</b> - write to multiple holding registers.</li>
 +
        </ul></li>
 +
    <li><b>Register number</b> - number of the first register (in range [1..65536]) from which the registers will be read/written to.
 +
    <li><b>Register count/value</b> - this value depends on the Modbus function:
 +
        <ul>
 +
            <li><b>3</b> - <u>register count</u> (in range [1..125]); must not exceed the boundary (first register number + register count <= 65537);</li>
 +
            <li><b>6</b> - <u>register value</u> (in range [0..65535]);</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></li>
 +
</ul>
 +
 +
===Response messages===
 +
----
 +
A special response message can take one of the following forms:
 +
 +
<COOKIE> OK                              - <i>for functions 6 and 16</i>
 +
<COOKIE> OK <VALUE> <VALUE> <VALUE>...  - <i>for function 3, where <VALUE> <VALUE> <VALUE>... are read register values</i>
 +
<COOKIE> ERROR: ...                      - <i>for failures, where ... is the error description</i>
 +
 +
===Examples===
 +
----
 +
Below are a few <b>examples</b> of controlling/monitoring the internal Modbus TCP Slave on {{{name}}}.
 +
----
 +
<b>Reboot the device</b>
 +
 +
<ul>
 +
    <li>Request:<br><pre>0 65432 0 192.168.1.1 502 5 1 6 206 1</pre></li>
 +
    <li>Response:<br><pre>65432 OK</pre></li>
 +
</ul>
 +
----
 +
<b>Retrieve uptime</b>
 +
 +
<ul>
 +
    <li>Request:<br><pre>0 65432 0 192.168.1.1 502 5 1 3 2 2</pre></li>
 +
    <li>Response:<br><pre>65432 OK 0 5590</pre></li>
 +
</ul>
 +
----
 +
If you're using Eclipse Mosquitto (MQTT implementation used on {{{name}}}), Publish/Subscribe commands may look something like this:
 +
 +
<b>Retrieve uptime</b>
 +
 +
<ul>
 +
    <li>Request:<br><pre>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"</pre></li>
 +
    <li>Response:<br><pre>mosquitto_sub -h 192.168.1.1 -p 1883 -t response
 +
65432 OK 0 5590</pre></li>
 +
</ul>
    
==See also==
 
==See also==
   −
{{Template: Networking_device_modbus_see_also}}
+
<ul>
 +
    <li><b>[[{{{name}}} Monitoring via Modbus|Monitoring via Modbus]]</b> - detailed examples on how to use Modbus TCP</li>
 +
</ul>
    
[[Category:{{{name}}} Services section]]
 
[[Category:{{{name}}} Services section]]

Navigation menu