Title: examples/simple_ds402_node.py uses contradictory PDO mapping patterns · Issue #496 · canopen-python/canopen · GitHub
Open Graph Title: examples/simple_ds402_node.py uses contradictory PDO mapping patterns · Issue #496 · canopen-python/canopen
X Title: examples/simple_ds402_node.py uses contradictory PDO mapping patterns · Issue #496 · canopen-python/canopen
Description: The example uses the RemoteNode.load_configuration() API to send ParameterValue settings given in the sample EDS file to the device. This used to work in conjunction with PdoBase.read() to synchronize the locally cached PDO configuration...
Open Graph Description: The example uses the RemoteNode.load_configuration() API to send ParameterValue settings given in the sample EDS file to the device. This used to work in conjunction with PdoBase.read() to synchron...
X Description: The example uses the RemoteNode.load_configuration() API to send ParameterValue settings given in the sample EDS file to the device. This used to work in conjunction with PdoBase.read() to synchron...
Opengraph URL: https://github.com/canopen-python/canopen/issues/496
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"examples/simple_ds402_node.py uses contradictory PDO mapping patterns ","articleBody":"The example uses the `RemoteNode.load_configuration()` API to send `ParameterValue` settings given in the sample EDS file to the device. This used to work in conjunction with `PdoBase.read()` to synchronize the locally cached PDO configuration and mapping info. Calling that method (on any PDO) was therefore not really necessary, as it was implied as a final step in `load_configuration()`.\r\n\r\nBut #427 changed this and made `load_configuration()` apply the PDO configuration through calls to `PdoBase.save()` instead. Thus the need to read it back was eliminated.\r\n\r\nIn any case, the example goes on to call `BaseNode402.setup_402_state_machine()`, which then reads back the PDO configuration again. Here it would help to pass `read_pdos=False` since we know that the configuration was just saved, skipping the unnecessary upload.\r\n\r\nThat convenience method also checks whether needed values like the status and control words are configured in the respective PDOs. Which should succeed because of the initialization values in the sample EDS (haven't tested).\r\n\r\nBut then the example code continues with re-mapping the PDOs, which (probably?) invalidates the `rpdo_pointers` and `tpdo_pointers` entries pointing at the previous PDO mapping's `PdoVariable` objects. This should be done before `setup_402_state_machine()` to avoid this error. In addition, the example first uses `node.tpdo.read()` and `node.rpdo.read()` before adjusting the mappings, which, again, is unnecessary after `load_configuration()`.\r\n\r\nFurthermore, before the PDO re-mapping, it tries to change the `node.state` attribute, but there is no prior change of `node.nmt.state = 'OPERATIONAL'`, thus the exchanges of control and status words cannot work. There is a fallback to SDO implemented if no PDO maps the required objects, but that is not triggered because they are in fact mapped. The problem is that in PRE-OPERATIONAL state, the node's PDOs simply do not function. Re-mapping them after the previous `PdoVariable` objects have been cached (see above) doesn't make this any better.\r\n\r\nThese are some observations from trying to understand the sample code, showing that it is mostly broken for actual usage and suggests wrong or inefficient patterns of the library API usage. There may be more problems hidden, which could be revealed after testing with actual hardware. Maybe that was done at some point, but probably not after the library API has evolved and some functionality (especially regarding profile CiA402) moved around.\r\n\r\nWe should discuss how to make this example actually useful again, or at the very minimum, document that it serves only as a demonstration of the API and will not work with real hardware unless the user takes care of the issues with their hopefully firm CANopen background themselves.","author":{"url":"https://github.com/acolomb","@type":"Person","name":"acolomb"},"datePublished":"2024-07-04T21:32:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/496/canopen/issues/496"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fa9745e2-2f1c-b4d8-9c00-275e8b7271fb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E5D0:3DA5C6:116349D:174F2DD:6A5EF2D4 |
| html-safe-nonce | cbd580aebd03e449d5469a06ff91e93dfe31e7f2eb5ccccdc469d30f74986ca0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUQwOjNEQTVDNjoxMTYzNDlEOjE3NEYyREQ6NkE1RUYyRDQiLCJ2aXNpdG9yX2lkIjoiODExMDAzMDc2MjE5OTE1MTMxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a51e06bb47d0cff6f7bee2e29dee77e1d9b65eb0c5c5c70feb9fe40ddbd7b6f0 |
| hovercard-subject-tag | issue:2391483102 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/canopen-python/canopen/496/issue_layout |
| twitter:image | https://opengraph.githubassets.com/72ded9253e84c607c959c9aa2276f902fb65d2921c0df2ebe843f57fce8343f1/canopen-python/canopen/issues/496 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/72ded9253e84c607c959c9aa2276f902fb65d2921c0df2ebe843f57fce8343f1/canopen-python/canopen/issues/496 |
| og:image:alt | The example uses the RemoteNode.load_configuration() API to send ParameterValue settings given in the sample EDS file to the device. This used to work in conjunction with PdoBase.read() to synchron... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | acolomb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 82d0004a35927bdb00c652a57f456c55aa0eda4ade1bc7956d7510fdea6e454b |
| turbo-cache-control | no-preview |
| go-import | github.com/canopen-python/canopen git https://github.com/canopen-python/canopen.git |
| octolytics-dimension-user_id | 200581454 |
| octolytics-dimension-user_login | canopen-python |
| octolytics-dimension-repository_id | 68737600 |
| octolytics-dimension-repository_nwo | canopen-python/canopen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 68737600 |
| octolytics-dimension-repository_network_root_nwo | canopen-python/canopen |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d2d913dd727d2d7ac189fb4d05b10bc34ecd03ee |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width