Jump to content

Template:Networking rut2 9 modbus custom register block: Difference between revisions

no edit summary
No edit summary
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:
Line 39: Line 39:
  $ 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 77: Line 78:
[[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==
==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>
Line 86: Line 87:
<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]]
[[File:Configuration examples 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