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 183: Line 194:  
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Enabled</td>
+
         <td>No Brackets</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>Removes the starting and ending brackets from the request (only for read requests).</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
Line 192: Line 203:  
         <td>Deletes the request.</td>
 
         <td>Deletes the request.</td>
 
     </tr>
 
     </tr>
 
+
    <tr>
 +
        <td>off/on slider</td>
 +
        <td>off | on; default: <b>off</b></td>
 +
        <td>Turns the request on or off.</td>
 +
    </tr>
 
</table>
 
</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:
+
<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_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
 
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
Line 268: 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 285: 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 326: 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 346: Line 363:  
     <tr>
 
     <tr>
 
         <td>Baud rate</td>
 
         <td>Baud rate</td>
         <td>300 | 1200 | 2400 | 4800 | 9600 | 19200 | 38400 | 57600 | 115200; default: <b>115200</b></td>
+
         <td>300 <nowiki>|</nowiki> 1200 <nowiki>|</nowiki> 2400 <nowiki>|</nowiki> 4800 <nowiki>|</nowiki> 9600 <nowiki>|</nowiki> 19200 <nowiki>|</nowiki> 38400 <nowiki>|</nowiki> 57600 <nowiki>|</nowiki> 115200; default: <b>115200</b></td>
 
         <td>Serial data transmission rate (in bits per second).</td>
 
         <td>Serial data transmission rate (in bits per second).</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
 
         <td>Data bits</td>
 
         <td>Data bits</td>
         <td>5 | 6 | 7 | 8; default: <b>8</b></td>
+
         <td>5 <nowiki>|</nowiki> 6 <nowiki>|</nowiki> 7 <nowiki>|</nowiki> 8; default: <b>8</b></td>
 
         <td>Number of data bits for each character.</td>
 
         <td>Number of data bits for each character.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
 
         <td>Parity</td>
 
         <td>Parity</td>
         <td>None | Even | Odd; default: <b>None</b></td>
+
         <td>None <nowiki>|</nowiki> Even <nowiki>|</nowiki> Odd; 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>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>
 
             <ul>
Line 367: Line 384:  
     <tr>
 
     <tr>
 
         <td>Stop bits</td>
 
         <td>Stop bits</td>
         <td>1 | 2; default: <b>1</b></td>
+
         <td>1 <nowiki>|</nowiki> 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>
 
         <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>Flow control</td>
 
         <td>Flow control</td>
         <td>None | RTS/CTS | Xon/Xoff; default: <b>None</b></td>
+
         <td>None <nowiki>|</nowiki> RTS/CTS <nowiki>|</nowiki> 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.
 
         <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>
 
             <ul>
Line 388: Line 405:  
The list is empty by default. In order to create a new slave device configuration, click the 'Add' button.
 
The list is empty by default. In order to create a new slave device configuration, click the 'Add' button.
   −
[[File:Networking_rutos_manual_modbus_modbus_serial_master_slave_devices_list_add_button.png|border|class=tlt-border]]
+
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs232_slave_devices_list_add_button.png|border|class=tlt-border]]
 +
 
 +
Then click the 'Edit' button next to the newly added slave device in order to begin configuration.
 +
 
 +
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs232_slave_devices_list_edit_button.png|border|class=tlt-border]]
 +
 
 +
=====RS232 Slave Device Configuration=====
 +
----
 +
The <b>RS232 Slave Device Configuration</b> section is used to configure the parameters of Modbus RTU slaves that the Master (this {{{name}}} device) will be querying with requests. The figure below is an example of the RS232 Slave 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>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <th>Description</th>
 +
    </tr>
 +
    <tr>
 +
        <td>Enabled</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Turns communication with the slave device on or off.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Name</td>
 +
        <td>string; default: <b>none</b></td>
 +
        <td>Slave device's name, used for easier management purposes.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Slave ID</td>
 +
        <td>integer [0..255]; default: <b>none</b></td>
 +
        <td>Slave ID. Each slave in a network is assigned a unique identifier ranging from 1 to 255. When the master requests data from a slave, the first byte it sends is the Slave ID. When set to 0, the slave 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 slave device.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Timeout</td>
 +
        <td>integer [1..30]; default: <b>5</b></td>
 +
        <td>Maximum response wait time.</td>
 +
    </tr>
 +
</table>
 +
=====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.
 +
 
 +
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.png|border|class=tlt-border]]
   −
Then click the 'Edit' button next to the newly added slave device in order to begin conifguration
+
<table class="nd-mantable">
 +
    <tr>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <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>
 +
        <td>Data type</td>
 +
        <td>8bit INT <nowiki>|</nowiki> 8bit UINT <nowiki>|</nowiki> 16bit INT, high byte first <nowiki>|</nowiki> 16bit INT, low byte first <nowiki>|</nowiki> 16bit UINT, high byte first <nowiki>|</nowiki> 16bit UINT, low byte first <nowiki>|</nowiki> 32bit float, Byte order 1,2,3,4 <nowiki>|</nowiki> 32bit float, Byte order 4,3,2,1 <nowiki>|</nowiki> 32bit float, Byte order 2,1,4,3 <nowiki>|</nowiki> 32bit float, Byte order 3,4,1,2; default: <b>16bit INT, high byte first</b></td>
 +
        <td>Defines how read data will be stored.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Function</td>
 +
        <td>Read coils (1) <nowiki>|</nowiki> Read input coils (2) <nowiki>|</nowiki> Read holding registers (3) <nowiki>|</nowiki> Read input registers (4) <nowiki>|</nowiki> Set single coil (5) <nowiki>|</nowiki> Set single coil register (6) <nowiki>|</nowiki> Set multiple coils (15) <nowiki>|</nowiki> Set multiple holding registers (16); default: <b>Read holding registers (3)</b></td>
 +
        <td>Specifies the type of register being addressed by a Modbus request.
 +
        </td>
 +
    </tr>
 +
    <tr>
 +
        <td>First Register</td>
 +
        <td>integer [0..65535]; default: <b>1</b></td>
 +
        <td>First Modbus register from which data will be read.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Register Count / Values</td>
 +
        <td>integer [1..2000]; default: <b>1</b></td>
 +
        <td>Number of Modbus registers that will be read during the request.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>No Brackets</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Removes the starting and ending brackets from the request (only for read requests).</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Delete [ X ]</td>
 +
        <td>- (interactive button)</td>
 +
        <td>Deletes the request.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>off/on slider</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Turns the request on or off.</td>
 +
    </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_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 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.
   −
[[File:Networking_rutos_manual_modbus_modbus_serial_master_slave_devices_list_edit_button.png|border|class=tlt-border]]
+
The figure below is an example of the Modbus Master 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]]
==MQTT Gateway==
+
 
 +
Then click the 'Edit' button next to the newly created Alarm to configuration.
 +
 
 +
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_edit_button.png|border|class=tlt-border]]
   −
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.
+
After this you should be redirected to that Alarm's configuration page which should look similar to this:
   −
[[File:Networking_rutos_manual_modbus_mqtt_gateway.png|border|class=tlt-border]]
+
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_alarm_configuration.png|border|class=tlt-border]]
    
<table class="nd-mantable">
 
<table class="nd-mantable">
Line 408: Line 541:  
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Enable</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 MQTT gateway on or off.</td>
+
         <td>Turns the alarm on or off.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Function code</td>
 +
        <td>Read Coil Status (1) <nowiki>|</nowiki> Read Input Status (2) <nowiki>|</nowiki> Read Holding Registers (3) <nowiki>|</nowiki> 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 Master (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#RS485_Slave_Device_Configuration|RS485 Slave Device Configuration]].</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Register</td>
 +
        <td>integer [1..65536]; default: <b>none</b></td>
 +
        <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Condition</td>
 +
        <td>More than <nowiki>|</nowiki> Less than <nowiki>|</nowiki> Equal to <nowiki>|</nowiki> Not Equal to; default: <b>Equal to</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>
 +
        <td>Value</td>
 +
        <td>various; default: <b>none</b></td>
 +
        <td>The value against which the read data will be compared.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Host</td>
+
         <td>Value</td>
         <td>ip <nowiki>|</nowiki> host; default: <b>127.0.0.1</b></td>
+
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>IP address or hostname of an MQTT broker.</td>
+
         <td>The value against which the read data will be compared.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Port</td>
+
         <td>Action frequency</td>
         <td>integer [0..65535]; default: <b>1883</b></td>
+
         <td>Every trigger <nowiki>|</nowiki> First trigger; default: <b>Every trigger</b></td>
         <td>Port number of the MQTT broker.</td>
+
         <td>Describes how frequently the specified action will be taken.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Request topic</td>
+
         <td>Redundancy protection</td>
         <td>alphanumeric string; default: <b>request</b></td>
+
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>.</td>
+
         <td>Protection against executing a configured action too often.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Response topic</td>
+
         <td>Redundancy protection period</td>
         <td>alphanumeric string; default: <b>response</b></td>
+
         <td>integer [1..86400]; default: <b>none</b></td>
         <td>.</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>Username</td>
+
         <td>Action</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:
 +
            <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 slave.</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>string; default: <b>none</b></td>
         <td>Username for authentication to the MQTT broker.</td>
+
         <td>SMS message text.</td>
 +
    </tr>
 +
    <tr>
 +
        <td><span style="color: #0054a6;">SMS: Phone number</span></td>
 +
        <td>phone number; default: <b>none</b></td>
 +
        <td>Recipient's phone number.</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>
 +
        <td><span style="color: purple;">MODBUS Write Request: ID</span></td>
 +
        <td>integer [1..255]; default: <b>none</b></td>
 +
        <td>Modbus slave ID.</td>
 +
    </tr>
 +
    <tr>
 +
        <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
 +
        <td>Read Force Single Coil (5) <nowiki>|</nowiki> Preset Single Register (6) <nowiki>|</nowiki> Force Multiple Coils (15) <nowiki>|</nowiki> Force Multiple Registers (16); default: <b>Force Single Coil (5)</b></td>
 +
        <td>A function code specifies the type of register being addressed by a Modbus request.</td>
 +
    </tr>
 +
    <tr>
 +
        <td><span style="color: purple;">MODBUS Write Request: First register</span></td>
 +
        <td>integer [0..65535]; default: <b>none</b></td>
 +
        <td>Begins reading from the register specified in this field.</td>
 +
    </tr>
 +
    <tr>
 +
        <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
 +
        <td>integer [0..65535]; default: <b>none</b></td>
 +
        <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
 +
    </tr>
 +
</table>
 +
|}}|}}{{#ifeq: {{{rs485}}} | 1 |
 +
<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.
 +
 
 +
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs485_configuration.png|border|class=tlt-border]]
 +
 
 +
<table class="nd-mantable">
 +
    <tr>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <th>Description</th>
 +
    </tr>
 +
    <tr>
 +
        <td>Enabled</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></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>
 +
        <td>Baud rate</td>
 +
        <td>300 <nowiki>|</nowiki> 1200 <nowiki>|</nowiki> 2400 <nowiki>|</nowiki> 4800 <nowiki>|</nowiki> 9600 <nowiki>|</nowiki> 19200 <nowiki>|</nowiki> 38400 <nowiki>|</nowiki> 57600 <nowiki>|</nowiki> 115200; default: <b>115200</b></td>
 +
        <td>Serial data transmission rate (in bits per second).</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Data bits</td>
 +
        <td>5 <nowiki>|</nowiki> 6 <nowiki>|</nowiki> 7 <nowiki>|</nowiki> 8; default: <b>8</b></td>
 +
        <td>Number of data bits for each character.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Parity</td>
 +
        <td>None <nowiki>|</nowiki> Even <nowiki>|</nowiki> Odd; 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>
 +
            </ul>
 +
        </td>
 +
    </tr>
 +
    <tr>
 +
        <td>Stop bits</td>
 +
        <td>1 <nowiki>|</nowiki> 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>Flow control</td>
 +
        <td>None <nowiki>|</nowiki> RTS/CTS <nowiki>|</nowiki> 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.
 +
            <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>
 +
</table>
 +
 
 +
====RS485 Slave Devices List====
 +
----
 +
The <b>RS485 Slave Devices List</b> section is used to configure the parameters of Modbus RUT slaves that the Master (this {{{name}}} device) will be querying with requests.
 +
 
 +
The list is empty by default. In order to create a new slave device configuration, click the 'Add' button.
 +
 
 +
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs485_slave_devices_list_add_button.png|border|class=tlt-border]]
 +
 
 +
Then click the 'Edit' button next to the newly added slave device in order to begin configuration.
 +
 
 +
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs485_slave_devices_list_edit_button.png|border|class=tlt-border]]
 +
 
 +
=====RS485 Slave Device Configuration=====
 +
----
 +
The <b>RS485 Slave Device Configuration</b> section is used to configure the parameters of Modbus RTU slaves that the Master (this {{{name}}} device) will be querying with requests. The figure below is an example of the RS485 Slave Device Configuration and the table below provides information on the fields contained in that section:
 +
 
 +
[[File:Networking_rutos_manual_modbus_modbus_serial_master_rs485_slave_device_configuration.png|border|class=tlt-border]]
 +
 
 +
<table class="nd-mantable">
 +
    <tr>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <th>Description</th>
 +
    </tr>
 +
    <tr>
 +
        <td>Enabled</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Turns communication with the slave device on or off.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Password</td>
+
         <td>Name</td>
 
         <td>string; default: <b>none</b></td>
 
         <td>string; default: <b>none</b></td>
         <td>Password for authentication to the MQTT broker.</td>
+
         <td>Slave device's name, used for easier management purposes.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Slave ID</td>
 +
        <td>integer [0..255]; default: <b>none</b></td>
 +
        <td>Slave ID. Each slave in a network is assigned a unique identifier ranging from 1 to 255. When the master requests data from a slave, the first byte it sends is the Slave ID. When set to 0, the slave 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 slave 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 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.
 +
 +
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]]
   −
==See also==
+
The new Request Configuration should become visible in the list:
   −
{{Template: Networking_device_modbus_see_also}}
+
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration.png|border|class=tlt-border]]
   −
[[Category:{{{name}}} Services section]]
+
<table class="nd-mantable">
<!--
+
    <tr>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <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>
 +
        <td>Data type</td>
 +
        <td>8bit INT <nowiki>|</nowiki> 8bit UINT <nowiki>|</nowiki> 16bit INT, high byte first <nowiki>|</nowiki> 16bit INT, low byte first <nowiki>|</nowiki> 16bit UINT, high byte first <nowiki>|</nowiki> 16bit UINT, low byte first <nowiki>|</nowiki> 32bit float, Byte order 1,2,3,4 <nowiki>|</nowiki> 32bit float, Byte order 4,3,2,1 <nowiki>|</nowiki> 32bit float, Byte order 2,1,4,3 <nowiki>|</nowiki> 32bit float, Byte order 3,4,1,2; default: <b>16bit INT, high byte first</b></td>
 +
        <td>Defines how read data will be stored.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Function</td>
 +
        <td>Read coils (1) <nowiki>|</nowiki> Read input coils (2) <nowiki>|</nowiki> Read holding registers (3) <nowiki>|</nowiki> Read input registers (4) <nowiki>|</nowiki> Set single coil (5) <nowiki>|</nowiki> Set single coil register (6) <nowiki>|</nowiki> Set multiple coils (15) <nowiki>|</nowiki> Set multiple holding registers (16); default: <b>Read holding registers (3)</b></td>
 +
        <td>Specifies the type of register being addressed by a Modbus request.
 +
        </td>
 +
    </tr>
 +
    <tr>
 +
        <td>First Register</td>
 +
        <td>integer [0..65535]; default: <b>1</b></td>
 +
        <td>First Modbus register from which data will be read.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Register Count / Values</td>
 +
        <td>integer [1..2000]; default: <b>1</b></td>
 +
        <td>Number of Modbus registers that will be read during the request.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>No Brackets</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Removes the starting and ending brackets from the request (only for read requests).</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Delete [ X ]</td>
 +
        <td>- (interactive button)</td>
 +
        <td>Deletes the request.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>off/on slider</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Turns the request on or off.</td>
 +
    </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_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 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.
    +
The figure below is an example of the Modbus Master Alarms list. To create a new Alarm, click the 'Add' button.
   −
==Modbus Data to Server==
+
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_add_button.png|border|class=tlt-border]]
   −
The Modbus <b>Data to Server</b> function provides you with the possibility to set up senders that transfer data collected from Modbus slaves to remote servers. To add a new data sender, enter the server's address, specify the data sending period and click the "Add" button:
+
Then click the 'Edit' button next to the newly created Alarm to configuration.
   −
[[File:Networking_rutx_manual_modbus_add_new_data_sender_v1.png]]
+
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_edit_button.png|border|class=tlt-border]]
   −
===Data sender configuration===
+
After this you should be redirected to that Alarm's configuration page which should look similar to this:
----
  −
When you add a new data sender, you will be redirected to its configuration window. The figure below is an example of that window and the table below provides information on the fields that it contains:
     −
[[File:Networking_rutx_manual_modbus_data_sender_configuration_v1.png]]
+
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_alarm_configuration.png|border|class=tlt-border]]
    
<table class="nd-mantable">
 
<table class="nd-mantable">
 
     <tr>
 
     <tr>
         <th>Enabled</th>
+
         <th>Field</th>
         <th>off | on; default: <b>off</b></th>
+
        <th>Value</th>
         <th>Turns the data sender ON or OFF</th>
+
         <th>Description</th>
 +
    </tr>
 +
    <tr>
 +
        <td>Enabled</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
         <td>Turns the alarm on or off.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Function code</td>
 +
        <td>Read Coil Status (1) <nowiki>|</nowiki> Read Input Status (2) <nowiki>|</nowiki> Read Holding Registers (3) <nowiki>|</nowiki> 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 Master (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#RS485_Slave_Device_Configuration|RS485 Slave Device Configuration]].</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Name</td>
+
         <td>Register</td>
 +
        <td>integer [1..65536]; default: <b>none</b></td>
 +
        <td>Number of the Modbus coil/input/holding-register/input-register to read from.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Condition</td>
 +
        <td>More than <nowiki>|</nowiki> Less than <nowiki>|</nowiki> Equal to <nowiki>|</nowiki> Not Equal to; default: <b>Equal to</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>
 +
        <td>Value</td>
 +
        <td>various; default: <b>none</b></td>
 +
        <td>The value against which the read data will be compared.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Value</td>
 +
        <td>integer [0..65535]; default: <b>none</b></td>
 +
        <td>The value against which the read data will be compared.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Action frequency</td>
 +
        <td>Every trigger <nowiki>|</nowiki> First trigger; default: <b>Every trigger</b></td>
 +
        <td>Describes how frequently the specified action will be taken.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Redundancy protection</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Protection against executing a configured action too often.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Redundancy protection period</td>
 +
        <td>integer [1..86400]; default: <b>none</b></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>
 +
        <td>Action</td>
 +
        <td>SMS <nowiki>|</nowiki> MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
 +
        <td>Action that will be taken if the condition is met. Possible actions:
 +
            <ul>
 +
                <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>
 +
            </ul>
 +
        </td>
 +
    </tr>
 +
    <tr>
 +
        <td><span style="color: #0054a6;">SMS: Message</span></td>
 
         <td>string; default: <b>none</b></td>
 
         <td>string; default: <b>none</b></td>
         <td>Data sender's name. used for easier management purposes</td>
+
         <td>SMS message text.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Protocol</td>
+
         <td><span style="color: #0054a6;">SMS: Phone number</span></td>
         <td>HTTP; default: <b>HTTP</b></td>
+
         <td>phone number; default: <b>none</b></td>
         <td>Data sending protocol</td>
+
         <td>Recipient's phone number.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>JSON format</td>
+
         <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
         <td>json string; default: <b>{"ID":"%i", "TS":"%t","ST":"%s","VR":"%a"}</b></td>
+
         <td>integer [1..30]; default: <b>5</b></td>
         <td>Provides the possibility to fully customize the JSON segment</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 slave ID.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Segment count</td>
+
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; default: <b>1</b></td>
+
         <td>Read Force Single Coil (5) <nowiki>|</nowiki> Preset Single Register (6) <nowiki>|</nowiki> Force Multiple Coils (15) <nowiki>|</nowiki> Force Multiple Registers (16); default: <b>Force Single Coil (5)</b></td>
         <td>Max segment count in one JSON string sent to server</td>
+
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>URL</td>
+
         <td><span style="color: purple;">MODBUS Write Request: First register</span></td>
         <td>host | ip; default: <b>none</b></td>
+
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Address of the server to which the data will be sent.</td>
+
         <td>Begins reading from the register specified in this field.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Period</td>
+
         <td><span style="color: purple;">MODBUS Write Request: Values</span></td>
         <td>integer [1..6400]; default: <b>60</b></td>
+
         <td>integer [0..65535]; default: <b>none</b></td>
         <td>Data sending frequency (in seconds)</td>
+
        <td>Register/Coil values to be written (multiple values must be separated by space character).</td>
 +
    </tr>
 +
</table>
 +
|}}
 +
 
 +
==MQTT Gateway==
 +
 
 +
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]]
 +
 
 +
<table class="nd-mantable">
 +
    <tr>
 +
        <th>Field</th>
 +
        <th>Value</th>
 +
        <th>Description</th>
 +
    </tr>
 +
    <tr>
 +
        <td>Enable</td>
 +
        <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
 +
        <td>Turns MQTT gateway on or off.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Host</td>
 +
        <td>ip <nowiki>|</nowiki> host; default: <b>127.0.0.1</b></td>
 +
        <td>IP address or hostname of an MQTT broker.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Port</td>
 +
        <td>integer [0..65535]; default: <b>1883</b></td>
 +
        <td>Port number of the MQTT broker.</td>
 +
    </tr>
 +
    <tr>
 +
        <td>Request topic</td>
 +
        <td>alphanumeric string; default: <b>request</b></td>
 +
         <td>MQTT topic for sending requests.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Data filtering</td>
+
         <td>Response topic</td>
         <td>All data | By slave ID | By slave IP; default: <b>All data</b></td>
+
         <td>alphanumeric string; default: <b>response</b></td>
         <td>Which data this sender will transfer to the server</td>
+
         <td>MQTT topic for subscribing to responses.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Retry on fail</td>
+
         <td>Username</td>
         <td>off | on; default: <b>off</b></td>
+
         <td>string; default: <b>none</b></td>
         <td>Specifies whether the data sender should retry failed attempts (Retry until successful)</td>
+
         <td>Username for authentication to the MQTT broker.</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
         <td>Custom header</td>
+
         <td>Password</td>
         <td>string; default: <b>off</b></td>
+
         <td>string; default: <b>none</b></td>
         <td>Adds a custom header(s) to HTTP requests</td>
+
         <td>Password for authentication to the MQTT broker.</td>
 
     </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==
 +
 
 +
<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]]

Navigation menu