Test the transmit side against implementations CanLab did not write - #32
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyputs independent, widely used implementations on the other end, all on python-can's in-process virtual bus:id_iso()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
msgpackjoin thedevextras, which CI installs. The testsimportorskipthem.pytest -q: 740 passed on this branch. ruff clean.