reject impossible pulses

This commit is contained in:
Matthew Kennedy 2023-09-07 12:26:00 -07:00
parent d8edc9f61f
commit 38c4a0f8b9
1 changed files with 6 additions and 0 deletions

View File

@ -60,6 +60,12 @@ void HellaOilLevelSensor::onEdge(efitick_t nowNt) {
// Stop timing at the falling edge
float lastPulseMs = 1000 * m_pulseTimer.getElapsedSeconds(nowNt);
if (lastPulseMs > 100 || lastPulseMs < 20) {
// Impossibly short or long pulse, something went wrong
m_nextPulse = NextPulse::None;
return;
}
if (m_nextPulse == NextPulse::Diag) {
// TODO: decode diag pulse?
return;