Changes

no edit summary
Line 12: Line 12:  
Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.
 
Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.
   −
This article provides a guide on how to use Modbus TCP to monitor {{{name}}} routers with a PC using a Linux Operating System. However, the same principles apply to RUTXxx and TRBxx family devices, but the holding register information will differ. You can find this information in the links below:
+
This article provides a guide on how to use Modbus TCP to monitor {{{name}}} routers with a PC using a Linux Operating System.
*'''[[RUTXR1 Monitoring via Modbus]]'''
  −
*'''[[RUTX12 Monitoring via Modbus]]'''
  −
*'''[[RUTX11 Monitoring via Modbus]]'''
  −
*'''[[RUTX10 Monitoring via Modbus]]'''
  −
*'''[[RUTX09 Monitoring via Modbus]]'''
  −
*'''[[RUTX08 Monitoring via Modbus]]'''
  −
*'''[[TRB245 Monitoring via Modbus]]'''
  −
*'''[[TRB255 Monitoring via Modbus]]'''
  −
*'''[[TRB140 Monitoring via Modbus]]'''
  −
*'''[[TRB141 Monitoring via Modbus]]'''
  −
*'''[[TRB142 Monitoring via Modbus]]'''
  −
*'''[[TRB145 Monitoring via Modbus]]'''
   
==Configuring the router==
 
==Configuring the router==
    
In order to start using Modbus TCP, we must first configure the router. Modbus TCP configuration from the router's side is very simple. All you need to do is log in to the router's WebUI, go to '''Services → Modbus''', '''Enable''' the Modbus TCP service, enter a '''Port''' number through which the Modbus TCP communication will take place and '''Allow remote access''' if you wish to connect to the router remotely (from WAN).
 
In order to start using Modbus TCP, we must first configure the router. Modbus TCP configuration from the router's side is very simple. All you need to do is log in to the router's WebUI, go to '''Services → Modbus''', '''Enable''' the Modbus TCP service, enter a '''Port''' number through which the Modbus TCP communication will take place and '''Allow remote access''' if you wish to connect to the router remotely (from WAN).
   −
[[File:Networking_rutos_manual_modbus_modbus_tcp_slave_v2.png]]
+
[[File:Networking_rutos_manual_modbus_modbus_tcp_slave.png|border|class=tlt-border]]
    
==Installing the necessary software==
 
==Installing the necessary software==
Line 42: Line 30:  
Modbus TCP can be used to both '''get''' and '''set''' certain router parameters. First lets do an overview of how to obtain parameters via Modbus TCP. Please keep in mind that in order to get routers parameters when using '''[https://wiki.teltonika-networks.com/view/{{{name}}}_Modbus#Requests_configuration Request Configuration]''' you need to use '''Register Number''' instead of '''Register Address'''.{{#ifeq:RUTX12| RUTX12| To get data from the second modem, you need to execute this command:
 
Modbus TCP can be used to both '''get''' and '''set''' certain router parameters. First lets do an overview of how to obtain parameters via Modbus TCP. Please keep in mind that in order to get routers parameters when using '''[https://wiki.teltonika-networks.com/view/{{{name}}}_Modbus#Requests_configuration Request Configuration]''' you need to use '''Register Number''' instead of '''Register Address'''.{{#ifeq:RUTX12| RUTX12| To get data from the second modem, you need to execute this command:
   −
  $  modbus write -D 192.168.1.1 %MW328  12589 12590 12800
+
  $  modbus write -D {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW328  12589 12590 12800
    
This command sets it to primary modem:
 
This command sets it to primary modem:
   −
  $ modbus write -D 192.168.1.1 %MW328  13101 12544
+
  $ modbus write -D {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW328  13101 12544
    
}}
 
}}
Line 59: Line 47:  
|analog = {{{analog}}}
 
|analog = {{{analog}}}
 
|gps = {{{gps}}}
 
|gps = {{{gps}}}
 +
|dualsim = {{{dualsim}}}
 
}}
 
}}
   Line 79: Line 68:  
For the first example, lets use a modbus read command to attempt to obtain the router's uptime value in seconds. If you look back at the table above, you will see that the uptime value is stored in two registers starting from the first register, therefore:
 
For the first example, lets use a modbus read command to attempt to obtain the router's uptime value in seconds. If you look back at the table above, you will see that the uptime value is stored in two registers starting from the first register, therefore:
   −
  $ modbus read -w -p 12345 192.168.1.1 %MW001 2
+
  $ modbus read -w -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW001 2
    
'''-w''' specifies the data type. In this case, unsigned 16 bit integers.
 
'''-w''' specifies the data type. In this case, unsigned 16 bit integers.
Line 85: Line 74:  
'''-p''' specifies the port number.
 
'''-p''' specifies the port number.
   −
'''192.168.1.1''' - the router's LAN IP address.
+
'''{{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}}''' - the router's LAN IP address.
    
'''%MW001''' specifies the register address.
 
'''%MW001''' specifies the register address.
Line 116: Line 105:  
Lets examine a different, more complex example by issuing a request for the router's '''WAN IP address'''. If you look at the '''[[Monitoring_via_Modbus#List_of_parameters|table]]''' above, you will see that the WAN IP address value is contained within the 139th and 140th registers. Therefore, we should specify the 139th address and read 2 registers from that address:
 
Lets examine a different, more complex example by issuing a request for the router's '''WAN IP address'''. If you look at the '''[[Monitoring_via_Modbus#List_of_parameters|table]]''' above, you will see that the WAN IP address value is contained within the 139th and 140th registers. Therefore, we should specify the 139th address and read 2 registers from that address:
   −
  $ modbus read -w -p 12345 192.168.1.1 %MW139 2
+
  $ modbus read -w -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW139 2
    
[[File:Configuration examples modbus wan ip v2.png]]
 
[[File:Configuration examples modbus wan ip v2.png]]
Line 155: Line 144:  
Some values like Hostname, Router name, Network type are represented as text in their original form, but are stored in registers as numbers. You can interpret these values the same way as all discussed before (by converting them to binary and then to text), but a simpler way would be to get them in '''hexadecimal''' form and then convert them to text. To do so, we'll have to add the '''-D''' parameter to the command. Lets do it by asking for the router's Hostname:
 
Some values like Hostname, Router name, Network type are represented as text in their original form, but are stored in registers as numbers. You can interpret these values the same way as all discussed before (by converting them to binary and then to text), but a simpler way would be to get them in '''hexadecimal''' form and then convert them to text. To do so, we'll have to add the '''-D''' parameter to the command. Lets do it by asking for the router's Hostname:
   −
  $ modbus read -D -w -p 12345 192.168.1.1 %MW007 16
+
  $ modbus read -D -w -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW007 16
    
[[Image:Configuration examples modbus hostname example v2.png]]
 
[[Image:Configuration examples modbus hostname example v2.png]]
Line 165: Line 154:  
==Setting router values==
 
==Setting router values==
   −
The Modbus daemon also supports the setting of some system parameters. To accomplish this task the '''modbus write''' command is used. System related parameters and how to use them are described below. The register address specifies from which register to start writing the required values. All commands, except “Change APN”, accepts only one input parameter {{#ifeq:{{{mobile}}}|1|(more on changing APN can be found below)}}.
+
The Modbus daemon also supports the setting of some system parameters. To accomplish this task the '''modbus write''' command is used. System related parameters and how to use them are described below. The register address specifies from which register to start writing the required values. All commands, except “Change APN”, accepts only one input parameter {{#ifeq:{{{mobile}}}|1|(more on changing APN can be found below)}}.  
<table class="nd-othertables">
+
{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table
    <tr>
+
|wifi={{{wifi}}}
        <th width="350">value to set</th>
+
|mobile={{{mobile}}}
      <th width="180">register address</th>
+
|series={{{series}}}
      <th width="150">register value</th>
+
|name={{{name}}}
      <th width="466">description</th>
  −
    </tr>
  −
{{#ifeq:{{{wifi}}}|1|
  −
    <tr>
  −
      <td>Switch WiFi ON/OFF</td>
  −
      <td>203</td>
  −
      <td>1 {{!}} 0</td>
  −
        <td>Turns WiFi ON or OFF</td>
  −
    </tr>
  −
}}
  −
{{#ifeq:{{{mobile}}}|1|
  −
    <tr>
  −
      <td>Switch mobile data connection (ON/OFF<span class="asterisk">*</span>)</td>
  −
      <td>204</td>
  −
      <td>1 {{!}} 0</td>
  −
        <td>Turns mobile data connection ON or OFF</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Switch SIM card</td>
  −
      <td>205</td>
  −
      <td>1 {{!}} 2 {{!}} 0</td>
  −
        <td>Changes the active SIM card slot
  −
            <ul>
  −
                <li>1 - switch to SIM1</li>
  −
                <li>2 - switch to SIM2</li>
  −
    <li>0 - switch from the the SIM card opposite of the one currently in use (SIM1 → SIM2 or SIM2 → SIM1</li>
  −
            </ul>
  −
</td>
  −
    </tr>
  −
}}
  −
    <tr>
  −
    <td>Reboot</td>
  −
        <td>206</td>
  −
        <td>1</td>
  −
        <td>Reboots the router</td>
  −
    </tr>
  −
{{#ifeq:{{{mobile}}}|1|
  −
    <tr>
  −
    <td>Change APN</td>
  −
        <td>207</td>
  −
        <td>APN code</td>
  −
        <td>Changes APN. <br> The number of input registers may vary depending on the length of the APN, but the very first byte of the set APN command denotes the number of the SIM card for which to set the APN. This byte should be set to:
  −
            <ul>
  −
                <li>1 - to set APN for SIM1</li>
  −
                <li>2 - to set APN for SIM2</li>
  −
    </ul>
  −
        </td>
  −
    </tr>
  −
}}
  −
{{#switch:{{{series}}}
  −
|RUTX= {{#ifeq:{{{name}}}| RUTXR1||
  −
    <tr>
  −
      <td> Switch PIN 4 state </td>
  −
      <td>325</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Toggles PIN 4 ON or OFF, when output is selected</td>
  −
  </tr>
  −
}}
  −
|
  −
    <tr>
  −
      <td> Switch PIN 3 state </td>
  −
      <td>324</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Toggles PIN 3 ON or OFF, when output is selected</td>
  −
  </tr>
  −
    <tr>
  −
      <td> Switch PIN 4 state </td>
  −
      <td>325</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Toggles PIN 4 ON or OFF, when output is selected</td>
  −
  </tr>
  −
}}
  −
{{#ifeq:{{{series}}}|TRB2XX|
  −
    <tr>
  −
      <td> Switch PIN2 state </td>
  −
      <td>336</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Toggles PIN 2 ON or OFF, when output is selected</td>
  −
  </tr>
  −
}}
  −
 
  −
{{#ifeq:{{{name}}}|TRB141|
  −
    <tr>
  −
      <td> Switch relay state </td>
  −
      <td>337</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Turns Relay ON or OFF</td>
  −
  </tr>
  −
    <tr>
  −
      <td> Switch latching relay state </td>
  −
      <td>338</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Turns latching relay ON or OFF</td>
  −
  </tr>
  −
    <tr>
  −
      <td>Switch PIN 1 (Dry/Wet) state</td>
  −
      <td>343</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Switches PIN 1 state to 0 (dry) / 1 (wet)</td>
  −
  </tr>
  −
    <tr>
  −
      <td>Switch PIN 2(Dry/Wet) state</td>
  −
      <td>344</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Switches PIN 2 state to 0 (dry) / 1 (wet)</td>
  −
  </tr>
  −
    <tr>
  −
      <td> Switch ACL ON/OFF </td>
  −
      <td>345</td>
  −
      <td>1{{!}}0</td>
  −
      <td>Turns ACL functionality ON or OFF</td>
  −
  </tr>
   
}}
 
}}
</table>
  −
   
{{#ifeq:{{{wifi}}}|1|
 
{{#ifeq:{{{wifi}}}|1|
 
As you can see most of the values are '''0''' and '''1''', 0 meaning OFF and 1 meaning ON. For example, if you want to turn '''WiFi OFF''', this command should be used:
 
As you can see most of the values are '''0''' and '''1''', 0 meaning OFF and 1 meaning ON. For example, if you want to turn '''WiFi OFF''', this command should be used:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW203 0
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW203 0
    
If you want to turn '''WiFi ON''', use this command instead:
 
If you want to turn '''WiFi ON''', use this command instead:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW203 1
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW203 1
 
}}
 
}}
 
{{#ifeq:{{{mobile}}}|1|
 
{{#ifeq:{{{mobile}}}|1|
Line 300: Line 175:  
In the case of '''SIM switch''' there are three values - '''0''', '''1''' and '''2'''. 1 makes the first SIM card slot in use, 2 makes the second SIM card slot in use and 0 initiates a switc from the SIM card in use to the opposite SIM card. For example, to initiate a switch to the second SIM card the command should look like this:
 
In the case of '''SIM switch''' there are three values - '''0''', '''1''' and '''2'''. 1 makes the first SIM card slot in use, 2 makes the second SIM card slot in use and 0 initiates a switc from the SIM card in use to the opposite SIM card. For example, to initiate a switch to the second SIM card the command should look like this:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW205 2
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW205 2
    
The '''reboot''' function only takes one value: '''1'''. It simply reboots the router. To initiate a reboot, use this command:
 
The '''reboot''' function only takes one value: '''1'''. It simply reboots the router. To initiate a reboot, use this command:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW206 1
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW206 1
    
===APN===
 
===APN===
Line 312: Line 187:  
As an example lets try to change the router's first SIM card's APN to '''gprs.fix-ip.omnitel1.net''':
 
As an example lets try to change the router's first SIM card's APN to '''gprs.fix-ip.omnitel1.net''':
   −
  $ modbus write -w -D -p 12345 192.168.1.1 %MW207 <span style="color:blue">'''1'''</span> <span style="color:green">'''103 112 114 115 46 102 105 120 45 105 112 46 111 109 110 105 116 101 108 49 46 110 101 116'''</span>
+
  $ modbus write -w -D -p 12345 {{#ifeq:{{{series}}}|TRB14X|192.168.2.1|192.168.1.1}} %MW207 <span style="color:blue">'''1'''</span> <span style="color:green">'''103 112 114 115 46 102 105 120 45 105 112 46 111 109 110 105 116 101 108 49 46 110 101 116'''</span>
    
The value of the first byte is highlighted in <span style="color:blue">'''blue'''</span> and, in this case, it denotes that the APN value should be changed for the first SIM card. The value of the APN string itself is highlighted in <span style="color:green">'''green'''</span>. Use an ASCII to Decimal online converter to convert individual letters to Decimal code.
 
The value of the first byte is highlighted in <span style="color:blue">'''blue'''</span> and, in this case, it denotes that the APN value should be changed for the first SIM card. The value of the APN string itself is highlighted in <span style="color:green">'''green'''</span>. Use an ASCII to Decimal online converter to convert individual letters to Decimal code.
Line 322: Line 197:  
**http://www.unit-conversion.info/
 
**http://www.unit-conversion.info/
 
**http://www.binaryhexconverter.com/
 
**http://www.binaryhexconverter.com/
 +
 +
[[Category:{{{name}}} Configuration Examples]]

Navigation menu