Gateway forwarding
Need: test a gateway (or protocol converter). Write on one side and read back on the other to confirm the data got through.
The library's A to B single.json is the typical form:
{ "write": { "channel": "A", "function": 6, "address": "0x0000", "value": "0x00AA" } },
{ "wait": { "ms": 100 } },
{ "read": { "channel": "B", "function": 3, "address": "0x9000", "expected": "0x00AA" } }This assumes the gateway maps 0x0000 on side A to 0x9000 on side B. Change the addresses to match your gateway's mapping. The B to A … series works the other way round: write 0x0000 on B and read it back from 0x9000 on A.
Practising without a gateway
Slave mode does not forward data, so two separate Slaves cannot simulate a gateway. To practise, connect both channels A and B to the same Slave: A writes, and B reads back at the same address.
Both channels are 127.0.0.1:502, with Connection → Same line: B uses A turned on (same_line: true in JSON) so B shares A's connection. This option is required when A and B connect to the same IP and port; without it, the run stops beforehand with Channel A and B use the same IP:port, but Same line is off..
| Case | What it does |
|---|---|
| A to B single | A writes 0x0000 = 0x00AA, B reads 0x0000 |
| B to A single | B writes 0x0001 = 0x00BB, A reads 0x0001 |
| A to B consecutive | A writes 0x0010..0x001A = 0x00CC, B reads all 11 back |

Channel B on the left shows Same port as A. All three cases PASS.
What a gateway that does not forward looks like
This script uses the library's original A to B single, but A connects to 127.0.0.1:502 and B to 127.0.0.1:503 (Slave ID 2), simulating two devices that cannot reach each other. Before running it, add a second device in the Slave window: Device → Add Device, then change its TCP Port to 503 in Device → Edit Device..., and click Listen.

The write on A succeeds, but 0x9000 on B reads 0x0000, so the step FAILs and the overall result is Release BLOCKED. Seeing this on a real gateway means the data did not reach the other side: check the gateway's mapping table, the Slave IDs and the connection settings on both sides.
Notes
- The Wait after the write matters: gateways usually poll downstream devices on a schedule, so data takes a while to appear on the other side. If the delay varies, replace the Read with Wait Until to wait until the value appears.
- If B gets DISCONNECT rather than FAIL, side B is not responding (wrong connection or Slave ID); the problem is not the forwarding.
Download the sample scripts
Sample scripts
03-gateway-practice.json only needs a Slave on 127.0.0.1:502. 03-gateway-no-forward.json also needs 127.0.0.1:503 (Slave ID 2), set up as described above. See How to use the examples.
