Class PhoenixSignals
BaseStatusSignals.
Grouping signals and refreshing them together ensures that all sampled values share the same synchronization fence, minimizing timestamp skew between related measurements.
Signals are maintained in separate groups depending on whether they are sourced from a CANivore bus or the roboRIO CAN bus, as Phoenix requires refresh calls to be performed per bus.
This class is purely static and is not intended to be instantiated.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidRefreshes all registered Phoenix signals.static voidregisterSignals(boolean canivore, com.ctre.phoenix6.BaseStatusSignal... signals) Registers one or more Phoenix signals for synchronized refreshing.static voidtryUntilOk(int maxAttempts, Supplier<com.ctre.phoenix6.StatusCode> command) Repeatedly executes a Phoenix command until it succeeds or the maximum number of attempts is reached.
-
Method Details
-
tryUntilOk
Repeatedly executes a Phoenix command until it succeeds or the maximum number of attempts is reached.This is useful for Phoenix configuration calls that may transiently fail during startup or bus contention.
- Parameters:
maxAttempts- maximum number of attempts before giving upcommand- supplier that executes the Phoenix command and returns aStatusCode
-
registerSignals
public static void registerSignals(boolean canivore, com.ctre.phoenix6.BaseStatusSignal... signals) Registers one or more Phoenix signals for synchronized refreshing.All registered signals will be refreshed together when
refreshAll()is called, ensuring consistent timestamps across related measurements.Signals must be registered to the correct bus (CANivore vs roboRIO). Mixing buses in a single refresh call is not supported by Phoenix.
This method should typically be called during subsystem construction or robot initialization, before periodic refreshes occur.
- Parameters:
canivore-trueif the signals are on the CANivore bus,falseif they are on the roboRIO CAN bussignals- one or moreBaseStatusSignals to register
-
refreshAll
public static void refreshAll()Refreshes all registered Phoenix signals.This method should be called once per control loop to update all registered signals in a synchronized manner.
Signals on the CANivore and roboRIO buses are refreshed separately, but each group is internally synchronized.
-