I’m making a device that controls a gas valve and keeps the gas ignited when it needs to. This works great, but I need the code to 100% certainly be running or something could go horribly wrong. My problem is that the Photon (or P1 on a custom PCB in my case) blocks all user code if Network connection is lost.
I have looked into several ways of solving this. SYSTEM_MODE(MANUAL) will not do the trick since it still blocks user code when reconnecting. The trick is apparently to use SYSTEM_THREAD(ENABLED) like @armor suggests in this thread.
I do however have a problem - if I’m using SYSTEM_MODE(SEMI_AUTOMATIC) with SYSTEM_THREAD(ENABLED) I will experience full on hardware crashes at random intervals. This is completely unreproducible and happens very rarely (3 times in 8 hours today), but when it happens it can (in my case) burn someones house down. If I turn off SYSTEM_THREAD, there is never a crash. I do not use any of the “Synchronous system functions” so that should not be an issue. I have a vague idea that since I use I2C and SPI extensively that there may be something related to that causing the problem, but there is no documentation indicating that.
Is there a guide for debugging hardware hangs? (as in full freeze)
Are there any known bugs related to this? ( Like @SadE54 mentions here )
Do I need to use SINGLE_THREADED_BLOCK or ATOMIC_BLOCK when writing data (to SPI as in the RA8875 based LCD screen or one of the 6 I2C devices on the board)?