Skip to content

Script examples ​

Every screen and result here was checked by running it on the v1.3.3 (Windows) Release build.

The earlier chapters introduced the commands one at a time. This chapter starts from real test needs instead: each example goes through the need, how the script is written, what the run shows, and what to watch out for. Case names and messages in the examples are in English, and that is the text you see on screen.

If you are not yet familiar with the commands, keep the Script command reference at hand.

How to use the examples ​

  1. The sample scripts can be downloaded from the end of each example page. The script files include their connection settings, so they run as soon as you open them.
  2. Open one Roach Modbus Tool window, switch to Slave mode and click Listen (default 127.0.0.1:502, Slave ID 1). The few examples that need more listeners say so on their page.
  3. Open a second window, switch to Script, click Open JSON to open the example, then click Run.

Scripts in the sample library (the scripts folder in the app folder) only hold steps, without connection settings, so they use whatever channel settings are on screen when opened. The examples here are those library scripts with 127.0.0.1 connection settings added, so you can run them without real hardware.

Contents ​

#NeedSample
1Write a register and read it back to confirm01-single.json
2Check a whole block, or several blocks, of addresses at once02-segments.json
3Check that a gateway forwards data from side A to side B03-gateway-*.json
4Power the device off and on repeatedly, checking its state after every boot04-power-cycle*.json
5Write and check a block of addresses in a loop, and find the first 005-address-scan.json
6Read and write floats and longs in the device's byte order06-float.json
7Have the operator scan a serial number and confirm an LED, with the answers in the report07-serial-number.json
8Tidy repeated steps into a subroutine08-before.json, 08-after.json
9Run without a window on a fixture or in CI, and judge the result by exit code09-cli.json
10A case-by-case walkthrough of the library's Showcase - all features.jsonSample library

Next steps ​

Roach Modbus Tool by Mr.Roach