Skip to content

Showcase walkthrough ​

The library's Showcase - all features.json shows almost every feature in 7 cases. It is written for "write on side A, read back on side B through a gateway": channel A connects to 127.0.0.100:502, channel B to 127.0.0.101:502, and the gateway maps 0x0000 on A to 0x9000 on B.

Running it on this PC ​

A listener on 127.0.0.1 only accepts connections made to 127.0.0.1, so create two more listeners in the Slave window:

  1. Add a device with Device → Add Device, then use Device → Edit Device... to set its Listen IP to 127.0.0.100 and TCP Port to 502.
  2. In this device's Slave ID row on the right, click + to add ID 1 (a new device does not start with Slave ID 1).
  3. Click Listen.
  4. Create 127.0.0.101:502 the same way.

The two Slaves do not forward data to each other, so most reads on side B FAIL. That is expected; the walkthrough below points out which steps need a real gateway.

Showcase result (case 01)

Run on this PC, the result is PASS 2, FAIL 5.

Case by case ​

CaseFeatures shownResult on this PC
01 Main · gateway A to BWait Until for the device to come online (compare: false, 3000 ms); FC16 and FC06 writes on A, read back on B; Wait Until after the writes for the value to appear on B; If checks the gateway status on B against a range, giving Verdict PASS if it holds, otherwise Call fail_path then Verdict FAILFAIL: B cannot read the values A wrote
02 Compare · == != range formatEvery kind of compare: == with tolerance, !=, range, float_abcd, a signed range, long_abcd; stores B's firmware word in fw and checks the version with an If expressionFAIL: the Slave does not hold these values
03 Write · FC6 / FC16 / FC15FC16 multiple registers, FC06, values as float_cdab, FC15 writing 8 coils at once; read back on B with FC03 and FC02FAIL: needs gateway forwarding
04 Loop · Set / While / RepeatA While with an lhs/op/rhs condition writes 8 addresses; a Repeat reads them back on B into got; an If checks the last valueFAIL: needs gateway forwarding
05 Call · subroutine with parametersThe check_window subroutine (parameters addr, lo, hi, the last two with defaults) checks whether three addresses are in range, returning 1 or 0, summed into okFAIL: the values on B are 0, out of range
06 Operator · AskAsk text scans a serial number, Ask pass_fail confirms an LED, Ask number takes a measured voltage, then an If checks the voltage is within 23.5–24.5 VPASS (run in the GUI and answered)
07 Flow · End Round / End CaseWarm-up check: when 0x0311 == 1, End Round with discard, so the round does not count; when the gateway status changes, End Case skips the rest of the casePASS

Showcase case 06: operator answers

The Actual column of case 06 shows the three answers, sn = SN-2611-0042, operator: PASS and v24 = 24.1, followed by the If's check v24=24.1: true.

Turning it into your own test ​

  • Change channel_a and channel_b to the IP, port and Slave ID of the real device and gateway.
  • Change the addresses on side B (from 0x9000) to match the gateway's mapping table.
  • Delete cases you do not need; disable steps you do not need by selecting them and pressing Ctrl+/.

Download the sample script ​

Sample script

This is the same script as in the sample library, and the one the product site offers for download. Before running it, create the two listeners described in "Running it on this PC" above.

Roach Modbus Tool by Mr.Roach