Skip to content

Conversation

@acolomb
Copy link
Member

@acolomb acolomb commented Aug 12, 2021

This PR is based on #256 to avoid conflicts, thus should be merged after it. If needed I can rebase after merging #256.
EDIT: Rebased on top of master with #256 merged.

Switching operation modes for several drives simultaneously must be done via PDO. The current mechanism used for the BaseNode402.op_mode property supports only SDO. Now the PDO method is tried first, but falls back to the SDO method if the relevant objects (0x6060 / 0x6061) are not mapped to PDOs. In order to make sure an up-to-date value is returned for the property, the getter blocks until the TPDO has been received once, with a default timeout of 0.2 seconds leading to a RuntimeError.

On a side track, pdo.Map gains a new property is_periodic which reflects whether the period member has been set (usually from start()), or if a synchronous transmission type is configured. The above mentioned blocking behavior of the op_mode getter is skipped if the TPDO is not deemed periodic, to prevent the timeout from firing. Similarly, transmitting the RPDO immediately in the op_mode setter is skipped when deemed periodic. Same goes for the controlword setter, assuming that the application is responsible to set up the periodic transmission.

Transmitting the RPDO only makes sense if the value takes effect
immediately.  If there is already a cyclic task configured, or the
transmission type configuration requires a SYNC to be sent for the
change to apply, there is no sense in sending the PDO automatically in
the controlword setter.
Fall back to the previous behavior using SDO if the relevant object
0x6060 is not mapped to an RPDO.
Fall back to the previous behavior using SDO if the relevant object
0x6061 is not mapped to a TPDO.  The property getter still blocks
until an up-to-date value was received, by waiting for the respective
TPDO up to a configurable timeout of 0.2 seconds by default.  If the
TPDO does not look like it will be transmitted regularly (from its
is_periodic property), the method will not block and just return the
last received TPDO's value.

A lookup cache tpdo_pointers is added to keep track of the needed
pdo.Map instance, analog to the rpdo_pointers.
Consistently use empty dict literal for initialization.  Provide more
useful comments about the expected contents.
Switching operation modes for several drives simultaneously must be
done via PDO.  There is still a fallback mechanism via SDO, but a
warning should be issued when that is about to be used.
@acolomb acolomb force-pushed the operation-mode-pdo branch from 15a0891 to 2e444f7 Compare August 12, 2021 19:35
af-silva pushed a commit that referenced this pull request Aug 16, 2021
This reverts commit ebad5da.
Will merge instead the PR #257 with cumulative changes
@af-silva af-silva merged commit c161ab3 into canopen-python:master Aug 16, 2021
@acolomb acolomb mentioned this pull request Aug 16, 2021
@acolomb acolomb deleted the operation-mode-pdo branch August 17, 2021 12:22
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.

2 participants