From fa20e6ca4f23ced33f065f388ca46173c695e074 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 29 Oct 2014 17:08:54 -0400 Subject: [PATCH] Check for fatal interrupt status on multiple interrupt methods to avoid hanging program (fixes artf3602) Change-Id: I31cb499fd1641deec26001b719fd0a6f07d20692 --- wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp b/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp index 08e02432ef..badd6dfbdb 100644 --- a/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp +++ b/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp @@ -91,6 +91,7 @@ void InterruptableSensorBase::AllocateInterrupts(bool watcher) */ void InterruptableSensorBase::CancelInterrupts() { + if (StatusIsFatal()) return; wpi_assert(m_interrupt != NULL); int32_t status = 0; cleanInterrupts(m_interrupt, &status); @@ -108,6 +109,7 @@ void InterruptableSensorBase::CancelInterrupts() */ InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(float timeout, bool ignorePrevious) { + if (StatusIsFatal()) return InterruptableSensorBase::kTimeout; wpi_assert(m_interrupt != NULL); int32_t status = 0; uint32_t result; @@ -125,6 +127,7 @@ InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(fl */ void InterruptableSensorBase::EnableInterrupts() { + if (StatusIsFatal()) return; wpi_assert(m_interrupt != NULL); int32_t status = 0; enableInterrupts(m_interrupt, &status); @@ -136,6 +139,7 @@ void InterruptableSensorBase::EnableInterrupts() */ void InterruptableSensorBase::DisableInterrupts() { + if (StatusIsFatal()) return; wpi_assert(m_interrupt != NULL); int32_t status = 0; disableInterrupts(m_interrupt, &status); @@ -151,6 +155,7 @@ void InterruptableSensorBase::DisableInterrupts() */ double InterruptableSensorBase::ReadRisingTimestamp() { + if (StatusIsFatal()) return 0.0; wpi_assert(m_interrupt != NULL); int32_t status = 0; double timestamp = readRisingTimestamp(m_interrupt, &status); @@ -167,6 +172,7 @@ double InterruptableSensorBase::ReadRisingTimestamp() */ double InterruptableSensorBase::ReadFallingTimestamp() { + if (StatusIsFatal()) return 0.0; wpi_assert(m_interrupt != NULL); int32_t status = 0; double timestamp = readFallingTimestamp(m_interrupt, &status);