Skip to content

serial: do not read a payload for remote frames - #2151

Merged
zariiii9003 merged 3 commits into
hardbyte:mainfrom
DanShinde:serial-remote-frame-dlc
Nov 26, 2026
Merged

zariiii9003 merged 3 commits into
hardbyte:mainfrom
DanShinde:serial-remote-frame-dlc

Conversation

@DanShinde

Copy link
Copy Markdown
Contributor

Summary of Changes

  • SerialBus.send() writes a remote frame with its DLC (the requested length) and no payload, but _recv_internal() read DLC payload bytes for every frame. A remote frame with DLC > 0 therefore ate the end-of-frame byte and the start of the next frame, and recv() failed with TypeError: ord() expected a character once the port ran dry. Reproducible with SerialBus("loop://") and Message(is_remote_frame=True, dlc=8).
  • _recv_internal() now reads no payload when the RTR flag is set. The existing remote frame test only used DLC 0; the new test sends DLC 1 and 8 through the mock and loop:// buses.
  • The serial frame docs now say how remote frames are encoded.

Related Issues / Pull Requests

  • None found.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Other (please describe):

Checklist

  • I have followed the contribution guide.
  • I have added or updated tests as appropriate.
  • I have added or updated documentation as appropriate.
  • I have added a news fragment for towncrier.
  • All checks and tests pass (tox).

send() writes a remote frame with its DLC (the requested length) but no
payload. _recv_internal() then read DLC payload bytes, so a remote frame
with DLC > 0 swallowed the end-of-frame byte and the following frame,
and recv() failed with TypeError.

Read no payload for remote frames and document the encoding.
@zariiii9003

Copy link
Copy Markdown
Collaborator

AI Review: serial: do not read a payload for remote frames

The fix is correct. send() has never written a payload for remote frames, so the receive path skipping the payload makes the two sides consistent. On main, a remote frame with DLC > 0 raises TypeError and corrupts the frame that follows it; with this PR, both frames are received correctly. Reverting the fix makes the new test fail on both the mock and loop:// buses.

Requested changes

  • doc/interfaces/serial.rst, frame format table: the DLC description still reads "Length in byte of the payload", which contradicts the new paragraph for remote frames. Change it to e.g. "Payload length; requested data length for remote frames".
  • test/serial_test.py: fold test_rx_tx_rtr_frame_with_dlc into the existing test_rx_tx_rtr_frame as a loop over dlc in (0, 8). The receive path has no DLC-dependent branch for remote frames, so DLC 1 exercises the same code as DLC 8.

Verdict

request changes

@zariiii9003 zariiii9003 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@zariiii9003
zariiii9003 merged commit 0593b11 into hardbyte:main Nov 26, 2026
28 checks passed
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.

2 participants