Repository navigation
Conversation
candump writes an error frame as CAN_ERR_FLAG plus the error class bits, followed by the error data bytes. The reader only recognised the bus error class, so a controller problem (20000004#...) or bus off frame was read as an extended data frame, and a bus error frame lost its channel, direction and data bytes. Test CAN_ERR_FLAG alone and keep the class bits in arbitration_id, as the SocketCAN interface does, together with the data bytes, channel and direction. The writer now writes the message's error class instead of always writing the bus error class, so an error frame round-trips.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary of Changes
CanutilsLogReadertreats acandump -Lline as an error frame only when bothCAN_ERR_FLAG(0x20000000) andCAN_ERR_BUSERROR(0x80) are set. Every other error class, such as a controller problem (0x04) or bus off (0x40), is read as an extended data frame.can.logconvertwrites a controller-problem frame (0x04) as an ASC data frame instead ofErrorFrame.can.playerwithout--error-framestransmits that frame onto the bus as a data frame. For bus error frames,CanutilsLogReaderdropschannel, direction,dlc, and the 8 data bytes.CanutilsLogWriteralso ignoresarbitration_idon error frames and always writes the bus error class.In
can/io/canutils.py,CanutilsLogReadernow setsis_error_frame=bool(can_id & CAN_ERR_FLAG), which is howcan/interfaces/socketcan/socketcan.pyand can-utils'log2ascrecognise an error frame. The reader builds oneMessagefor every frame line. Error frames keep their class bits inarbitration_id, as the SocketCAN interface does, along with the data bytes,dlc,channeland direction.CanutilsLogWriternow encodes error frame IDs asCAN_ERR_FLAG | (msg.arbitration_id & 0x1FFFFFFF)while keepingCAN_ERR_BUSERRORdefined.Input (
err.log):Before (
main):After:
TestCanutilsFileFormatintest/logformats_test.pynow includestest_read_error_framesandtest_write_error_frame_class.test_read_error_framesverifies thatCanutilsLogReaderpreserves class, data, and channel on candump error lines.test_write_error_frame_classverifies that an error frame with class0x204writes as20000204#0004000000000102and reads back equal. Both tests fail onmainand pass after the change. The existing shared error-frame round-trip fixtures continue to pass.Additional checks:
CAN_ERR_FLAG, empty-data bus errors, andR/Tsuffixes) fail onmainand pass after the change.0x00000080) read identically onmainand after the change..logto.logwithcan.logconvert, comes back line for line apart from the writer'sRdirection suffix. Onmainits two bus error frames come back asvcan0 20000080#, without channel or data bytes. Its ASC conversion is the same onmainand after the change, apart from the generated date header.Related Issues / Pull Requests
Type of Change
Checklist
tox).Additional Notes
Compatibility:
Message(is_error_frame=True)or an ASCErrorFrame, is now written as20000000#instead of20000080#. can-utils'log2ascreads it as an error frame. Older python-can releases read it as a data frame with ID0, as they already do for every candump error frame withoutCAN_ERR_BUSERROR.arbitration_id, andCanutilsLogWriterwrites its low 29 bits afterCAN_ERR_FLAGas the error class.python-canreleases now reads back witharbitration_idequal toCAN_ERR_BUSERROR.Local checks (macOS):
pytest test/logformats_test.py(Python 3.12, withoutasammdf): 85 passed, 18 skipped; 83 passed onmain.tox -e type(Python 3.14 environment): passed (mypy 3.11 to 3.15).tox -e lint:blackandruffpassed;pylintreports only fiveselectno-member messages (epoll,EPOLLIN,EPOLLOUT) incan/interfaces/socketcan/socketcan.py, identical onmainon macOS.tox -e py: 505 passed, 36 failed; the same 36 tests (24 PCAN, 6 UDP multicast, 5 TRC, 1 SocketCAN capture) fail onmainon macOS.