Add opt-in CAN-FD support to can_core/can_node (untested on hardware) - #192
Draft
wilsonchenghy wants to merge 3 commits into
Draft
Add opt-in CAN-FD support to can_core/can_node (untested on hardware)#192wilsonchenghy wants to merge 3 commits into
wilsonchenghy wants to merge 3 commits into
Conversation
Adds CANFD_MTU/canfd_frame send+receive path, CAN_RAW_FD_FRAMES socket opt-in, and enable_can_fd/data_bitrate params -- gated behind enable_can_fd (default false) so classic-CAN/SLCAN behavior is unchanged unless explicitly turned on with a CAN-FD-capable adapter. setupSlcan() refuses enable_can_fd=true since SLCAN can't carry FD frames. Not validated against real hardware -- no CAN-FD adapter or arm available in this session. Needs bench testing before use in any control loop. See can/README.md and issue #189.
4 tasks
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
Adds real CAN-FD support to
can_core/can_node, gated behind an opt-inenable_can_fdparam (defaultfalse) so today's classic-CAN/SLCAN behavior is unchanged unless someone explicitly turns it on with CAN-FD-capable hardware. Closes the gap described in #189 (this repo currently has a deaddata_bitratefield with no actual FD wiring behind it).can_core.hpp:CanMessagegainsis_fd/fd_bitrate_switch;CanConfiggainsenable_fd(documented as opt-in/unvalidated) and clarifiesdata_bitrate's current scope.can_core.cpp:setupSocketCan()now opts the raw socket intoCAN_RAW_FD_FRAMESbeforebind()whenenable_fdis set.sendMessage()branches to build/write acanfd_frame(up to 64 data bytes,CANFD_BRSfor bitrate-switch) whenmessage.is_fd, otherwise unchanged classic-frame path.receiveMessage()reads into acan_frame/canfd_frameunion sized for the larger type, and distinguishes which one arrived by the byte countread()returns.setupSlcan()now explicitly refusesenable_fd=truerather than silently ignoring it — SLCAN (Lawicel ASCII protocol) can't carry FD frames.can_node.cpp: declares/wiresenable_can_fdanddata_bitrateparams through toCanConfig; hard-refuses to start (rather than silently degrading) ifenable_can_fd=trueis combined withbustype=slcan.params.yaml/can/README.md: document the new params and the hardware prerequisite.Explicitly NOT done here
gs_usb/candleLight-firmware adapter) before relying onenable_can_fd: truenear the motors — see thereal-hardware-safetyskill.motorCMDCallbackcontrol-mode logic — this is transport-layer only, all messages still fit in ≤8 bytes today, so FD's wider payload isn't being used yet, only its potential bitrate/timing headroom.ros2_control/MoveIt2 migration — that's a separate, larger gap from matching OpenArm's stack (tracked separately, not in scope here).Test plan
enable_can_fd: true+bustype: socketcanagainst a real CAN-FD-capable adapter, confirmcandump -xshows FD frames on the busenable_can_fd: true+bustype: slcanfails fast with the new error rather than misbehavingenable_can_fd: false) is bit-for-bit unchanged behavior vs. before this PRreal-hardware-safetyskill)Rollout plan (staged, not part of this PR)
This PR is step 1 of 3. Steps 2 and 3 are deliberately separate PRs, not bundled here:
enable_can_fd: trueagainst real CAN-FD hardware (new adapter required — the CANable/SLCAN setup cannot do FD), a follow-up PR changesparams.yaml's defaults (bustype: socketcan,enable_can_fd: true) so CAN-FD becomes the active path.setupSlcan(), thebustype=="slcan"branch,scripts/setup_can.sh, and the CANable-specific bring-up docs, leaving CAN-FD/SocketCAN as the only path. Tracked as a separate issue so it isn't forgotten, but intentionally not drafted as code yet — deleting the current working fallback before step 2 is validated would remove the safety net during the exact period it's needed.