Skip to content

Skip truncated ASC frames without losing later messages - #2161

Merged
zariiii9003 merged 1 commit into
hardbyte:mainfrom
Solarboaters:fix/truncated-asc-records
Nov 28, 2026
Merged

zariiii9003 merged 1 commit into
hardbyte:mainfrom
Solarboaters:fix/truncated-asc-records

Conversation

@Solarboaters

@Solarboaters Solarboaters commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2160. Reject payloads shorter than their declared length and skip malformed ASC frame records with a warning containing the offending record. Valid later frames remain readable, and relative timestamp accumulation still includes the skipped record.

Rebased onto main (d81b980). Six truncated-record regressions in TestAscFileFormat fail without the fix and pass with it, including the short CANoe 7.x layout. A separate CAN FD remote-frame control verifies that DataLength, not DLC, determines the required payload size.

Python 3.12/Linux: recording-format suite 150 passed, six skipped; full software suite 690 passed, 126 skipped. Black, Ruff and Pylint pass for the changed code. Type checking is blocked by a syntax error in the optional asammdf dependency. Physical CAN hardware was not tested; this fix operates on recording files.

@zariiii9003

Copy link
Copy Markdown
Collaborator

AI Review: Skip truncated ASC frames without losing later messages

The fix is correct and minimal: payloads shorter than their declared length are rejected, and malformed frame records are skipped with a warning naming the record. This is the consistent handling #2160 asks for. CAN FD remote records stay valid, since Vector "CAN, Log & Trigger ASC Logging Format", v1.4.16, §3.3 sets their <DataLength> to 0.

Requested changes

  • test/logformats_test.py::TestAscFileFormat::test_read_canoe_7_short_fd_layout_raises_value_error (added in Fix ASCReader CANoe 7 CAN FD layouts #2154) fails with this PR ("ValueError not raised"), because short CANoe 7.x records are now skipped. Rebase onto main and replace this test with the skip-with-warning test below, adding 0.000000 CANFD 1 1e3 Rx 1 0 d as a case.
  • test/test_asc_truncated.py: ASCReader is covered by TestAscFileFormat in test/logformats_test.py. Move test_truncated_frame_is_reported_and_following_frame_survives there (parameterized.expand + assertLogs("can.io.asc", "WARNING")) and delete the new file.
  • test_complete_empty_and_remote_records_are_unchanged: the d 0, r 8 and flagged CAN FD data cases duplicate existing ASC tests. Keep only the CAN FD remote case (... 123 0 0 8 0 0 0 10): it is the only test that fails if the length check uses the DLC code instead of DataLength.

Verdict: request changes

@Solarboaters
Solarboaters force-pushed the fix/truncated-asc-records branch from 60f2b35 to 2bf6fc7 Compare November 28, 2026 16:05

Copy link
Copy Markdown
Contributor Author

Rebased onto main and moved the regressions into TestAscFileFormat, including the short CANoe 7.x case; removed the redundant controls and retained the CAN FD remote case. Recording-format tests: 150 passed, 6 skipped; full software suite: 690 passed, 126 skipped. Black/Ruff/Pylint pass; type checking is blocked by a syntax error in the optional asammdf dependency.

@zariiii9003

Copy link
Copy Markdown
Collaborator

AI Review: Skip truncated ASC frames without losing later messages

The fix is correct and minimal. Records whose payload is shorter than their declared length (classic d <DLC>, CANFD <DataLength>, CANoe 7.x layout) are skipped with a warning naming the record, and later records stay readable. Well-formed records parse as on main, and relative timestamps still include the skipped record. The length check matches Vector "CAN, Log & Trigger ASC Logging Format", v1.4.16, §3.3: every CANFD record carries trailing fields after the payload, and §3.3.1 sets <DataLength> to 0 for a classic remote frame logged on a CAN FD channel. Skipping with a warning matches TRCReader. The earlier requests to rebase and to move the tests into TestAscFileFormat are resolved.

Correction to the earlier review

  • The earlier review called test_canfd_remote_record_uses_data_length the only test that fails if the length check uses the DLC code. That was wrong: test_read_classic_remote_message_in_canfd_record (test_CanFdRemoteMessage.asc) fails as well. The new test duplicates it; no action is needed from you.

Verdict: merge

@zariiii9003
zariiii9003 merged commit d94407a into hardbyte:main Nov 28, 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.

ASCReader: truncated frame lines either load silently with missing data or fail with a bare ValueError

2 participants