Changes

4,635 bytes removed ,  14:00, 30 April 2020
no edit summary
Line 1: Line 1:  
Router monitoring via Modbus TCP Linux guide applies to RUT950 and RUT955 routers.[[File:Configuration examples modbus logo.png|right|300px]]
 
Router monitoring via Modbus TCP Linux guide applies to RUT950 and RUT955 routers.[[File:Configuration examples modbus logo.png|right|300px]]
   −
==Summary==
+
==Introduction==
    
'''Modbus''' is a serial communications protocol originally published by Modicon (now Schneider Electric) in 1979 for use with its programmable logic controllers (PLCs). Modbus has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. The main reasons for the use of Modbus in the industrial environment are:
 
'''Modbus''' is a serial communications protocol originally published by Modicon (now Schneider Electric) in 1979 for use with its programmable logic controllers (PLCs). Modbus has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. The main reasons for the use of Modbus in the industrial environment are:
   −
* developed with industrial applications in mind,
+
*developed with industrial applications in mind,
* openly published and royalty-free,
+
*openly published and royalty-free,
* easy to deploy and maintain,
+
*easy to deploy and maintain,
* moves raw bits or words without placing many restrictions on vendors.
+
*moves raw bits or words without placing many restrictions on vendors.
    
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 chapter is a guide on how to use Modbus TCP to monitor RUT950 and RUT955 routers using a Linux Operating System.
+
This article provides a guide on how to use Modbus TCP to monitor RUT955 routers with a PC using a Linux Operating System. However, the same principles apply to RUT230, RUT240 and RUT950 routers, but the holding register information will differ. You can find this information in the links below:
 +
 
 +
*'''[[RUT230 Modbus]]'''
 +
*'''[[RUT240 Modbus]]'''
 +
*'''[[RUT950 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 → Mobdus''', '''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:Services modbus.PNG]]
      +
[[File:Services modbus v2.PNG]]
    
==Installing the necessary software==
 
==Installing the necessary software==
Line 27: Line 29:     
  $ sudo apt-get install ruby
 
  $ sudo apt-get install ruby
  $ sudo gem instal modbus-cli
+
  $ sudo gem install modbus-cli
    
==Getting router parameters==
 
==Getting router parameters==
   −
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.  
+
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/RUT955_Modbus#Requests_configuration Request Configuration]''' you need to use '''Register Number''' instead of '''Register Address'''.
    
===List of parameters===
 
===List of parameters===
 
----
 
----
Router parameters are held within '''registers'''. Each register contains 2 bytes of information. For simplification the number of registers for storing numerical values is 2, while the number of registers for storing text information is 16. The register numbers and corresponding system values are described in the table below:
+
Router parameters are held within '''registers'''. Each register contains 2 bytes of information. For simplification the number of registers for storing numerical values is 2, while the number of registers for storing text information is 16. The register addresses and corresponding system values are described in the table below:
   −
{| class="wikitable"
+
{{Template: Networking_rut955_manual_modbus_modbus_tcp_get_parameters_table}}
|+
  −
! style="width: 355px; background: black; color: white;"  | Required value
  −
! style="width: 135px; background: black; color: white;"  | Register number
  −
! style="width: 162px; background: black; color: white;"  | Number of registers
  −
|-
  −
! style="text-align: left; vertical-align: top;" | System uptime
  −
| style="text-align: left; vertical-align: top;" | 1
  −
| style="text-align: left; vertical-align: top;" | 2
  −
|-
  −
! style="text-align: left; vertical-align: top;" | GSM signal strength (dBm)
  −
| style="text-align: left; vertical-align: top;" | 3
  −
| style="text-align: left; vertical-align: top;" | 2
  −
|-
  −
! style="text-align: left; vertical-align: top;" | System temperature in 0.1 degrees Celcius
  −
| style="text-align: left; vertical-align: top;" | 5
  −
| style="text-align: left; vertical-align: top;" | 2
  −
|-
  −
! style="text-align: left; vertical-align: top;" | System hostname
  −
| style="text-align: left; vertical-align: top;" | 7
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | GSM operator name
  −
| style="text-align: left; vertical-align: top;" | 23
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Router serial number
  −
| style="text-align: left; vertical-align: top;" | 39
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Router MAC address
  −
| style="text-align: left; vertical-align: top;" | 55
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Router name
  −
| style="text-align: left; vertical-align: top;" | 71
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Current SIM card
  −
| style="text-align: left; vertical-align: top;" | 87
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Network registration
  −
| style="text-align: left; vertical-align: top;" | 103
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Network type
  −
| style="text-align: left; vertical-align: top;" | 119
  −
| style="text-align: left; vertical-align: top;" | 16
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Digital input
  −
| style="text-align: left; vertical-align: top;" | 135
  −
| style="text-align: left; vertical-align: top;" | 2
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Digital galvanically isolated input
  −
| style="text-align: left; vertical-align: top;" | 137
  −
| style="text-align: left; vertical-align: top;" | 2
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Current WAN IP address
  −
| style="text-align: left; vertical-align: top;" | 139
  −
| style="text-align: left; vertical-align: top;" | 2
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Analog input
  −
| style="text-align: left; vertical-align: top;" | 141
  −
| style="text-align: left; vertical-align: top;" | 2
  −
|-
  −
|}
      
===modbus read===
 
===modbus read===
Line 109: Line 45:  
To obtain parameters from the system, the '''modbus read''' command is used. The syntax for this command is:
 
To obtain parameters from the system, the '''modbus read''' command is used. The syntax for this command is:
   −
  $ modbus read [OPTIONS] HOST_NAME REGISTER_NUMBER NUMBER_OF_REGISTERS
+
  $ modbus read [OPTIONS] HOST_NAME REGISTER_ADDRESS NUMBER_OF_REGISTERS
    
'''OPTIONS''' can describe things like data type, port number, type of addressing, etc.  
 
'''OPTIONS''' can describe things like data type, port number, type of addressing, etc.  
Line 115: Line 51:  
'''HOST_NAME''' is the router's hostname or IP address (WAN IP, if you are connecting remotely).
 
'''HOST_NAME''' is the router's hostname or IP address (WAN IP, if you are connecting remotely).
   −
'''REGISTER_NUMBER''' specifies the register that you wish to read.
+
'''REGISTER_ADDRESS''' specifies the register that you wish to read.
   −
'''NUMBER_OF_REGISTERS''' specifies how many registers should be read starting from the register specified in '''REGISTER_NUMBER'''.
+
'''NUMBER_OF_REGISTERS''' specifies how many registers should be read starting from the register specified in '''REGISTER_ADDRESS'''.
    
'''Note:''' all of this information and more can be viewed by executing these commands in The Linux Terminal: '''modbus read -h''' or '''modbus read --help'''.
 
'''Note:''' all of this information and more can be viewed by executing these commands in The Linux Terminal: '''modbus read -h''' or '''modbus read --help'''.
Line 131: Line 67:  
'''192.168.1.1''' - the router's LAN IP address.
 
'''192.168.1.1''' - the router's LAN IP address.
   −
'''%MW001''' specifies the register number.
+
'''%MW001''' specifies the register address.
    
'''2''' - specifies how many registers should be read.
 
'''2''' - specifies how many registers should be read.
Line 209: Line 145:  
==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 number specifies from which register to start writing the required values. All commands, except “Change APN”, accepts only one input parameter (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 (more on changing APN can be found below).   
   −
{| class="wikitable"
+
{{Template: Networking_rut955_manual_modbus_modbus_tcp_set_parameters_table}}
|+
  −
! style="width: 425px; background: black; color: white;"  | Value to set
  −
! style="width: 425px; background: black; color: white;"  | Description
  −
! style="width: 425px; background: black; color: white;"  | Register number
  −
! style="width: 425px; background: black; color: white;"  | Register value
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Digital open collector output (on/off)
  −
| style="text-align: left; vertical-align: top;" | Change the state of the digital output number 1
  −
| style="text-align: left; vertical-align: top;" | 201
  −
| style="text-align: left; vertical-align: top;" | 1/0
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Digital relay output (on/off)
  −
| style="text-align: left; vertical-align: top;" | Change the state of the digital output number 2
  −
| style="text-align: left; vertical-align: top;" | 202
  −
| style="text-align: left; vertical-align: top;" | 1/0
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Switch WiFi (on/off)
  −
| style="text-align: left; vertical-align: top;" | Allows to switch WiFi on or off
  −
| style="text-align: left; vertical-align: top;" | 210
  −
| style="text-align: left; vertical-align: top;" | 1/0
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Switch mobile data connection (on/off)
  −
| style="text-align: left; vertical-align: top;" | Turns mobile data connection on or off
  −
| style="text-align: left; vertical-align: top;" | 211
  −
| style="text-align: left; vertical-align: top;" | 1/0
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Switch SIM card (SIM1, SIM2, SIM1->SIM2 and SIM2->SIM1)
  −
| style="text-align: left; vertical-align: top;" | Allows to change SIM card in use, 3 possible options are supported
  −
| style="text-align: left; vertical-align: top;" | 212
  −
| style="text-align: left; vertical-align: top;" | 0/1/2
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Change APN
  −
| style="text-align: left; vertical-align: top;" | Allows to change APN
  −
| style="text-align: left; vertical-align: top;" | 213
  −
| style="text-align: left; vertical-align: top;" | APN code
  −
|-
  −
! style="text-align: left; vertical-align: top;" | Reboot
  −
| style="text-align: left; vertical-align: top;" | Reboots the router
  −
| style="text-align: left; vertical-align: top;" | 220
  −
| style="text-align: left; vertical-align: top;" | 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 '''Wi-Fi 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 %MW210 0
+
  $ modbus write -w -p 12345 192.168.1.1 %MW203 0
   −
If you want to turn '''Wi-Fi 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 %MW210 1
+
  $ modbus write -w -p 12345 192.168.1.1 %MW203 1
    
As you can see, the only difference is the digit at the end - '''0 for OFF''', '''1 for ON'''. The same is true for all other parameters that accept only two input values.
 
As you can see, the only difference is the digit at the end - '''0 for OFF''', '''1 for ON'''. The same is true for all other parameters that accept only two input values.
Line 267: Line 161:  
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 %MW212 2
+
  $ modbus write -w -p 12345 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 %MW220 1
+
  $ modbus write -w -p 12345 192.168.1.1 %MW206 1
    
===APN===
 
===APN===
Line 279: Line 173:  
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 %MW213 <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 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 285: Line 179:  
==External links==
 
==External links==
   −
Online unit converters:
+
*Online unit converters:
 
+
**http://www.unit-conversion.info/
* http://www.unit-conversion.info/
+
**http://www.binaryhexconverter.com/
* http://www.binaryhexconverter.com/
 
0

edits