Skip to content

Test the transmit side against implementations CanLab did not write - #32

Merged
Sherin-SEF-AI merged 1 commit into
mainfrom
test/interop
Sep 23, 2026
Merged

Sherin-SEF-AI merged 1 commit into
mainfrom
test/interop

Conversation

@Sherin-SEF-AI

@Sherin-SEF-AI Sherin-SEF-AI commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Why

Every ISO-TP, UDS and J1939 transport test paired CanLab with a responder written in this repository. If both misread the standard the same way, they would agree and still be wrong. tests/test_interop.py puts independent, widely used implementations on the other end, all on python-can's in-process virtual bus:

Library Role Result
can-isotp 2.0.7 an ISO 15765-2 ECU a 100-byte answer reassembled; a 63-byte request arrives intact under its flow control (block size 4, STmin 5 ms)
udsoncan 1.26.1 ISO 14229 encoding and parsing every request CanLab sends is byte-for-byte udsoncan's encoding; DTC decoding matches udsoncan's id_iso()
can-j1939 2.0.12 two J1939-21 nodes a real RTS/CTS session (RTS, 15 CTS, EOM ACK) and a BAM, reassembled by CanLab through its hub byte-identical to what the receiving node got; nothing sent

No recording in the corpus contains an RTS/CTS session, so this is the first test of that path against anything but frames built here.

The defect it found

ISO 15765-2 STmin is the minimum gap between two consecutive frames. CanLab slept only within a block, so the first consecutive frame after each flow control left 0.12 ms after the previous one; the tap's timestamps show it. An ECU that asked for STmin because its receive buffer is slow would drop that frame. Every consecutive frame is now timed against the one before it, whatever arrived in between; no extra delay is added when the flow-control round trip already exceeded STmin.

Dependencies

The three libraries (all MIT) and msgpack join the dev extras, which CI installs. The tests importorskip them.

pytest -q: 740 passed on this branch. ruff clean.

Every ISO-TP, UDS and J1939 transport test paired CanLab with a
responder written in this repository, so a shared misreading of the
standard would pass. tests/test_interop.py puts widely used independent
implementations on the other end, on python-can's virtual bus:

- can-isotp as the ECU: a 100-byte answer is reassembled, and a 63-byte
  request arrives intact under its flow control (block size 4).
- udsoncan: every request CanLab sends is byte-for-byte what udsoncan
  encodes, and CanLab's DTC decoding matches udsoncan's id_iso().
- can-j1939: two nodes hold a real RTS/CTS session and a BAM broadcast
  while CanLab listens through its hub; both are reassembled identical
  to what the receiving node got, and nothing is sent. No recording in
  the corpus contains RTS/CTS, so this is its first independent test.

It found a defect. ISO-TP STmin is the gap between two consecutive
frames, but CanLab slept only within a block, so the first frame after
each flow control left 0.1 ms after the previous one; can-isotp's
timestamps showed it. Every consecutive frame is now timed against the
one before, whatever arrived between them.

The three libraries (all MIT) join the dev extras; the tests skip
without them.
@Sherin-SEF-AI
Sherin-SEF-AI merged commit f95a604 into main Sep 23, 2026
2 checks passed
@Sherin-SEF-AI
Sherin-SEF-AI deleted the test/interop branch September 23, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant