emfcamp / badge-2024-software

46 stars 29 forks source link

exception handling for hexpansion I2C #190

Open Robotmad opened 2 months ago

Robotmad commented 2 months ago

Fix for Issue #188.

If hexpansion is unplugged during an I2C operation an OSError exception is generated which was not being trapped leading to a crash. i2c read and write operations now protected and abort the transfer, not attempting any further bytes.

kliment commented 2 months ago

Far as I can see, this can result in incomplete reads that then get interpreted as a filesystem. We should probably handle this error one level higher

ChrisDick commented 2 months ago

I've given this a try and it does lead to incomplete file reads that are then run.

Traceback (most recent call last): File "main.py", line 43, in File "system/scheduler/init.py", line 243, in run_forever File "asyncio/core.py", line 1, in run_until_complete File "asyncio/core.py", line 1, in run_until_complete File "asyncio/core.py", line 1, in run_until_complete File "system/scheduler/init.py", line 239, in _main File "asyncio/funcs.py", line 1, in gather File "asyncio/core.py", line 1, in run_until_complete File "system/eventbus.py", line 101, in run File "asyncio/funcs.py", line 1, in gather File "asyncio/core.py", line 1, in run_until_complete File "system/hexpansion/app.py", line 254, in handle_hexpansion_insertion File "system/hexpansion/app.py", line 216, in _mount_eeprom File "system/hexpansion/app.py", line 142, in _launch_hexpansion_app File "hexpansion_2/app.py", line 62 IndentationError: unindent doesn't match any outer indent level

there is no indentation problem with the file.