From b990c62767858e22e75cceb9ae2b1667dbc8ec7e Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Wed, 31 Jul 2024 23:53:28 -0400 Subject: [PATCH] expose more faults in PDH and PH --- .../wpi/first/hal/PowerDistributionStickyFaults.java | 10 +++++++++- .../main/java/edu/wpi/first/hal/REVPHStickyFaults.java | 10 +++++++++- hal/src/main/native/athena/REVPDH.cpp | 2 ++ hal/src/main/native/athena/REVPH.cpp | 2 ++ hal/src/main/native/include/hal/PowerDistribution.h | 4 ++++ hal/src/main/native/include/hal/REVPH.h | 4 ++++ wpilibc/src/main/native/include/frc/PneumaticHub.h | 4 ++++ .../src/main/native/include/frc/PowerDistribution.h | 4 ++++ 8 files changed, 38 insertions(+), 2 deletions(-) diff --git a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java index f81f5471e62..4d7836c5e64 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java +++ b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionStickyFaults.java @@ -91,6 +91,12 @@ public class PowerDistributionStickyFaults { /** The device's CAN controller experienced a "Bus Off" event. */ public final boolean CanBusOff; + /** The hardware on the device has malfunctioned. */ + public final boolean HardwareFault; + + /** The firmware on the device has malfunctioned. */ + public final boolean FirmwareFault; + /** The device has rebooted. */ public final boolean HasReset; @@ -166,6 +172,8 @@ public PowerDistributionStickyFaults(int faults) { Brownout = (faults & 0x1000000) != 0; CanWarning = (faults & 0x2000000) != 0; CanBusOff = (faults & 0x4000000) != 0; - HasReset = (faults & 0x8000000) != 0; + HardwareFault = (faults & 0x8000000) != 0; + FirmwareFault = (faults & 0x10000000) != 0; + HasReset = (faults & 0x20000000) != 0; } } diff --git a/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java b/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java index 648458de780..4a74a9c75f9 100644 --- a/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java +++ b/hal/src/main/java/edu/wpi/first/hal/REVPHStickyFaults.java @@ -25,6 +25,12 @@ public class REVPHStickyFaults { /** The device's CAN controller experienced a "Bus Off" event. */ public final boolean CanBusOff; + /** The hardware on the device has malfunctioned. */ + public final boolean HardwareFault; + + /** The firmware on the device has malfunctioned. */ + public final boolean FirmwareFault; + /** The device has rebooted. */ public final boolean HasReset; @@ -40,6 +46,8 @@ public REVPHStickyFaults(int faults) { Brownout = (faults & 0x8) != 0; CanWarning = (faults & 0x10) != 0; CanBusOff = (faults & 0x20) != 0; - HasReset = (faults & 0x40) != 0; + HardwareFault = (faults & 0x40) != 0; + FirmwareFault = (faults & 0x80) != 0; + HasReset = (faults & 0x100) != 0; } } diff --git a/hal/src/main/native/athena/REVPDH.cpp b/hal/src/main/native/athena/REVPDH.cpp index 339840414b9..053f6d06db9 100644 --- a/hal/src/main/native/athena/REVPDH.cpp +++ b/hal/src/main/native/athena/REVPDH.cpp @@ -624,6 +624,8 @@ void HAL_GetREVPDHStickyFaults(HAL_REVPDHHandle handle, stickyFaults->brownout = status4.sticky_brownout_fault; stickyFaults->canWarning = status4.sticky_can_warning_fault; stickyFaults->canBusOff = status4.sticky_can_bus_off_fault; + stickyFaults->hardwareFault = status4.sticky_hardware_fault; + stickyFaults->firmwareFault = status4.sticky_firmware_fault; stickyFaults->hasReset = status4.sticky_has_reset_fault; } diff --git a/hal/src/main/native/athena/REVPH.cpp b/hal/src/main/native/athena/REVPH.cpp index fd74c012b59..a7a6bb87bd9 100644 --- a/hal/src/main/native/athena/REVPH.cpp +++ b/hal/src/main/native/athena/REVPH.cpp @@ -737,6 +737,8 @@ void HAL_GetREVPHStickyFaults(HAL_REVPHHandle handle, stickyFaults->brownout = status1.sticky_brownout_fault; stickyFaults->canWarning = status1.sticky_can_warning_fault; stickyFaults->canBusOff = status1.sticky_can_bus_off_fault; + stickyFaults->hardwareFault = status1.sticky_hardware_fault; + stickyFaults->firmwareFault = status1.sticky_firmware_fault; stickyFaults->hasReset = status1.sticky_has_reset_fault; } diff --git a/hal/src/main/native/include/hal/PowerDistribution.h b/hal/src/main/native/include/hal/PowerDistribution.h index 1241d1ee31c..757d92f7d93 100644 --- a/hal/src/main/native/include/hal/PowerDistribution.h +++ b/hal/src/main/native/include/hal/PowerDistribution.h @@ -362,6 +362,10 @@ struct HAL_PowerDistributionStickyFaults { uint32_t canWarning : 1; /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t canBusOff : 1; + /** The hardware on the device has malfunctioned. */ + uint32_t hardwareFault : 1; + /** The firmware on the device has malfunctioned. */ + uint32_t firmwareFault : 1; /** The device has rebooted. */ uint32_t hasReset : 1; }; diff --git a/hal/src/main/native/include/hal/REVPH.h b/hal/src/main/native/include/hal/REVPH.h index 6e9ff79639f..08b697c038f 100644 --- a/hal/src/main/native/include/hal/REVPH.h +++ b/hal/src/main/native/include/hal/REVPH.h @@ -122,6 +122,10 @@ struct HAL_REVPHStickyFaults { uint32_t canWarning : 1; /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t canBusOff : 1; + /** The hardware on the device has malfunctioned. */ + uint32_t hardwareFault : 1; + /** The firmware on the device has malfunctioned. */ + uint32_t firmwareFault : 1; /** The device has rebooted. */ uint32_t hasReset : 1; }; diff --git a/wpilibc/src/main/native/include/frc/PneumaticHub.h b/wpilibc/src/main/native/include/frc/PneumaticHub.h index f2ff204f3e6..8d58935090a 100644 --- a/wpilibc/src/main/native/include/frc/PneumaticHub.h +++ b/wpilibc/src/main/native/include/frc/PneumaticHub.h @@ -226,6 +226,10 @@ class PneumaticHub : public PneumaticsBase { uint32_t CanWarning : 1; /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t CanBusOff : 1; + /** The hardware on the device has malfunctioned. */ + uint32_t HardwareFault : 1; + /** The firmware on the device has malfunctioned. */ + uint32_t FirmwareFault : 1; /** The device has rebooted. */ uint32_t HasReset : 1; }; diff --git a/wpilibc/src/main/native/include/frc/PowerDistribution.h b/wpilibc/src/main/native/include/frc/PowerDistribution.h index 28db7fc9b90..e3ab87b9cc6 100644 --- a/wpilibc/src/main/native/include/frc/PowerDistribution.h +++ b/wpilibc/src/main/native/include/frc/PowerDistribution.h @@ -311,6 +311,10 @@ class PowerDistribution : public wpi::Sendable, uint32_t CanWarning : 1; /** The device's CAN controller experienced a "Bus Off" event. */ uint32_t CanBusOff : 1; + /** The hardware on the device has malfunctioned. */ + uint32_t HardwareFault : 1; + /** The firmware on the device has malfunctioned. */ + uint32_t FirmwareFault : 1; /** The device has rebooted. */ uint32_t HasReset : 1;