diff --git a/hal/src/main/native/athena/PDP.cpp b/hal/src/main/native/athena/PDP.cpp index 00352cda1f..f5cf92b687 100644 --- a/hal/src/main/native/athena/PDP.cpp +++ b/hal/src/main/native/athena/PDP.cpp @@ -175,7 +175,11 @@ double HAL_GetPDPTemperature(HAL_PDPHandle handle, int32_t* status) { HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); - return pdpStatus.bits.temp * 1.03250836957542 - 67.8564500484966; + if (*status != 0) { + return 0; + } else { + return pdpStatus.bits.temp * 1.03250836957542 - 67.8564500484966; + } } double HAL_GetPDPVoltage(HAL_PDPHandle handle, int32_t* status) { @@ -186,7 +190,11 @@ double HAL_GetPDPVoltage(HAL_PDPHandle handle, int32_t* status) { HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); - return pdpStatus.bits.busVoltage * 0.05 + 4.0; /* 50mV per unit plus 4V. */ + if (*status != 0) { + return 0; + } else { + return pdpStatus.bits.busVoltage * 0.05 + 4.0; /* 50mV per unit plus 4V. */ + } } double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel, @@ -205,6 +213,9 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel, PdpStatus1 pdpStatus; HAL_ReadCANPacketTimeout(handle, Status1, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); + if (*status != 0) { + return 0; + } switch (channel) { case 0: raw = (static_cast(pdpStatus.bits.chan1_h8) << 2) | @@ -235,6 +246,9 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel, PdpStatus2 pdpStatus; HAL_ReadCANPacketTimeout(handle, Status2, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); + if (*status != 0) { + return 0; + } switch (channel) { case 6: raw = (static_cast(pdpStatus.bits.chan7_h8) << 2) | @@ -265,6 +279,9 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel, PdpStatus3 pdpStatus; HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); + if (*status != 0) { + return 0; + } switch (channel) { case 12: raw = (static_cast(pdpStatus.bits.chan13_h8) << 2) | @@ -365,6 +382,9 @@ double HAL_GetPDPTotalCurrent(HAL_PDPHandle handle, int32_t* status) { HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); + if (*status != 0) { + return 0; + } uint32_t raw; raw = pdpStatus.bits.TotalCurrent_125mAperunit_h8; @@ -380,6 +400,9 @@ double HAL_GetPDPTotalPower(HAL_PDPHandle handle, int32_t* status) { HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); + if (*status != 0) { + return 0; + } uint32_t raw; raw = pdpStatus.bits.Power_125mWperunit_h4; @@ -397,6 +420,9 @@ double HAL_GetPDPTotalEnergy(HAL_PDPHandle handle, int32_t* status) { HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length, &receivedTimestamp, TimeoutMs, status); + if (*status != 0) { + return 0; + } uint32_t raw; raw = pdpStatus.bits.Energy_125mWPerUnitXTmeas_h4;