Skip to content

PDO defaults#36

Merged
mcbridejc merged 3 commits intomainfrom
pdo-defaults
Dec 21, 2025
Merged

PDO defaults#36
mcbridejc merged 3 commits intomainfrom
pdo-defaults

Conversation

@mcbridejc
Copy link
Copy Markdown
Owner

@mcbridejc mcbridejc commented Dec 20, 2025

Allow PDO default settings to be specified in device config, e.g.:

[pdos]
num_rpdo = 4
num_tpdo = 4

# Setup TPDO1 to be enabled by default, transmitting on $NODEID + 0x200
[pdos.tpdo.1]
enabled = true
cob_id = 0x200
add_node_id = true
transmission_type = 254
mappings = [
    { index=0x2000, sub=1, size=32 },
]

This simple feature became more complicated -- and sprawled into 39 files! -- because the defaults are a function of the node ID, and that has implications for how/when defaults are initialized and persisted object values are loaded. Up to now, object defaults have just been set in object initializers, that will have to change in the future for all objects (see #35). For now, PDO defaults are initialized by the Node, and this means that persisted values cannot be loaded until after the node is created, so I went ahead and added callbacks for ResetApp and ResetComm, as well as all of the other NMT state changes. Applications that support persistent object stored should read the persisted objects in the ResetApp and ResetComm callbacks.

The callback structure is also adjusted, and callbacks are no longer required to have static lifetimes. Instead of passing the CAN message sender callback to Node::process, it is included in the callbacks during initialization.

Other breaking changes

  • the node_configuration mod is moved from zencan-client to zencan-common.
  • cob is changed to cob_id in node configuration files / PdoConfig.
  • zencan_common::objects::PdoMapping renamed to PdoMappable to distinguish it from zencan_copmmon::pdo::PdoMapping.

@mcbridejc mcbridejc force-pushed the pdo-defaults branch 3 times, most recently from 26cda18 to 4da23ff Compare December 20, 2025 21:07
Creates ability to specify PDO default config in device config.

This leads to a requirement for runtime default initialization (because
PDO IDs can be a function of the node ID), which leads to a requirement
to implement callbacks for loading persisted object values, so the
way that callbacks are handled is also refactored.

Callbacks are no longer required to be static, but instead Node has an
generic lifetime.
@mcbridejc mcbridejc linked an issue Dec 21, 2025 that may be closed by this pull request
@mcbridejc mcbridejc merged commit bfa2090 into main Dec 21, 2025
1 check passed
@mcbridejc mcbridejc deleted the pdo-defaults branch February 18, 2026 20:10
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.

TPDO configuration

1 participant