02-10-2021 12:34 AM
In the file bme680.c on lines 1212 to 1215, we can read:
rslt = null_ptr_check(dev);
do {
if (rslt == BME680_OK) {
rslt = bme680_get_regs(((uint8_t) (BME680_FIELD0_ADDR)), buff, (uint16_t) BME680_FIELD_LENGTH,
The issue is that the variable "rslt" is not altered further down the loop, so when there is an error the first time, "rslt" will be different than BME680_OK, so the "if" on line 1214 will always be false, and the bme680_get_regs function will never be called again.
So at the end, this code will always try a maximum of 1 time.
Thank you.
JL, Clarity IoT
Solved! Go to Solution.
02-10-2021 12:50 AM
Also, this code fills in the output "struct bme680_field_data *data" variable even when an error occurs upon a call to bme680_get_regs. The "rslt" status code should be checked just after the call and the error condition should be properly handled.
02-10-2021 02:51 AM
02-10-2021 06:06 PM
Hello jrlemieux,
We have updated version source code as below.
GitHub - BoschSensortec/BME68x-Sensor-API: Common Sensor API for the BME680 and BME688 sensors
Could you use this one?
It fixed your comment already.
Thanks,
02-10-2021 08:47 PM
The bug is not fixed.
Line 1141 reads:
while ((tries) && (rslt == BME68X_OK))
This test is wrong, because the loop will not be performed if there was an error the first time the loop is executed.
Lines 1207 to 1209 read:
if (rslt == BME68X_OK)
{
dev->delay_us(BME68X_PERIOD_POLL, dev->intf_ptr);
This is wrong because the wait should be done between the attemps when there is a failure, not a success.
Finally, the rslt that is captured on line 1143 is checked too late. All the processing between lins 1153 to 1175 should not be execued when an error happens on line 1143.
The check on line 1147 should be done at the start of the function, not in the loop.
I feel that the current code has never neeb tested under a failure test case.
Thank you.
JL