Skip to content

Implicit I O

Ralf Steinert edited this page Nov 15, 2026 · 1 revision

Class 1 I/O in two minutes, then what goes wrong in practice.

Run a drive

$ pip install enip-sim
$ enip-sim serve drive &
enip-sim: drive: ethernet/ip 127.0.0.1:44818 (udp 2222), control on :44819
  enip-sim drive
$ enip-sim io --out 0100f401 --rpi 20 --seconds 3      # run forward, 50.0 Hz
enip-sim: drive I/O open (run, RPI 20 ms), O->T 0x20000001, T->O 0x31389027
  0.000 s  in 02000000  status 0x0002 (ready), speed 0.0 Hz
  0.040 s  in 03000500  status 0x0003 (running, ready), speed 0.5 Hz
  0.101 s  in 03000a00  status 0x0003 (running, ready), speed 1.0 Hz
  ...
enip-sim: 151 input packets in 3 s

The output assembly (instance 20) is the logic command (bit 0 run forward, bit 1 run reverse, bit 2 fault reset) and the speed reference in 0.1 Hz; the input assembly (70) is the status word (running, ready, faulted, at reference, reverse) and the actual speed. enip-sim info drive lists them.

From Python

from enip_sim import EnipClient

with EnipClient("127.0.0.1", 44818) as c:
    with c.open_io(output_instance=20, input_instance=70, config_instance=1,
                   output_size=4, input_size=4, rpi_ms=20) as io:
        io.set_outputs(b"\x01\x00\xf4\x01")
        io.run()
        io.wait_for_inputs(lambda d: d[2:] == b"\xf4\x01", timeout=15)

io.idle() clears the run bit: the drive holds its outputs. Leaving the with block sends Forward_Close.

What your scanner has to get right

These are the rejections you would also meet at commissioning; the simulator answers them the way the specification says (general status 0x01 plus the extended status):

you see cause fix
0x0109, additional e.g. 8 connection size wrong; the number is what the device expects O→T size = output assembly + 2 (sequence count) + 4 (run/idle header); T→O = input assembly + 2
0x0117 unknown connection point drive: O→T 20, T→O 70; io-block: 101 / 100; input-only: O→T 198
0x0118 wrong configuration instance drive 1, io-block 102
0x0108 multicast or null connection type, or 16-bit parameters in a Large_Forward_Open point-to-point; in Large_Forward_Open the type sits in bits 30–29
0x0111 RPI below 10 ms 10 ms or slower
0x0106 another exclusive owner holds the outputs close it, or open input-only
0x0100 same connection serial / vendor / originator serial still open Forward_Close first, or a new serial

Inject the failures a running line shows:

enip-sim inject connection_timeout        # the device stops producing; your scanner times out
enip-sim inject io_loss every=3           # every 3rd input packet is lost
enip-sim inject trip code=7               # the drive faults; status bit 2 in the inputs
enip-sim clear

Troubleshooting

No input packets arrive. The device sends T→O to the address your TCP session comes from, to the port named in your Forward_Open's T→O sockaddr item, else 2222. A firewall that drops incoming UDP to that port stops it; so does NAT between scanner and simulator.

Outputs are ignored. O→T must come from the same IP address as the TCP session, with the run bit set (io.run()), and with exactly the output assembly's size.

Docker. With Docker Engine on Linux, -p 44818:44818 -p 2222:2222/udp works (the CI checks it). Docker Desktop runs containers in a VM, and the device's UDP packets back to the host do not arrive — run the simulator with pip there.

The scanner listens on UDP 2222 itself on the same machine (EIPScanner does): start the simulator on another UDP port, enip-sim serve drive --io-port 2223. The Forward_Open reply carries an O→T sockaddr item with that port, so the scanner sends there.

Timeouts on macOS. macOS stretches short timers: on GitHub's macOS runners a 20 ms wait took 40–86 ms (median). Use a timeout multiplier of 2 or more there.

Clone this wiki locally