inhibit sensor timeout during flash (#3146)
* inhibit timeout during flash * do it up a level Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
048801e95e
commit
70dfd4af78
|
@ -116,9 +116,13 @@ void writeToFlashIfPending() {
|
|||
// with a flash write thread, the schedule happens directly from
|
||||
// setNeedToWriteConfiguration, so there's nothing to do here
|
||||
if (allowFlashWhileRunning() || !getNeedToWriteConfiguration()) {
|
||||
// Allow sensor timeouts again now that we're done (and a little time has passed)
|
||||
Sensor::inhibitTimeouts(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent sensor timeouts while flashing
|
||||
Sensor::inhibitTimeouts(true);
|
||||
writeToFlashNow();
|
||||
}
|
||||
|
||||
|
|
|
@ -261,6 +261,12 @@ bool Sensor::Register() {
|
|||
return s_sensorNames[static_cast<size_t>(type)];
|
||||
}
|
||||
|
||||
/*static*/ bool Sensor::s_inhibitSensorTimeouts = false;
|
||||
|
||||
/*static*/ void Sensor::inhibitTimeouts(bool inhibit) {
|
||||
Sensor::s_inhibitSensorTimeouts = inhibit;
|
||||
}
|
||||
|
||||
// Print information about all sensors
|
||||
/*static*/ void Sensor::showAllSensorInfo() {
|
||||
for (size_t i = 1; i < efi::size(s_sensorRegistry); i++) {
|
||||
|
|
|
@ -121,6 +121,12 @@ public:
|
|||
*/
|
||||
static void resetAllMocks();
|
||||
|
||||
/*
|
||||
* Inhibit sensor timeouts. Used if you're doing something that will block sensor updates, such as
|
||||
* erasing flash memory (which stalls the CPU on some MCUs)
|
||||
*/
|
||||
static void inhibitTimeouts(bool inhibit);
|
||||
|
||||
/*
|
||||
* Get a friendly name for the sensor.
|
||||
* For example, CLT, IAT, Throttle Position 2, etc.
|
||||
|
@ -160,6 +166,8 @@ protected:
|
|||
explicit Sensor(SensorType type)
|
||||
: m_type(type) {}
|
||||
|
||||
static bool s_inhibitSensorTimeouts;
|
||||
|
||||
private:
|
||||
const SensorType m_type;
|
||||
|
||||
|
|
|
@ -37,6 +37,11 @@ public:
|
|||
return unexpected;
|
||||
}
|
||||
|
||||
// Timeouts are disabled, return last value
|
||||
if (Sensor::s_inhibitSensorTimeouts) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (m_timeoutPeriod != 0) { // zero m_timeoutPeriod means value lasts forever
|
||||
if (getTimeNowNt() - m_timeoutPeriod > m_lastUpdate) {
|
||||
return unexpected;
|
||||
|
|
Loading…
Reference in New Issue