Raise WPILib alerts for Phoenix device and CAN bus health - #54
Closed
nlaverdure wants to merge 1 commit into
Closed
nlaverdure wants to merge 1 commit into
nlaverdure wants to merge 1 commit into
Conversation
Phoenix 6 sends its automatic alerts straight to MrcLib, so they never reach WPILib's alert registry and AdvantageKit doesn't log them (#47). This covers the conditions that matter to this robot with WPILib Alerts, computed from logged inputs so replay reproduces them. Config failure: tryUntilOk returns its last StatusCode, and each module logs its drive setup, turn config, and CANcoder read and write results, with a HIGH alert per failure. A failed CANcoder config read skips the write and never seeds the turn-zero Preference, since the config then holds defaults. The read result stays latched. The setTurnZero write makes one attempt, because it runs on the main loop. Firmware: Phoenix blocks a motor's output only on a firmware/API compliancy mismatch, and setControl returns FirmwareTooOld or ApiTooOld when it does (ParentDevice.setControlPrivate). Each module keeps the setControl result and raises a HIGH alert when output is blocked. Firmware versions are logged for reference. A CANcoder disconnected alert joins the drive and turn ones. CAN bus (#50): LoggedCANBus reads CANBus.getStatus() on a background thread every 400 ms in REAL mode, since the call can block for up to 1 ms. It logs BusErrorCount, ArbitrationLostCount, RestartCount, State, Status and a sample count. CANBusHealth raises a HIGH alert for ErrorPassive, BusOff, Stopped, a failed status read, a rising bus-off or restart count, or a stalled reader, and a MEDIUM alert for ErrorWarning, each held 0.5 s. REC and TEC stay log-only. Hoot logging: FeatureFlags.HOOT_LOGGING_ENABLED, off by default, disables Phoenix's automatic .hoot logging in every mode. Verified in sim with ModuleIOSimTalonFX and injected failures (temporary, not committed): hoot file 446 KB with the flag on and none with it off; driveInitStatus=ConfigFailed and the CANcoder read-failure alert shown and held; the turn-zero Preference re-seeded after a good read and not after a failed one; firmware decode 0x1A460000 -> 26.70.0.0 matching getVersionMajor/Minor/Bugfix/Build. The default sim shows no alerts. Closes #52 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks
7 tasks
Member
Author
|
Superseded by PR 57 (#57), which merges this PR's device and CAN bus alerts with the CAN chain hint from PR 55, simplified per the 2026-09-27 review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phoenix 6 sends its automatic alerts straight to MrcLib, so they never reach WPILib's alert registry and AdvantageKit doesn't log them (#47). This PR covers the conditions that affect this robot with WPILib
Alerts, which AdvantageKit logs under/RealOutputs/Alerts. It also adds the CAN bus fields from #50.Every alert is computed from logged inputs, so replaying a log shows the same alerts.
What changed, and why it differs from #52's written tasks
Statusand CAN states on the SystemCore ports: HIGH for ErrorPassive, BusOff, Stopped, a failed status read, a rising bus-off or restart count, or a stalled reader. MEDIUM for ErrorWarning.Robot.java@3ea1eb0:195,255-257), so there's no field evidence it stays quiet on a healthy bus.setControlreturnsFirmwareTooOldorApiTooOld. Versions are logged for reference.setControlreturns that verdict (ParentDevice.setControlPrivate). Pinning versions wouldn't catch it..hootlogging is behindFeatureFlags.HOOT_LOGGING_ENABLED, off by default.hootfiles are rarely used. 6328 and Spectrum both turn off auto-logging. The pre-match display already warns when the USB drive is low.Also added:
Drive/ConstructMs, which measures boot cost. The upper bound with SC1 dead is about 18–19 s (derived from the timeouts, not measured).#50: CAN bus fields
LoggedCANBusnow logsBusErrorCount,ArbitrationLostCount,RestartCount,State,StatusandSampleCount.CANBus.getStatus()on a background thread every 400 ms, and only in REAL mode. CTRE's Javadoc says the call "can block for up to 0.001 seconds."Verified
CANBusHealthTest,PhoenixFirmwareTestandPhoenixUtilTest, all passing../gradlew buildruns 211 tests. One fails,VisionFilterTest > yawConsistency > Rejects ambiguous PnP solution with wrong yaw, and it fails the same way onmain-2027-alpha7.ModuleIOSimTalonFXand injected failures (temporary, not committed):.hootfile; off, it wrote none. Both runs had 12 Phoenix devices.DriveInitStatus = ConfigFailedraised "Drive motor setup failed on module FrontLeft (ConfigFailed)."0x1A460000→26.70.0.0, matchinggetVersionMajor/Minor/Bugfix/Build()on sim devices..hootfiles.Robot session (can't be done in sim)
/RealOutputs/LoggedRobot/UserCodeMSp50/p99 compared with a pre-change log.CANBus/SC*/SampleCountrises about 2.5 per second.CANBus/SC<n>/BusUtilization(0–1) withSystemStats/Network/CAN<n>/Utilization(percent), andBusErrorCountwithRX/ErrorsandTX/Errors, to check bus numbering and overlap.Drive/ConstructMswith a healthy bus and with SC1 unplugged at boot.*FirmwareBlockedalert./U/logs/session_Ncontains only.wpilogfiles.OK/ErrorActive. Record State/TEC/REC with the PD and gyro unplugged.Closes #52
Refs #50
🤖 Generated with Claude Code