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
- 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.
- 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. - 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
| # | Need | Sample |
|---|---|---|
| 1 | Write a register and read it back to confirm | 01-single.json |
| 2 | Check a whole block, or several blocks, of addresses at once | 02-segments.json |
| 3 | Check that a gateway forwards data from side A to side B | 03-gateway-*.json |
| 4 | Power the device off and on repeatedly, checking its state after every boot | 04-power-cycle*.json |
| 5 | Write and check a block of addresses in a loop, and find the first 0 | 05-address-scan.json |
| 6 | Read and write floats and longs in the device's byte order | 06-float.json |
| 7 | Have the operator scan a serial number and confirm an LED, with the answers in the report | 07-serial-number.json |
| 8 | Tidy repeated steps into a subroutine | 08-before.json, 08-after.json |
| 9 | Run without a window on a fixture or in CI, and judge the result by exit code | 09-cli.json |
| 10 | A case-by-case walkthrough of the library's Showcase - all features.json | Sample library |
Next steps
- Troubleshooting: devices that do not connect, scripts that do not load, license and update problems
- Script command reference: every field of every command
