-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
I2C Error handling #6689
I2C Error handling #6689
Conversation
4488c11
to
4648028
Compare
e36f675
to
ec33a81
Compare
I think this is more or less ready to gather feedback, so I will remove the "draft" label. |
Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html There are some steps that you can take now:
Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available. Best regards, PS: I'm just an automated script, not a human being. |
ec33a81
to
1c40835
Compare
What is the status of this PR? It looks like it is not passing the build tests. In general the idea seems useful - thanks for working on it. I haven't done a full review but I have some initial comments:
Thanks again, |
1c40835
to
1af516c
Compare
I think it does not pass tests because I changed some mcu commands and the current dictionary does not fit.
Thanks |
I think it's failing because
That branch is for the case where some code calls
Unfortunately, that's quite difficult with the current mcu/host communication protocol. There's no good way (that I know of) to figure out which response is associated with each command if multiple commands are sent at once. It should be possible to just ignore responses though.
Yeah - if we can do this in phases I think that would help. Maybe first phase is support for returning error codes to the mcu i2c layer, which calls shutdown on an error. Then one-by-one convert mcu archs to return errors instead of shutdown. Then convert mcu i2c commands to return error instead of invoking shutdown (internal mcu i2c users still invoke shutdown) and have klippy invoke shutdown. After that point, the host code can implement retry or error propagation. Again, just thinking out loud. Thanks, |
e2b342c
to
216e923
Compare
b755d18
to
10a8622
Compare
Sum up for now:
I hope those reduced size of changes will be easier to review/check/cherrypick. |
Thanks. In general, it looks good to me. I like this plan to update the mcu first and then update the host in a following PR. Some minor things I noticed:
Thanks again, |
da7d039
to
96135d8
Compare
JFYI, ldc/mpu - done |
Thanks! It looks good to me. I'll give a few days for others to comment, but otherwise look to commit. -Kevin |
While we're waiting, would you be able to rebase and add a signed-off-by line to the rp2040 patch? Also, is the commit comments in "i2ccmds: abstract i2c dev from bus" still accurate? Thanks, |
96135d8
to
87067f3
Compare
I updated the comment, to be more "clear" I'm not sure that I have better wording to describe that, feel free to change or suggest a better one |
Added wrapper around sw/hw bus API, pins.py code will ensure that pins will not mix between HW/SW buses. Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
Signed-off-by: Timofey Titovets <[email protected]>
87067f3
to
47e6b65
Compare
Thanks! -Kevin |
* i2ccmds: abstract i2c dev from bus implementation Added wrapper around sw/hw bus API, pins.py code will ensure that pins will not mix between HW/SW buses. Signed-off-by: Timofey Titovets <[email protected]> * i2c: handle errors at i2ccmds Signed-off-by: Timofey Titovets <[email protected]> * i2c_software: forward errors to i2ccmd Signed-off-by: Timofey Titovets <[email protected]> * linux: forward i2c errors to i2ccmd Signed-off-by: Timofey Titovets <[email protected]> * rp2040: forward i2c errors to i2ccmd Signed-off-by: Timofey Titovets <[email protected]> * stm32: forward i2c errors to i2ccmd Signed-off-by: Timofey Titovets <[email protected]> * i2ccmds: move status checks to function Signed-off-by: Timofey Titovets <[email protected]> * ldc1612: shutdown on i2c errors Signed-off-by: Timofey Titovets <[email protected]> * mpu: shutdown on i2c errors Signed-off-by: Timofey Titovets <[email protected]> --------- Signed-off-by: Timofey Titovets <[email protected]> Co-authored-by: Timofey Titovets <[email protected]>
As mentioned: #6674 (comment)
That would be nice to handle I2C errors, instead of the current shutdown approach.
There is a refactoring part to make things more obvious, where is the dev and where is the bus.
Errors handling works, but:
There should be a better way to define & pass errors to Klippy. I think it would be possible to reuse static_stings_id for that.When klippy inits and I2C returns an error, it is an unhandled exception, so it only appears in logs. There should be a fix actually to show it to frontends as before with shutdown msg.Missing handling forldc1612 - used in homing sequence, there is no reason or way to handle errors.So, they stop updating data, if there is no heater for them, the machine will continue running.
About the code itself:
(I still somewhat think about non-blocking i2c, it feels right to store queue/buf at bus level),
int ret
looks a little dirty to me, maybe it is a bad approach here, I will be glad to receive any feedback.(maybe with timers there is a simple way with callbacks, cause we don't need to do something with stack).
Thanks.