Skip to content

Command-line runs ​

Need: run a script on a test fixture, on a schedule or in CI, without opening a window, judge the result by exit code, and produce a report.

About the example: it has two cases, Write and read and Status.

Syntax ​

text
RoachModbusTool --run-script <script.json> [--report <report.xlsx or .csv>] [--loops N] [--case <case name>] [--log <log.txt>]
OptionMeaning
--run-scriptThe script to run (required)
--reportWrite a report after the run. The .xlsx or .csv extension picks the format
--loops NRun N rounds, overriding the script's setting
--case nameRun only this case in each round
--log fileAlso write the console output to a text file

It needs a valid license or trial, and the license must include the Script feature.

Exit codes ​

Exit codeMeaningTested
0Release PASS09-cli.json with the Slave running
1A FAIL, SKIP or DISCONNECT (Release BLOCKED)Run with the Slave stopped: both cases DISCONNECT
2Could not run: file missing or malformed, serial port would not open, a Slave channel could not listen, or a bad optionMissing file, a script with goto, --loops x
3Not licensed (for Script, or for RTU needed by a serial channel)—

Getting the exit code on Windows ​

The app is a Windows GUI program, so Command Prompt and PowerShell do not wait for it to finish by default. Wait for it explicitly:

bat
start /wait "" RoachModbusTool.exe --run-script 09-cli.json --report out.xlsx
echo %ERRORLEVEL%
powershell
$p = Start-Process RoachModbusTool.exe -ArgumentList '--run-script 09-cli.json --report out.xlsx' `
     -Wait -PassThru -NoNewWindow
$p.ExitCode

In a batch file:

bat
start /wait "" RoachModbusTool.exe --run-script 09-cli.json --report out.xlsx
if %ERRORLEVEL%==0 (echo PASS) else (echo NOT PASS: %ERRORLEVEL%)

On Linux, the AppImage is an ordinary command-line program:

bash
./RoachModbusTool-x86_64.AppImage --run-script 09-cli.json --report out.xlsx; echo $?

Output ​

The run log and a final summary line go to standard output (UTF-8). Actual output (the user name in the log folder path is masked):

text
Opened 09-cli.json
Loaded Channel A/B from file
Roach Modbus Tool 1.3.3 - running ...\05-script-examples\09-cli.json
Starting...
Log file folder: C:\Users\<name>\AppData\Local\Mr.Roach\Roach Modbus Tool\script_logs
Firmware: examples
On error: Skip remaining
Loop: 1
A ON - Master TCP 127.0.0.1:502  Slave ID 1    B OFF
Connected A
Running 2 case(s) x 1 loop(s)
Running case 1/2: Write and read
15:27:29.857  [Write and read #3, loop 1]  0x0500 = 4660
Finished case 1/2: Write and read  PASS
Running case 2/2: Status
Finished case 2/2: Status  PASS
Write and read: PASS
  A 0x0500 = 0x1234 (expect 0x1234)
Status: PASS
  A 0x0501 = 0x0000 (expect 0x0000)
Done
PASS 2 - FAIL 0 - SKIP 0 - DISCONNECT 0 - Release PASS

When the device does not respond (exit code 1), it ends with:

text
Write and read: DISCONNECT
  A 0x0500 write failed: comm fail: connect failed: connection refused
  skip: on_error skip
Status: DISCONNECT
  A 0x0501 read failed: comm fail: connect failed: connection refused
Done
PASS 0 - FAIL 0 - SKIP 0 - DISCONNECT 2 - Release BLOCKED

--run-script 09-cli.json --case Status runs only Status:

text
Running case 2/2: Status
Finished case 2/2: Status  PASS
...
PASS 1 - FAIL 0 - SKIP 0 - DISCONNECT 0 - Release PASS

CSV report ​

What --report out.csv --loops 3 produces (excerpt):

text
Firmware,examples
Loops,3
Test cases,2
PASS,6
FAIL,0
SKIP,0
DISCONNECT,0
Release,PASS

loop,time,test_name,verdict
1,2026-11-25 15:27:49,Write and read,PASS
1,2026-11-25 15:27:49,Status,PASS
2,2026-11-25 15:27:49,Write and read,PASS
...

loop,time,case,step,action,channel,function,start,end,actual,expected,verdict,detail,response_ms
1,2026-11-25 15:27:49,Write and read,1,write,A,6,1280,1280,,,PASS,,0.1
1,2026-11-25 15:27:49,Write and read,2,read,A,3,1280,1280,0x1234,0x1234,PASS,v = 4660,0.0
1,2026-11-25 15:27:49,Write and read,3,log,,0,0,0,,,PASS,0x0500 = 4660,
...

The CSV has three parts in order: the summary, each case's result, and each step's result. The start and end columns are decimal addresses (1280 = 0x0500).

Notes

  • There is no operator: Pause steps are logged and skipped, and Ask steps always FAIL. Run scripts with Ask in the GUI, or use --case to run only cases without Ask.
  • A TCP device that is not responding when the run starts does not abort the run: every step that communicates connects again, and steps without a response are judged DISCONNECT. To wait for a device to boot, make the first step a Wait Until (compare: false).
  • A script with goto, or a main_case that is not the first case, is refused (exit code 2) with an explanation of how to fix it.

Download the sample script ​

Sample script

Start a Slave window on 127.0.0.1:502 and click Listen, then run it with the command-line syntax above.

Roach Modbus Tool by Mr.Roach