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

network.PeriodicTask.update fails to update periodic RPDO #519

Open
dominjon opened this issue Jul 11, 2024 · 1 comment
Open

network.PeriodicTask.update fails to update periodic RPDO #519

dominjon opened this issue Jul 11, 2024 · 1 comment

Comments

@dominjon
Copy link

I believe I've found a bug when attempting to update a periodic RPDO whose values I'm setting.

The logic of network.PeriodicTask.update attempts to check if the data are new by checking the argument it's been passed against the existing value in the pdo.Map. However, pdo.Map.update is passing network.PeriodicTask.update the same value. If the task does not have the modify_data attribute, then the fact that new_data != old_data is trivially false means that the data are never updated.

@erlend-aasland
Copy link
Contributor

The new data is saved to .msg.data, no matter which branch is taken:

canopen/canopen/network.py

Lines 327 to 335 in a196e1e

new_data = bytearray(data)
old_data = self.msg.data
self.msg.data = new_data
if hasattr(self._task, "modify_data"):
self._task.modify_data(self.msg)
elif new_data != old_data:
# Stop and start (will mess up period unfortunately)
self._task.stop()
self._start()

AFAICS, modify_data is only used to update the task without affecting the timing (see the python-can source). If modify_data is not available, the workaround is to restart the task, thus affecting the timing for the subsequent task execution.

Do you have a code snippet to reproduce the failure you're seeing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants