adafruit / Adafruit_SCD30

Other
14 stars 22 forks source link

Getting odd values with M0 (other?) boards #6

Closed caternuson closed 3 years ago

caternuson commented 3 years ago

Re this thread: https://forums.adafruit.com/viewtopic.php?f=19&t=175010

I've recreated same behavior on QT PY: Screenshot from 2021-02-05 13-55-03

And also Itsy M0: Screenshot from 2021-02-05 13-53-25

But seems to work just fine on Itsy M4: Screenshot from 2021-02-05 13-51-06

ladyada commented 3 years ago

!? can you try turning on i2c debug in busio?

caternuson commented 3 years ago

This is on QT PY, running the adafruit_scd30_test example, and with #define DEBUG_SERIAL Serial enabled in Adafruit_I2CDevice.cpp, and uploading after a complete power cycle.

Looks like the reset failed maybe?

Screenshot from 2021-02-05 14-14-50

ladyada commented 3 years ago

can you compare the data trace with an M4?

caternuson commented 3 years ago

Itsy M4

Screenshot from 2021-02-05 14-33-14

ladyada commented 3 years ago

try initing these to zero https://github.com/adafruit/Adafruit_SCD30/blob/master/Adafruit_SCD30.cpp#L293

ladyada commented 3 years ago

also this is running past the buffer end https://github.com/adafruit/Adafruit_SCD30/blob/master/Adafruit_SCD30.cpp#L286

caternuson commented 3 years ago

OK, back to QT PY with initing those values to zero. But nothing done for the buffer index.

Screenshot from 2021-02-05 14-42-40

ladyada commented 3 years ago

yay ok! PR plz :)

caternuson commented 3 years ago

nice spot! thanks.

guess we'll see if/when that buffer index issue causes grief.

caternuson commented 3 years ago

Looks resolved: https://forums.adafruit.com/viewtopic.php?f=19&t=175010#p853221

Thanks again @ladyada for the assist!

kevinjwalters commented 3 years ago

This sort of thing (stack variables used before initialisation) could easily be detected by static analysis of the code as a prevention measure in the same way that pylint runs over the CircuitPython libraries.

The gcc/g++ compiler has enough smarts in it to pick this up too with -Wuninitialized and/or -Wmaybe-uninitialized. Antique versions of gcc may incorrectly inhibit this due to confusion from memcpy().

ladyada commented 3 years ago

@kevinjwalters yes, please add a check update to the Arduino CI!