Puara / puara-gestures

High-level gestural descriptor functions for the Puara Framework
MIT License
1 stars 6 forks source link

updateInertialGestures() causes ESP32 crash if the gyrobuffers are empty #3

Open aburt2 opened 1 year ago

aburt2 commented 1 year ago

I was testing with making a better sensor manager for the T-Stick (one that won't try to read from sensors that haven't responded) and while testing I've noticed that if you haven't set any gyroscope values using setGyroscopeValues and call the updateInertialGestures() method it causes the ESP32 to crash with the following error message.

@edumeneses is it possible to have the function either print out a warning when the gyroBuffers are empty or initialise puara-gestures with zeros in the gyroBuffers

Tested on Tinypico with T-stick firmware (commenting out lines 420 - 426)

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400d5d15  PS      : 0x00060830  A0      : 0x800d5f95  A1      : 0x3ffb2130  
A2      : 0x3ffc4d10  A3      : 0x3ffc4d88  A4      : 0x3ffc4d78  A5      : 0x00000000
A6      : 0x00000000  A7      : 0x3ffc4d20  A8      : 0x800d5d15  A9      : 0x3ffb2100
A10     : 0x82797940  A11     : 0x3ffb21a0  A12     : 0x3ffb21b0  A13     : 0x3ffb20b0
A14     : 0x00000001  A15     : 0x3ffb0320  SAR     : 0x0000001c  EXCCAUSE: 0x0000001c
EXCVADDR: 0x82797940  LBEG    : 0x4008c6cd  LEND    : 0x4008c6dd  LCOUNT  : 0xfffffffd  

Backtrace: 0x400d5d12:0x3ffb2130 0x400d5f92:0x3ffb21e0 0x400d3570:0x3ffb2200 0x400f767d:0x3ffb2290

  #0  0x400d5d12:0x3ffb2130 in PuaraGestures::updateJabShake() at .pio/libdeps/tinypico/puara-gestures/puara_gestures.cpp:24
  #1  0x400d5f92:0x3ffb21e0 in PuaraGestures::updateInertialGestures() at .pio/libdeps/tinypico/puara-gestures/puara_gestures.cpp:12
  #2  0x400d3570:0x3ffb2200 in loop() at src/main.cpp:436
  #3  0x400f767d:0x3ffb2290 in loopTask(void*) at C:/Users/user/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
edumeneses commented 1 year ago

Sure thing! We can talk more about that IRL today, but I plan to revisit the puara-gestures library next week. I plan to initialize the class with default internal variables (0.0 for the sensor data holders and gyroBuffers), and implement a check on updateJabShake() / updateOrientation()

Also, there's some code cleaning to do.

We can push a quick fix today afternoon.

edumeneses commented 1 year ago

@aburt2 , I believe this is already fixed. Please let me know if not.

I'll leave this open for now.

aburt2 commented 1 year ago

Okay @edumeneses , I'll test this tomorrow

aburt2 commented 1 year ago

@edumeneses it is Still an issue with the latest T-Stick firmware

edumeneses commented 1 year ago

Thanks for taking the time to check. I'll add it to the lists to review in the code.

I started touching on that earlier this week.