After some code tweaks, I’m now getting every single piece of data – yes, that’s right, I’m reading data at 1kHz!
Primary problem was integrating samples rather than averaging them. I’d found before that calling time.time() was actually a very time consuming call. By just adding samples instead of integrating them, I only need to call time.time() in each motion processing loop rather than per sample. It’s that which has taken my sampling rate to 1kHz – or to put it another way, the python code can now read the sensors faster than the sensors can churn out the data, so my code sits there twiddling its thumbs waiting for the data.
I’ve not tracked down the cause for the occassional I2C miss, so I’ve also moved the try / except wrapper from around the I2C read to around the (interrupt + I2C read). That forces the code to wait for the next sample before trying to read it again. That’s the cause for the spike in the middle.
Combining the above with my recent super-duper fast GPIO edge_detect_wait() update listening for a single 50us pulse per call, once more, I can climb back up on my trusty steed and blow raspberries at the RTOS dogma.
Code’s up on GitHub.