Bitbus Slave Loopback Demo
This demo runs a Bitbus slave and a simulated master on one IOU13 (Bitbus Slave Variant) with bbslave firmware. The sniffer function block sends the master's frames, and the slave function block responds. Internal loopback connects them without an external Bitbus connection.
Complete the setup guide first and note the slave and sniffer endpoints of your module.
Demo Software
The setup guide describes how to install the tools and get the demo software. Start in the io4edge-client-go repository root on your development PC. The source is available in the Bitbus slave loopback example.
Compile Demo
Run this in a powershell console
cd examples\bitbusslave\loopback
$Env:GOOS = "linux"
$Env:GOARCH = "arm64"
go build
cd examples/bitbusslave/loopback
GOOS=linux GOARCH=arm64 go build
This produces the binary file loopback in the current folder.
Copy Demo to Moducop
Transfer the compiled binary. Replace <target-ip> with the IP address of your Moducop.
We copy the binary to the /data folder of ModuCop, as this is a writeable, whereas the rest of the filesystem is write protected.
scp loopback root@<target-ip>:/data
Running the Demo
Login into your Moducop over SSH:
ssh root@<target-ip>
Once logged in into the Moducop's Shell, run the demo.
In case your IOU13 (Bitbus Slave Variant) is not in the slot next to the CPU, use a different address, e.g. S101-IOU13 (Bitbus Slave Variant)-USB-EXT-2-bbslave
Pass the slave endpoint first and the sniffer endpoint second. Use the service names reported by your scan for both function blocks on the same module:
/data/loopback S101-IOU13-USB-EXT-1-bbslave S101-IOU13-USB-EXT-1-bitbus
Alternatively, pass IP addresses and ports in the same order. Replace the example endpoints with those reported by io4edge-cli scan -f:
/data/loopback 192.168.201.1:10002 192.168.201.1:10001
Expected Behavior
The demo configures:
| Setting | Value |
|---|---|
| Baud rate of both function blocks | 375000 baud |
| Sniffer sender | Enabled |
| Internal loopback | Enabled; external Bitbus activity disabled |
| Full duplex | Enabled so the receiver also captures local transmissions |
| Sniffer address filter | All addresses |
| Slave address | 1 |
| Application watchdog | 5000 ms |
| Idle response information field | One byte, 00 |
The simulated master establishes the connection with DISC/SNRM. It sends master message every 500 ms and polls between messages. The application prepares slave message every 200 ms when no previous message is pending. The demo checks sequence numbers, acknowledges slave messages, and prints the slave status once per second.
Typical output includes:
Master received: "slave message"
Slave received: "master message"
Slave status: nrm, pending TX=false
The order of messages and pending-TX status can vary. You may also see Master received: "\x00" when the slave returns its idle response.
Stop the Demo
Press Ctrl+C to stop the streams and close both clients. An exchange already in progress can take up to three seconds to finish.
The device remains configured for loopback after the program exits. Before using an external Bitbus, upload a sniffer configuration with WithLoopbackEnable(false) and the baud rate, receive filters, and duplex setting required by your bus. See the detailed Bitbus description.
Troubleshooting
- If a connection fails, verify the endpoints, their order, and network reachability from the demo host. Use
IP:portif service-name resolution is unavailable. - If configuration is rejected or the slave service is missing, verify that the transmit-capable module runs compatible
bbslavefirmware and that your io4edge client supports the Bitbus slave API. - If the demo reports no slave response, verify that both endpoints belong to the same module and that another application is not changing its configuration.