Monitoring via Modbus: Difference between revisions

From Teltonika Networks Wiki
No edit summary
Line 26: Line 26:
  $ sudo apt-get install ruby
  $ sudo apt-get install ruby
  $ sudo gem instal modbus-cli
  $ sudo gem instal modbus-cli
==Getting router parameters==
Modbus TCP can be used to both '''get''' and '''set''' certain router parameters. First lets do an overview of how to get parameters via Modbus TCP.
===List of parameters===
Router parameters are held within '''registers'''. Each register contains 2 bytes of information. For simplification the number of registers for storing numbers is 2, while the number of registers for storing text information is 16. The register numbers and corresponding system values are described below:
{| class="wikitable"
|+
! style="width: 425px; background: black; color: white;"  | Required value
! style="width: 425px; background: black; color: white;"  | Representation
! style="width: 425px; background: black; color: white;"  | Register number
! style="width: 425px; background: black; color: white;"  | Number of registers
|-
! style="text-align: left; vertical-align: top;" | System uptime
| style="text-align: left; vertical-align: top;" | 32 bit unsigned integer
| 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;" | 32 bit integer
| 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 Celcium
| style="text-align: left; vertical-align: top;" | 32 bit integer
| 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;" | Text
| 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;" | Text
| 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;" | Text
| 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;" | Text
| 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;" | Text
| 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;" | Text
| 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;" | Text
| 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;" | Text
| 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 1
| style="text-align: left; vertical-align: top;" | 32 bit integer
| style="text-align: left; vertical-align: top;" | 135
| style="text-align: left; vertical-align: top;" | 2
|-
! style="text-align: left; vertical-align: top;" | Digital input
| style="text-align: left; vertical-align: top;" | 32 bit integer
| 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;" | 32 bit unsigned integer
| 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;" | 32 bit integer
| style="text-align: left; vertical-align: top;" | 141
| style="text-align: left; vertical-align: top;" | 2
|-
|}
===modbus read===
To obtain parameters from the system, the '''modbus read''' command is used.

Revision as of 10:13, 6 December 2017

Router monitoring via Modbus TCP Linux guide applies to RUT950 and RUT955 routers.

Summary

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,
  • openly published and royalty-free,
  • easy to deploy and maintain,
  • 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.

This chapter is a guide on how to use Modbus TCP to monitor RUT950 and RUT955 routers using a Linux Operating System.

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).

Installing the necessary software

Next you'll need software capable of communicating via Modbus TCP. The software that we'll be using in this guide is called modbus-cli. To get it you'll first have to install ruby:

$ sudo apt-get install ruby
$ sudo gem instal modbus-cli

Getting router parameters

Modbus TCP can be used to both get and set certain router parameters. First lets do an overview of how to get parameters via Modbus TCP.

List of parameters

Router parameters are held within registers. Each register contains 2 bytes of information. For simplification the number of registers for storing numbers is 2, while the number of registers for storing text information is 16. The register numbers and corresponding system values are described below:

Required value Representation Register number Number of registers
System uptime 32 bit unsigned integer 1 2
GSM signal strength (dBm) 32 bit integer 3 2
System temperature in 0.1 degrees Celcium 32 bit integer 5 2
System hostname Text 7 16
GSM operator name Text 23 16
Router serial number Text 39 16
Router MAC address Text 55 16
Router name Text 71 16
Current SIM card Text 87 16
Network registration Text 103 16
Network type Text 119 16
Digital input 1 32 bit integer 135 2
Digital input 32 bit integer 137 2
Current WAN IP address 32 bit unsigned integer 139 2
Analog input 32 bit integer 141 2

modbus read

To obtain parameters from the system, the modbus read command is used.