From 94e2c2f9dae96b7eddb0cabc075043193ab31576 Mon Sep 17 00:00:00 2001 From: Stefan Tibus <38475243+stibus@users.noreply.github.com> Date: Wed, 13 Apr 2022 00:15:47 +0200 Subject: [PATCH] Fix early return in `startLowPowerPeriodicMeasurement` In method `FrogMoreScd40::startLowPowerPeriodicMeasurement` the `return` statement appeared before the update of the `DuringMeasurement` flag. Thus, the class would wrongly assume not be in measurement mode and a subsequent `stopPeriodicMeasurement` would fail. Moved the `return` statement to after setting the flag. --- lib/lib_i2c/FrogmoreScd40/FrogmoreScd40.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lib_i2c/FrogmoreScd40/FrogmoreScd40.cpp b/lib/lib_i2c/FrogmoreScd40/FrogmoreScd40.cpp index ee7e3c232..5499311f3 100644 --- a/lib/lib_i2c/FrogmoreScd40/FrogmoreScd40.cpp +++ b/lib/lib_i2c/FrogmoreScd40/FrogmoreScd40.cpp @@ -691,8 +691,8 @@ int FrogmoreScd40::startLowPowerPeriodicMeasurement(void) if (DuringMeasurement) { return (ERROR_SCD40_BUSY_MEASURING); } - return (sendCommand(COMMAND_SCD40_START_LOW_POWER_PERIODIC_MEASUREMENT)); DuringMeasurement = 1; + return (sendCommand(COMMAND_SCD40_START_LOW_POWER_PERIODIC_MEASUREMENT)); } int FrogmoreScd40::getDataReadyStatus(bool *pIsAvailable)