Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS402: Simplify setup procedure. #259

Merged
merged 6 commits into from
Aug 16, 2021

Conversation

acolomb
Copy link
Collaborator

@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.

The BaseNode402.setup_402_state_machine() method does some unnecessary things that should rather be handled in the application code. Switching the NMT state and DS402 power state was already questioned in a code comment, and I agree that it should not happen here unconditionally.

In the same spirit, reading all of the node's PDO configuration is detrimental to the application in case it has previously called pdo.save(), causing lots of needless SDO traffic. So that part is made optional through a function argument.

Overall this should make the library's convenience methods more useful in context of a more complex application. The downside of course is that a simple script to get some DS402 controller working would need a little more state switching outside of the library code.

Reading the PDO configuration is possible in OPERATIONAL or
PRE-OPERATIONAL states, so switching that is unnecessary.  The
application should be responsible to handle such transitions, and the
library function should be usable without disturbing the application
logic.

Changing the DS402 state machine to SWITCH ON DISABLED is also not
necessary.  The drive may be in whatever state from a previous usage,
and then the change to SWITCH ON DISABLED may even trigger an
exception because there is no way to reach it directly.  So this
transition should also be the application's responsibility.
SDOs are allowed in all but the STOPPED state.  That would lead to a
timeout and an SdoCommunicationError exception.  Checking the NMT
state here raises an exception without a timeout involved.
If the application already configured the PDOs and called .save() on
the pdo.Maps object, there is no sense in reading everything back
again in the setup_pdos() method.  Provide an optional argument to
disable that behavior.

A call to subscribe to the PDOs from the network is added because that
side-effect of pdo.read() is necessary for the TPDO callback to work.
Add an optional argument which is simply passed down to setup_pdos()
to choose whether reading the PDO configuration is necessary.
Besides the changes regarding setup_402_state_machine(), there were
numerous errors where the documentation talks about nonexistent or
differently named attributes.

Also fix the description regaring what the method actually does.  It
won't configure the TPDO1 to contain the Statusword, but only check
the PDO configuration for Statusword and Controlword presence.
@acolomb acolomb force-pushed the simplify-setup-ds402 branch from 3b51936 to edc4b1c Compare August 12, 2021 19:37
@af-silva af-silva merged commit 7c5e4ce into christiansandberg:master Aug 16, 2021
@acolomb acolomb deleted the simplify-setup-ds402 branch August 16, 2021 20: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