Hi Klipper devs,
Been really happy with my machine recently, but I’ve been trying to solve a particularly annoying issue with intermittent I2C errors killing prints. I am running a Nevermore StealthMax which uses a pair of BME280+SGP40 sensors.
There’s currently PR #6738 and a separate klipper module for SGP40 sensors, klipper-sgp40. That module has largely tracked the changes introduced in Klipper over the last year and a new PR is being worked on to try and handle I2C errors without crashing. I’ve been testing the code on my printer by manually connecting and disconnecting the wires to an SGP40 during runtime.
From what I can tell, with some changes I mentioned in the PR, the code is correctly able to catch certain exceptions related to the I2C read fails. However the exception serialhdl.error: Unable to obtain 'i2c_response' response doesn’t get caught, even with a blanket try...except Exception as e: wrapper around the I2C measurement code in the init.py file.
Aside from hacking i2ccmds.c’s i2c_shutdown_on_err, I can’t seem to figure out how to catch this error and discard the failed measurement. In my case, these sensors are non-critical. If they drop, they only affect my satisfaction knowing how much air pollution my printer is spewing out.
Would anyone with deeper knowledge of the serialhdl and i2c_transfer functions be able to help point me in the right direction? Happy to dig deeper in the code, but multi-threaded python code is not my forte and I’m having trouble following the function calls.





