Claude/socanmatic issue 1 patches 7cgu4r - #2
Open
saulrh wants to merge 2 commits into
Open
Conversation
Implements the profiles requested in issue golems#1, alongside the existing DS301 (communication) and DS402 (drives) support. New profiles: * DS305 -- Layer Setting Services (LSS). Lets an LSS master configure the node-ID and bit-rate of slaves over the bus: switch mode global and selective, configure/activate bit timing, configure node-ID, store configuration, and inquire node-ID / identity. Also exposed through the shell tool as `canmat lss ...`. * DS401 -- Generic I/O device profile. Read/write helpers for 8-bit digital I/O (0x6000/0x6200) and 16-bit analogue I/O (0x6401/0x6411). * DS405 -- Interface and device profile for IEC 61131-3 programmable devices. Typed read/write accessors for network variables, with the full input/output index table from CiA 405 tables 4 and 5 (including the REAL32 network-variable path). DS305 lives in the base library; DS401 and DS405 are built as separate profile libraries mirroring the DS402 layout. Build fixes needed to make this decade-old tree build on a modern toolchain: * Port the canmatc EDS-to-C generator from Python 2 to Python 3 (configparser, print(), read_file, eager map, list() around dict keys/range). Restore inline ';' comment stripping that Python 2's ConfigParser did by default, which the generated dictionaries rely on. * Add the missing `typedef` on enum canmat_402_polarity_mask in ds402.h. Without it the enum name became a tentative global definition in every translation unit, which fails to link under modern GCC's -fno-common default. Verified with the full autotools build (autoreconf/configure/make) and make check (test_sdo passes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P2vev2FUGJ83n8XdihYHo2 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013DfTvJceEThw8L7uzes7Am
Review fixes for the LSS support: * canmat lss node/baud/store printed canmat_lss_strerror(err) on any failure, but err is only meaningful when the slave itself reported an error (CANMAT_ERR_DEV). A transport or protocol failure left err at 0 and printed "failed: Success". Fall back to canmat_iface_strerror for non-device errors. * canmat_lss_switch_mode_selective read data[0] of the response without checking can_dlc, unlike the other LSS receive paths. Reject frames shorter than 1 byte as a protocol error. * Mark fail() noreturn (new ATTR_NORETURN macro alongside ATTR_PRINTF) and drop the unreachable return after it in the lss switch branch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013DfTvJceEThw8L7uzes7Am
|
@saulrh |
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.
Disclaimer: I have not reviewed this code, nor have I run this on real hardware. In fact, it's been like ten or twelve years since I so much as touched one of the motors that this library talks to! But it compiles on modern systems now. :V
I hope your day just got a little bit weirder.
Claude's PR description follows:
Closes #1.
Adds the CANopen profiles requested in the issue — DS305, DS401, and DS405 — alongside the existing DS301 (communication) and DS402 (drives) support.
New profiles
canmat lss .... Lives in the base library.libsocanmatic401profile library.libsocanmatic405profile library.Build fixes needed to build this decade-old tree on a modern toolchain
canmatcEDS-to-C generator from Python 2 to Python 3 (configparser,print(),read_file, eagermap,list()around dict keys/range), restoring the inline;comment stripping that Python 2's ConfigParser did by default.typedefonenum canmat_402_polarity_maskinds402.h, which otherwise fails to link under modern GCC's-fno-commondefault.Verification
Full autotools build (
autoreconf/configure/make) is clean andmake checkpasses (PASS: test_sdo), withlibsocanmatic401,libsocanmatic405, andds305.oall produced.🤖 Generated with [Claude Code](https://claude.com/claude-code)