Changes

no edit summary
Line 22: Line 22:     
Script which would log certain data into Modbus register. To add new <b>script</b>, connect to the device via <b>SSH</b> and use:
 
Script which would log certain data into Modbus register. To add new <b>script</b>, connect to the device via <b>SSH</b> and use:
  $ vi /bin/extramodbus (where extramodbus here could be any name)
+
  $ vi /bin/extramodbus (this script is for this manual purpose, yours might be different)
    
Insert following <b>script</b> (this script is for this manual purpose, yours might be different) example:
 
Insert following <b>script</b> (this script is for this manual purpose, yours might be different) example:
 
+
{{#switch:{{{name}}}
 +
|RUTX10=
 +
<pre>
 +
#!/bin/ash
 +
while true
 +
do
 +
date > /tmp/regfile  #where data will be stored
 +
df | awk 'NR==3 {print $3}' >> /tmp/regfile
 +
df | awk 'NR==4 {print $3}' >> /tmp/regfile
 +
sleep 5
 +
done
 +
</pre>
 +
|RUTX08=
 +
<pre>
 +
#!/bin/ash
 +
while true
 +
do
 +
date > /tmp/regfile  #where data will be stored
 +
df | awk 'NR==3 {print $3}' >> /tmp/regfile
 +
df | awk 'NR==4 {print $3}' >> /tmp/regfile
 +
sleep 5
 +
done
 +
</pre>
 +
|
 +
<pre>
 
  #!/bin/ash
 
  #!/bin/ash
 
  while true
 
  while true
Line 34: Line 58:  
  sleep 5
 
  sleep 5
 
  done
 
  done
 
+
</pre>
 +
}}
 
After saving change execution rights with this command:
 
After saving change execution rights with this command:
    
  $ chmod +x /bin/<scriptname> #example: chmod +x /bin/extramodbus
 
  $ chmod +x /bin/<scriptname> #example: chmod +x /bin/extramodbus
   −
Then you need to run your script to start loggin data to <b>regfile</b>, to start script simple write <script name> & example:
+
Run the script to start logging data to regfile, to do that simply type in your terminal: <script name> &.
 +
For example:
    
  $ extramodbus &
 
  $ extramodbus &
Line 45: Line 71:  
And script will run in the background.
 
And script will run in the background.
   −
With this script we will be able to get routers local time and couple 3G signal values each 5 seconds.
+
With this script we will be able to get routers local time and couple {{#switch:{{{name}}}
 +
|RUTX10= DF application |RUTX08= DF application | GSM}} values each 5 seconds.
 
Data stored in <b>regfile (cat /tmp/regfile)</b> looks like this:
 
Data stored in <b>regfile (cat /tmp/regfile)</b> looks like this:
 +
{{#switch:{{{name}}}
 +
|RUTX10=
 +
<pre>
 +
Wed Jun 17 15:11:29 EEST 2020
 +
69
 +
27
 +
</pre>
 +
|RUTX08=
 +
<pre>
 +
Wed Jun 17 15:11:29 EEST 2020
 +
69
 +
27
 +
</pre>
 +
|
 +
<pre>
 +
Wed Jun 17 15:11:29 EEST 2020
 +
-69
 +
27
 +
</pre>
 +
}}
   −
Wed Jun 17 15:11:29 EEST 2020
  −
-69
  −
27
      
To view collected data in HEX execute this command via SSH:  
 
To view collected data in HEX execute this command via SSH:  
Line 61: Line 105:  
  0000025
 
  0000025
   −
==Reading Created Custom Modbus Registers==
+
==Reading Created Custom Modbus Registers with Modbus TCP Master==
    
To read data via Modbus you can use:
 
To read data via Modbus you can use:
Line 70: Line 114:     
With Modbus TCP master you can read data just by using ASCII data type and interactive test button.  
 
With Modbus TCP master you can read data just by using ASCII data type and interactive test button.  
 +
{{#switch:{{{series}}}
 +
|RUT9XX = [[File:Configuration examples modbus tcp master test.png|border|class=tlt-border]]
 +
|RUT2XX = [[File:Configuration examples modbus tcp master test.png|border|class=tlt-border]]
 +
|RUTX  = [[File:Configuration examples rutx modbus tcp master test.png|border|class=tlt-border]]
 +
|TRB1  = [[File:Configuration examples trb1 modbus tcp master test.png|border|class=tlt-border]]
 +
|TRB2  = [[File:Configuration examples rutx modbus tcp master test.png|border|class=tlt-border]]
 +
}}
   −
[[File:Configuration examples modbus tcp master test.png|border|class=tlt-border]]
      
To determine how many registers to specify in the '''Register count/Values''' field you should divide character count by two. For example, if you have 28 characters you should input  14 to '''Register count/Values''' field.
 
To determine how many registers to specify in the '''Register count/Values''' field you should divide character count by two. For example, if you have 28 characters you should input  14 to '''Register count/Values''' field.
    
[[File:Configuration_examples_modbus_register_count.png|border|class=tlt-border]]
 
[[File:Configuration_examples_modbus_register_count.png|border|class=tlt-border]]
 
+
==Reading Created Custom Modbus Registers with ComTestPro==
For example purpose we will be using <b>ComTestPro</b> program, which allows us to get Modbus data from device in <b>Hex</b>. So in order to get <b>date</b> from the router by reading <b>custom Modbus registers</b> we need to use following configuration:
+
For this example we will be using <b>ComTestPro</b> program, which allows us to get Modbus data from device in <b>Hex</b>. So in order to get <b>date</b> from the router by reading <b>custom Modbus registers</b> we need to use following configuration:
 
<ul>
 
<ul>
 
<li>Protocol: Modbus TCP;</li>
 
<li>Protocol: Modbus TCP;</li>
<li>IP Address: 192.168.3.1 (routers LAN or WAN IP);</li>
+
<li>IP Address: 192.168.{{#ifeq:{{{series}}}|TRB1|2|1}}.1 (routers LAN or WAN IP);</li>
 
<li>Port: 502 (port number on which Modbus TCP Slave is listening);</li>
 
<li>Port: 502 (port number on which Modbus TCP Slave is listening);</li>
 
<li>Device: 1</li>
 
<li>Device: 1</li>
Line 86: Line 136:  
<li>Registers: 14 (registers lenght).</li>
 
<li>Registers: 14 (registers lenght).</li>
 
</ul>
 
</ul>
With this configuration you should get routers <b>date</b> in <b>hex</b>. Below is the example of configuration and what answer do we get from the router:
+
With this configuration you should get routers <b>date</b> in <b>hex</b>. Below is the example of configuration and what reply we get from the router:  
   −
[[File:Configuration examples modbus comtest pro.png|border|class=tlt-border]]
+
{{#switch:{{{series}}}
 +
|RUT9XX = [[File:Configuration examples rutx modbus comtest pro.png|border|class=tlt-border]]
 +
|RUT2XX = [[File:Configuration examples rutx modbus comtest pro.png|border|class=tlt-border]]
 +
|RUTX  = [[File:Configuration examples rutx modbus comtest pro.png|border|class=tlt-border]]
 +
|TRB1  = [[File:Configuration examples trb1 modbus comtest pro.png|border|class=tlt-border]]
 +
|TRB2  = [[File:Configuration examples rutx modbus comtest pro.png|border|class=tlt-border]]
 +
}}
   −
And as you can see we received answer in <b>hex</b> which is:
+
And as you can see we received a reply in hex:  
    
  5468 7520 4A75 6C20 3330 2031 313A 3539 3A30 3820 5554 4320 3230 3230  
 
  5468 7520 4A75 6C20 3330 2031 313A 3539 3A30 3820 5554 4320 3230 3230  
   −
And by using certain websites, like this one: '''[https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ online hex converter]''' and there we can analyze the data, and by entering the received <b>hex</b> we can see the routers <b>date</b> which in <b>ASCII</b> is:
+
By using certain websites, like this: '''[https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ hex converter]''' we can analyze the data by entering the received hex reply. After conversion we can see the routers date which in <b>ASCII</b> is:  
    
  Thu Jul 30 11:59:08 UTC 2020
 
  Thu Jul 30 11:59:08 UTC 2020

Navigation menu