BigW Consortium Gitlab

Commit 9e7f16d3 by David Frey

update bme680 app to not crash if timer is delayed

parent f7063ff3
......@@ -80,11 +80,13 @@ le_result_t mangOH_bme680_Configure(
if (samplingRate != _s.samplingRate)
{
_s.samplingRate = samplingRate;
LE_ASSERT_OK(le_timer_SetMsInterval(_s.timer, (uint32_t)(1000.0 / sr)));
if (!le_timer_IsRunning(_s.timer))
{
LE_ASSERT_OK(le_timer_Start(_s.timer));
}
le_timer_Stop(_s.timer);
/*
* Set the timer to 1ms to trigger a reading with the new settings immediately. Once that
* reading is performed, BSEC will decide how to set the timer.
*/
LE_ASSERT_OK(le_timer_SetMsInterval(_s.timer, 1.0));
LE_ASSERT_OK(le_timer_Start(_s.timer));
}
return status == BSEC_OK ? LE_OK : LE_FAULT;
......
......@@ -354,7 +354,12 @@ static void TimerHandler(le_timer_Ref_t t)
}
}
int64_t nextTimerMs = (sensorSettings.next_call - GetTimestampNs()) / (1000LL * 1000LL);
LE_FATAL_IF(nextTimerMs <= 0, "Processing too slowly - next timeout scheduled for %lld ms", nextTimerMs);
LE_DEBUG("Configuring timer to %" PRId64 " ms", nextTimerMs);
if (nextTimerMs <= 0)
{
LE_WARN("Next timer set to occur in %" PRId64 " ms. Setting to 1 ms instead", nextTimerMs);
nextTimerMs = 1;
}
LE_ASSERT_OK(le_timer_SetMsInterval(t, nextTimerMs));
LE_ASSERT_OK(le_timer_Start(t));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment