Repository navigation
Fix ASCReader CANoe 7 CAN FD layouts - #2154
Merged
Merged
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Collaborator
AI Review: ASCReader support for CANoe 7.x CAN FD layout (#2154)Context
Findings
Tests
Verdictrequest changes |
Handle remote and error frames, reject malformed short records, merge the CANoe regressions, and use the PR-number changelog filename. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Collaborator
AI Review: ASCReader support for CAN FD records with the identifier before the direction (#2154)Context
Findings
Recommended changesOn top of 2660e0c. With these changes --- a/can/io/asc.py
+++ b/can/io/asc.py
@@ def _process_fd_can_frame(self, line: str, msg_kwargs: dict[str, Any]) -> Message:
fields = line.split()
- if len(fields) >= 4 and fields[1] not in ("Rx", "Tx"):
+ if len(fields) >= 4 and fields[1] not in ("Rx", "Tx", "TxRq"):
@@
rest = fields[3:]
- if rest and rest[0].lower() == "errorframe":
- msg_kwargs["is_error_frame"] = True
- return Message(**msg_kwargs)
if len(rest) < 3:
raise ValueError(f"Malformed CAN FD message: {line}")
@@
if marker not in ("d", "r"):
raise ValueError(f"Malformed CAN FD message: {line}")
- msg_kwargs["is_fd"] = True
- msg_kwargs["bitrate_switch"] = brs == "1"
- msg_kwargs["error_state_indicator"] = esi == "1"
-
if marker == "r":
if len(rest) < 4:
raise ValueError(f"Malformed CAN FD remote frame: {line}")
- dlc_code = int(rest[3], 10)
+ msg_kwargs["is_fd"] = False
msg_kwargs["is_remote_frame"] = True
- msg_kwargs["dlc"] = dlc2len(dlc_code)
- msg_kwargs["data"] = bytearray()
+ msg_kwargs["dlc"] = min(8, int(rest[3], self._converted_base))
return Message(**msg_kwargs)
+ msg_kwargs["bitrate_switch"] = brs == "1"
+ msg_kwargs["error_state_indicator"] = esi == "1"
+
if len(rest) < 5:--- a/test/logformats_test.py
+++ b/test/logformats_test.py
@@ def test_read_canoe_7_can_fd_layout(self):
"0.001000 CANFD 1 1e3 Rx 1 0 d 13 32 " + " ".join(["00"] * 32) + "\n"
- "0.002000 CANFD 1 100 Tx 1 0 r 8 Length = 1704000\n"
+ "0.002000 CANFD 1 100 Tx 1 0 r f Length = 1704000\n"
+ "0.003000 CANFD 1 TxRq 1 0 0 1 1 01\n"
)
with can.ASCReader(stream) as reader:
- data, large, remote = reader
+ data, large, remote, txrq = reader
@@
- self.assertTrue(remote.is_fd)
+ self.assertFalse(remote.is_fd)
+ self.assertFalse(remote.bitrate_switch)
self.assertTrue(remote.is_remote_frame)
self.assertEqual(remote.arbitration_id, 0x100)
self.assertFalse(remote.is_rx)
self.assertEqual(remote.dlc, 8)
self.assertEqual(remote.data, b"")
+ self.assertEqual(txrq.arbitration_id, 0x1)
+ self.assertFalse(txrq.is_rx)
+
@@
- def test_read_canoe_7_fd_error_frame(self):
- stream = StringIO(
- "base hex timestamps absolute\n"
- "0.000000 CANFD 5 Tx ErrorFrame "
- "Not Acknowledge error, dominant error flag\n"
- )
- with can.ASCReader(stream) as reader:
- (actual,) = reader
-
- self.assertTrue(actual.is_error_frame)
- self.assertEqual(actual.channel, 4)
-Verdictrequest changes |
Keep TxRq on the standard CAN FD layout path, parse CANoe 7 remote frames as classic remote frames, and constrain DLC 9-F to classic DLC 8. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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
ASCReadersupport for CANoe 7.x CAN FD records whose field order is<channel> <id> <Rx|Tx>.Related Issues / Pull Requests
Type of Change
Checklist
Additional Notes
This fix also removes the need for an application-level CANoe 7.x fallback in CanVouch.