phoenix6

Subpackages

Submodules

Package Contents

class phoenix6.AllTimestamps

A collection of timestamps for a received signal.

Constructs a new AllTimestamps object.

update(system_timestamp_seconds: phoenix6.units.second, system_timestamp_source: phoenix6.timestamp.TimestampSource, system_timestamp_valid: bool, canivore_timestamp_seconds: phoenix6.units.second, canivore_timestamp_source: phoenix6.timestamp.TimestampSource, canivore_timestamp_valid: bool, device_timestamp_seconds: phoenix6.units.second, device_timestamp_source: phoenix6.timestamp.TimestampSource, device_timestamp_valid: bool)

Update this timestamp with the new timestamps

Parameters:
  • system_timestamp_seconds (second) – New system timestamp seconds

  • system_timestamp_source (TimestampSource) – New System timestamp source

  • system_timestamp_valid (bool) – Whether new System timestamp is valid

  • canivore_timestamp_seconds (second) – New CANivore timestamp seconds

  • canivore_timestamp_source (TimestampSource) – New CANivore timestamp source

  • canivore_timestamp_valid (bool) – Whether new CANivore timestamp is valid

  • device_timestamp_seconds (second) – New Device timestamp seconds

  • device_timestamp_source (TimestampSource) – New Device timestamp source

  • device_timestamp_valid (bool) – Whether new Device timestamp is valid

get_best_timestamp() phoenix6.timestamp.Timestamp

Gets the most accurate timestamp available.

The timestamp sources from most to least accurate are:

  • TimestampSource.Device

  • TimestampSource.CANivore

  • TimestampSource.System

Note that some of these sources may not be available.

Returns:

The most accurate timestamp available

Return type:

Timestamp

get_system_timestamp() phoenix6.timestamp.Timestamp

Get the timestamp as reported by the TimestampSource.System source.

Returns:

Timestamp as reported by system

Return type:

Timestamp

get_canivore_timestamp() phoenix6.timestamp.Timestamp

Get the timestamp as reported by the TimestampSource.CANivore source.

Returns:

Timestamp as reported by the CANivore

Return type:

Timestamp

get_device_timestamp() phoenix6.timestamp.Timestamp

Get the timestamp as reported by the TimestampSource.Device source.

Returns:

Timestamp as reported by the device

Return type:

Timestamp

class phoenix6.Timestamp(time: phoenix6.units.second, source: TimestampSource, is_valid: bool = True)

Information about the timestamp of a signal.

Construct a new Timestamp for the given source.

Parameters:
  • time (second) – The time in seconds

  • source (TimestampSource) – The timestamp source

property time: phoenix6.units.second

Get the time of this timestamp

Returns:

Time of this timestamp

Return type:

second

property source: TimestampSource

Get the source of this timestamp

Returns:

Source of this timestamp

Return type:

TimestampSource

property is_valid: bool

Get whether this timestamp is valid or not

Returns:

True if this timestamp is valid

Return type:

bool

update(time: phoenix6.units.second, source: TimestampSource, valid: bool)

Update this timestamp with provided information

Parameters:
  • time (second) – Time in seconds

  • source (TimestampSource) – Timestamp source

  • valid (bool) – Whether the timestamp is valid or not

get_latency() phoenix6.units.second

Get the latency of this timestamp compared to now

Returns:

Difference between now and this timestamp

Return type:

second

class phoenix6.BaseStatusSignal(device_identifer: phoenix6.hardware.device_identifier.DeviceIdentifier, spn: int, signal_name: str, report_if_old_func: Callable[[], None], units_generator: Callable[[], dict[int, str]] | None)

Bases: abc.ABC

Common parent type for the :ref:StatusSignal: object.

This can be used for a collection of :ref:StatusSignal: objects, but we recommend using the derived class instead when possible

Normal Constructor for a BaseStatusSignal

Parameters:
  • device_identifer (DeviceIdentifier) – Identifier of the device this signal is associated to

  • spn (int) – SPN Index of this signal

  • signal_name (str) – Name of this signal

  • report_if_old_func (Callable[[], None]) – Function to call if device is too old

  • units_generator (Callable[[], dict[int, StatusSignal]]) – Callable function that returns a dictionary mapping a signal to its units

property name: str

The name of this signal.

Returns:

The name of this signal

Return type:

str

property units: str

The units associated with this signal.

Returns:

Units associated with this signal

Return type:

str

property value_as_double: float

The value as a double instead of the generic type. This may be helpful when working with the base class.

Returns:

Signal as a double

Return type:

float

property all_timestamps: phoenix6.all_timestamps.AllTimestamps

All the timestamps associated with this signal.

Returns:

All the timestamps associated with this signal

Return type:

AllTimestamps

property timestamp: phoenix6.timestamp.Timestamp

The most accurate timestamp available for this signal.

The timestamp sources from most to least accurate are:

  • TimestampSource.Device

  • TimestampSource.CANivore

  • TimestampSource.System

Note that some of these sources may not be available.

Returns:

The most accurate timestamp available for this signal

Return type:

Timestamp

property status: phoenix6.status_code.StatusCode

The status of the last time this signal was updated.

Returns:

Status of the last time this signal was updated

Return type:

StatusCode

property has_updated: bool

Whether the signal has been updated since the last check.

Note that the signal must be refreshed before calling this routine.

Returns:

True if the signal has updated since the previous call of this routine

Return type:

bool

set_update_frequency(frequency_hz: phoenix6.units.hertz, timeout_seconds: phoenix6.units.second = 0.1) phoenix6.status_code.StatusCode

Sets the rate at which the device will publish this signal.

A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz. Additionally, some update frequencies are not supported and will be promoted up to the next highest supported frequency.

If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.

Parameters:
  • frequency_hz (hertz) – Rate to publish the signal in Hz

  • timeout_seconds (second) – Maximum amount of time to wait when performing the action

Returns:

Status code of setting the update frequency

Return type:

StatusCode

get_applied_update_frequency() phoenix6.units.hertz

Gets the rate at which the device will publish this signal.

This is typically the last value passed into set_update_frequency. The returned value may be higher if another StatusSignal in the same status frame has been set to a higher update frequency.

Returns:

Applied update frequency of the signal in Hz

Return type:

hertz

static get_latency_compensated_value(signal: StatusSignal[float], signal_slope: StatusSignal[float], max_latency_seconds: phoenix6.units.second = 0.3) float

Performs latency compensation on signal using the signalSlope and signal’s latency to determine the magnitude of compensation. The caller must refresh these StatusSignals beforehand; this function only does the math required for latency compensation.

Important: The signalSlope must be the rate of change of the signal. If it is not the latency compensation may not perform as expected.

Example: compensatedTurns = BaseStatusSignal.get_latency_compensated_value(fx.get_position(), fx.get_velocity())

Parameters:
  • signal (StatusSignal[float]) – Signal to be latency compensated. Caller must make sure this signal is up to date either by calling StatusSignal.refresh() or StatusSignal.wait_for_update(double).

  • signal_slope – Derivative of signal that informs compensation magnitude. Caller must make sure this signal is up to date either by calling StatusSignal.refresh() or StatusSignal.wait_for_update(double).

  • max_latency_seconds (second) – The maximum amount of latency to compensate for in seconds. A negative or zero value disables the max latency cap. This is used to cap the contribution of latency compensation for stale signals, such as after the device has been disconnected from the CAN bus.

Returns:

Latency compensated value from the signal StatusSignal.

Return type:

float

static wait_for_all(timeout_seconds: phoenix6.units.second, *signals: BaseStatusSignal | list[BaseStatusSignal]) phoenix6.status_code.StatusCode

Waits for new data on all provided signals up to timeout. This API is typically used with CANivore Bus signals as they will be synced using the CANivore Timesync feature and arrive simultaneously. Signals on a roboRIO bus cannot be synced and may require a significantly longer blocking call to receive all signals.

Note that CANivore Timesync requires Phoenix Pro.

This can also be used with a timeout of zero to refresh many signals at once, which is faster than calling refresh() on every signal. This is equivalent to calling refresh_all.

If a signal arrives multiple times while waiting, such as when not using CANivore Timesync, the newest signal data is fetched. Additionally, if this function times out, the newest signal data is fetched for all signals (when possible). We recommend checking the individual status codes using self.status when this happens.

Parameters:
  • timeout_seconds (second) – Maximum time to wait for new data in seconds. Pass zero to refresh all signals without blocking.

  • signals (tuple[BaseStatusSignal | list[BaseStatusSignal], ...]) – Signals to wait for new data against

Returns:

An InvalidParamValue if signals array is empty, InvalidNetwork if signals are on different CAN bus networks, RxTimeout if it took longer than timeoutSeconds to receive all the signals, MultiSignalNotSupported if using the roboRIO bus with more than one signal and a non-zero timeout. An OK status code means that all signals arrived within timeoutSeconds and they are all OK.

Any other value represents the StatusCode of the first failed signal. Check the status of each signal to determine which ones failed.

Return type:

StatusCode

static refresh_all(*signals: BaseStatusSignal | list[BaseStatusSignal]) phoenix6.status_code.StatusCode

Performs a non-blocking refresh on all provided signals.

This provides a performance improvement over separately calling refresh() on each signal.

Parameters:

signals (tuple[BaseStatusSignal | list[BaseStatusSignal], ...]) – Signals to refresh

Returns:

An InvalidParamValue if signals array is empty, InvalidNetwork if signals are on different CAN bus networks. An OK status code means that all signals are OK.

Any other value represents the StatusCode of the first failed signal. Check the status of each signal to determine which ones failed.

Return type:

StatusCode

static is_all_good(*signals: BaseStatusSignal | list[BaseStatusSignal]) bool

Checks if all signals have an OK error code.

Parameters:

signals (tuple[BaseStatusSignal | list[BaseStatusSignal], ...]) – Signals to check error code of

Returns:

True if all are good, False otherwise

Return type:

bool

static set_update_frequency_for_all(frequency_hz: phoenix6.units.hertz, *signals: BaseStatusSignal | list[BaseStatusSignal]) phoenix6.status_code.StatusCode

Sets the update frequency of all specified status signals to the provided common frequency.

A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz. Additionally, some update frequencies are not supported and will be promoted up to the next highest supported frequency.

If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.

This will wait up to 0.100 seconds (100ms) for each signal.

Parameters:
  • frequency_hz (hertz) – Rate to publish the signal in Hz

  • signals (tuple[BaseStatusSignal | list[BaseStatusSignal], ...]) – Signals to apply the update frequency to

Returns:

Status code of the first failed update frequency set call, or OK if all succeeded

Return type:

StatusCode

class phoenix6.StatusSignal(error: phoenix6.status_code.StatusCode | None, device_identifier: phoenix6.hardware.device_identifier.DeviceIdentifier, spn: int, signal_name: str, report_if_old_func: Callable[[], None], units_generator: Callable[[], dict[int, str]] | None, signal_type: type[T])

Bases: phoenix6.base_status_signal.BaseStatusSignal, Generic[T]

Represents a status signal with data of type T, and operations available to retrieve information about the signal.

Construct a StatusSignal object

Parameters:
  • error (StatusCode) – Status code to construct this with. If this is not None, this StatusSignal will be an error-only StatusSignal

  • device_identifier (DeviceIdentifier) – Device Identifier for this signal

  • spn (int) – SPN for this signal

  • report_if_old_func (Callable[[], None]) – Function to call if device is too old

  • units_generator (Callable[[], dict[int, StatusSignal]]) – Callable function that returns a dictionary mapping a signal to its units

  • signal_name (str) – Name of signal

  • signal_type (type) – Type of signal for the generic

property value: T

Gets the value inside this StatusSignal

Returns:

The value of this StatusSignal

Return type:

T

refresh(report_error: bool = True) StatusSignal[T]

Refreshes the value of this status signal.

If the user application caches this StatusSignal object instead of periodically fetching it from the hardware device, this function must be called to fetch fresh data.

This performs a non-blockin refresh operation. If you want to wait until you receive data, call wait_for_update instead.

Parameters:

report_error (bool, optional) – Whether to report any errors to the console, defaults to True

Returns:

Reference to itself

Return type:

StatusSignal[T]

wait_for_update(timeout_seconds: phoenix6.units.second, report_error: bool = True) StatusSignal[T]

Waits up to timeout_seconds to get up-to-date status signal value.

This performs a blocking refresh operation. If you want to non-blocking refresh the signal, call refresh instead.

Parameters:
  • timeout_seconds (second) – Maximum time to wait for a signal to update

  • report_error (bool, optional) – Whether to report any errors to the console, defaults to True

Returns:

Reference to itself

Return type:

StatusSignal[T]

is_near(target: T, tolerance: T) bool

Checks whether the signal is near a target value within the given tolerance. This signal must be a numeric type.

Parameters:
  • target (T) – The target value of the signal

  • tolerance (T) – The error tolerance between the target and measured values

Returns:

Whether the signal is near the target value

Return type:

bool

as_supplier() Callable[[], T]

Returns a lambda that calls refresh and value on this object. This is useful for command-based programming.

Returns:

Lambda that refreshes this signal and returns it

Return type:

Callable[[], T]

get_data_copy() SignalMeasurement[T]

Get a basic data-only container with this information, to be used for things such as data logging.

If looking for Phoenix 6 logging features, see the SignalLogger class instead.

This function returns a new object every call. As a result, we recommend that this is not called inside a tight loop.

Returns:

Basic structure with all relevant information

Return type:

SignalMeasurement[T]

class phoenix6.SignalMeasurement

Bases: Generic[T]

Information from a single measurement of a status signal.

name: str = "''"

The name of the signal

value: T = 'None'

The value of the signal

timestamp: phoenix6.units.second = '0.0'

Timestamp of when the data point was taken, in seconds

units = "''"

The units of the signal measurement

status

Status code response of getting the data

class phoenix6.StatusSignalCollection(*signals: phoenix6.base_status_signal.BaseStatusSignal | list[phoenix6.base_status_signal.BaseStatusSignal])

Class to manage bulk refreshing device status signals.

Creates a new collection of status signals, optionally adding the provided signals to the collection.

Parameters:

signals (tuple[BaseStatusSignal | list[BaseStatusSignal], ...]) – Signals to add

add_signals(*signals: phoenix6.base_status_signal.BaseStatusSignal | list[phoenix6.base_status_signal.BaseStatusSignal])

Adds the provided signals to the collection.

Parameters:

signals (tuple[BaseStatusSignal | list[BaseStatusSignal], ...]) – Signals to add

wait_for_all(timeout_seconds: phoenix6.units.second) phoenix6.status_code.StatusCode

Waits for new data on all signals up to timeout. This API is typically used with CANivore Bus signals as they will be synced using the CANivore Timesync feature and arrive simultaneously. Signals on a roboRIO bus cannot be synced and may require a significantly longer blocking call to receive all signals.

Note that CANivore Timesync requires Phoenix Pro.

This can also be used with a timeout of zero to refresh many signals at once, which is faster than calling refresh() on every signal. This is equivalent to calling self.refresh_all.

If a signal arrives multiple times while waiting, such as when not using CANivore Timesync, the newest signal data is fetched. Additionally, if this function times out, the newest signal data is fetched for all signals (when possible). We recommend checking the individual status codes using self.status when this happens.

Parameters:

timeout_seconds (second) – Maximum time to wait for new data in seconds. Pass zero to refresh all signals without blocking.

Returns:

An InvalidParamValue if this signal collection is empty, InvalidNetwork if signals are on different CAN bus networks, RxTimeout if it took longer than timeoutSeconds to receive all the signals, MultiSignalNotSupported if using the roboRIO bus with more than one signal and a non-zero timeout. An OK status code means that all signals arrived within timeoutSeconds and they are all OK.

Any other value represents the StatusCode of the first failed signal. Check the status of each signal to determine which ones failed.

Return type:

StatusCode

refresh_all() phoenix6.status_code.StatusCode

Performs a non-blocking refresh on all signals.

This provides a performance improvement over separately calling refresh() on each signal.

Returns:

An InvalidParamValue if this signal collection is empty, InvalidNetwork if signals are on different CAN bus networks. An OK status code means that all signals are OK.

Any other value represents the StatusCode of the first failed signal. Check the status of each signal to determine which ones failed.

Return type:

StatusCode

set_update_frequency_for_all(frequency_hz: phoenix6.units.hertz) phoenix6.status_code.StatusCode

Sets the update frequency of all status signals to the provided common frequency.

A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz.

If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.

This will wait up to 0.100 seconds (100ms) for each signal.

Parameters:

frequency_hz (hertz) – Rate to publish the signal in Hz

Returns:

Status code of the first failed update frequency set call, or OK if all succeeded

Return type:

StatusCode

is_all_good() bool

Checks if all signals have an OK error code.

Returns:

True if all are good, False otherwise

Return type:

bool

class phoenix6.CANBus(canbus: str = '', hoot_filepath: str | None = None)

Class for getting information about an available CAN bus.

A CANBus can optionally be constructed with an associated hoot file, which loads it for replay (equivalent to calling HootReplay.load_file).

Only one hoot log may be replayed at a time, so only one CAN bus should be constructed with a hoot file.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

For the native roboRIO CAN bus, use CANBus.roborio(str | None) instead.

Parameters:
  • canbus (str, optional) –

    Name of the CAN bus. Possible CAN bus strings are:

    • ”rio” for the native roboRIO CAN bus

    • CANivore name or serial number

    • SocketCAN interface (non-FRC Linux only)

    • ”*” for any CANivore seen by the program

    • empty string (default) to select the default for the system:

      • ”rio” on roboRIO

      • ”can0” on Linux

      • ”*” on Windows

  • hoot_filepath (str | None, optional) – Path and name of the hoot file to load

property name: str

Get the name used to construct this CAN bus.

Returns:

Name of the CAN bus

Return type:

str

static roborio(hoot_filepath: str | None = None) CANBus

Creates a new CAN bus for the native roboRIO bus.

The CANBus can optionally be constructed with an associated hoot file, which loads it for replay (equivalent to calling HootReplay.load_file).

Only one hoot log may be replayed at a time, so only one CAN bus should be constructed with a hoot file.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

Parameters:

hoot_filepath (str | None, optional) – Path and name of the hoot file to load

Returns:

The native roboRIO CAN bus

Return type:

CANBus

is_network_fd() bool

Gets whether the CAN bus is a CAN FD network.

Returns:

True if the CAN bus is CAN FD

Return type:

bool

get_status() CANBusStatus

Gets the status of the CAN bus, including the bus utilization and the error counters.

This can block for up to 0.001 seconds (1 ms).

Returns:

Status of the CAN bus

Return type:

CANBusStatus

class phoenix6.HootAutoReplay

Class for handling automatic logging and replay of custom signal inputs. Each subsystem typically creates a new instance of this class.

Note that all StatusSignals are automatically logged and replayed, so they do not need to be registered with this class. Additionally, the SignalLogger must be separately started at the start of the robot program.

“Inputs” are signals measured directly from devices that should be replayed unmodified. By comparison, a processed signal, such as a signal indicating that a mechanism has reached the target, is considered an “output”. This class should only be used with inputs.

Inputs are registered with a getter that returns a value to log and a setter that updates the value in your robot program. For example, a Vision class with a self._camera_pose: Pose2d input would register the input using:

``` def _set_camera_pose(val: SignalMeasurement[Pose2d]):

self._camera_pose = val.value

self._auto_replay = (

HootAutoReplay() .with_struct(

“Vision/CameraPose”, Pose2d, lambda: self._camera_pose, _set_camera_pose

)

)

After registering all relevant inputs, call self.update() periodically to perform the following:

  • In normal/simulated robot operation, registered inputs will be fetched from your robot code using the provided getter, and then logged using the SignalLogger.

  • During Hoot Replay, registered inputs will be fetched from HootReplay and then updated in your robot code using the provided setter.

update()

Updates the state of the robot program by doing one of the following:

  • In normal/simulated robot operation, registered inputs will be fetched from your robot code using the provided getter, and then logged using the SignalLogger.

  • During Hoot Replay, registered inputs will be fetched from HootReplay and then updated in your robot code using the provided setter.

This should be called periodically, typically in the subsystem.

with_timestamp_replay() HootAutoReplay

Registers Timer.getTimestamp() logging and playback with this instance. This should only be applied to one instance in the robot program.

The update() of this HootAutoReplay instance must be run at the start of robotPeriodic() before the CommandScheduler is run.

Returns:

this object

Return type:

HootAutoReplay

with_joystick_replay() HootAutoReplay

Registers joystick logging and playback with this instance. This should only be applied to one instance in the robot program.

To get joysticks to playback during Hoot Replay, “Turn off DS” must be checked in the simulation GUI (under “DS” at the top of the window). Additionally, the update() of this HootAutoReplay instance must be run at the start of robotPeriodic() before the CommandScheduler is run.

Returns:

this object

Return type:

HootAutoReplay

with_schema_value(name: str, schema_name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType, schema: bytes | str, getter: Callable[[], bytes], setter: Callable[[phoenix6.status_signal.SignalMeasurement[bytearray]], None]) HootAutoReplay

Registers the schema-serialized bytes as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • schema_name (str) – Name of the schema

  • schema_type (HootSchemaType) – Type of the schema, such as struct or protobuf

  • schema (bytes | str) – Schema bytes to write

  • getter (Callable[[], bytes]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[bytearray]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_struct(name: str, struct: type[T], getter: Callable[[], T], setter: Callable[[phoenix6.status_signal.SignalMeasurement[T]], None]) HootAutoReplay

Registers the WPILib Struct as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • struct (type[T]) – Type of struct to serialize

  • getter (Callable[[], T]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[T]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_struct_array(name: str, struct: type[T], getter: Callable[[], list[T]], setter: Callable[[phoenix6.status_signal.SignalMeasurement[list[T]]], None]) HootAutoReplay

Registers the array of WPILib Structs as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • struct (type[T]) – Type of struct to serialize

  • getter (Callable[[], list[T]]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[list[T]]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_raw(name: str, getter: Callable[[], bytes], setter: Callable[[phoenix6.status_signal.SignalMeasurement[bytearray]], None]) HootAutoReplay

Registers the raw data bytes as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], bytes]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[bytearray]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_boolean(name: str, getter: Callable[[], bool], setter: Callable[[phoenix6.status_signal.SignalMeasurement[bool]], None]) HootAutoReplay

Registers the boolean as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], bool]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[bool]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_integer(name: str, getter: Callable[[], int], setter: Callable[[phoenix6.status_signal.SignalMeasurement[int]], None]) HootAutoReplay

Registers the integer as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], int]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[int]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_float(name: str, getter: Callable[[], float], setter: Callable[[phoenix6.status_signal.SignalMeasurement[float]], None]) HootAutoReplay

Registers the float as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], float]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[float]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_double(name: str, getter: Callable[[], float], setter: Callable[[phoenix6.status_signal.SignalMeasurement[float]], None]) HootAutoReplay

Registers the double as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], float]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[float]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_string(name: str, getter: Callable[[], str], setter: Callable[[phoenix6.status_signal.SignalMeasurement[str]], None]) HootAutoReplay

Registers the string as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], str]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[str]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_boolean_array(name: str, getter: Callable[[], list[bool]], setter: Callable[[phoenix6.status_signal.SignalMeasurement[list[bool]]], None]) HootAutoReplay

Registers the array of booleans as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], list[bool]]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[list[bool]]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_integer_array(name: str, getter: Callable[[], list[int]], setter: Callable[[phoenix6.status_signal.SignalMeasurement[list[int]]], None]) HootAutoReplay

Registers the array of integers as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], list[int]]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[list[int]]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_float_array(name: str, getter: Callable[[], list[float]], setter: Callable[[phoenix6.status_signal.SignalMeasurement[list[float]]], None]) HootAutoReplay

Registers the array of floats as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], list[float]]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[list[float]]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_double_array(name: str, getter: Callable[[], list[float]], setter: Callable[[phoenix6.status_signal.SignalMeasurement[list[float]]], None]) HootAutoReplay

Registers the array of doubles as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], list[float]]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[list[float]]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

with_string_array(name: str, getter: Callable[[], list[str]], setter: Callable[[phoenix6.status_signal.SignalMeasurement[list[str]]], None]) HootAutoReplay

Registers the array of strings as a Hoot-Replayed input.

Parameters:
  • name (str) – Name of the signal in the log

  • getter (Callable[[], list[str]]) – Function that returns the current value of the input

  • setter (Callable[[SignalMeasurement[list[str]]], None]) – Function that sets the input to a new value

Returns:

this object

Return type:

HootAutoReplay

class phoenix6.HootReplay

Static class for controlling Phoenix 6 hoot log replay.

This replays the given hoot log in simulation. Hoot logs can be created by a robot program using SignalLogger. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

This replays all signals in the given hoot log in simulation. Hoot logs can be created by a robot program using SignalLogger. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

The signal logger always runs while replay is running. All custom signals written during replay will be automatically placed under hoot_replay/. Additionally, the log will contain all status signals and custom signals from the original log.

During replay, all transmits from the robot program are ignored. This includes features such as control requests, configs, and setting signal update frequency. Additionally, Tuner X is not functional during log replay.

To use Hoot Replay, call load_file(str) before any devices are constructed to load a hoot file and start replay. Alternatively, the CANBus(str, str) constructor can be used when constructing devices.

After devices are constructed, Hoot Replay can be controlled using play(), pause(), stop(), and restart(). Additionally, Hoot Replay supports step_timing(second) while paused. The current file can be closed using close_file(), after which a new file may be loaded.

static load_file(filepath: str) phoenix6.status_code.StatusCode

Loads the given file and starts signal log replay. Only one hoot log, corresponding to one CAN bus, may be replayed at a time.

This must be called before constructing any devices or checking CAN bus status. The CANBus(canbus, hoot_filepath) constructor can be used when constructing devices to guarantee that this API is called first.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

This API is blocking on the file read.

Parameters:

filepath (str) – Path and name of the hoot file to load

Returns:

Status of opening and reading the file for replay

Return type:

StatusCode

Raises:

ValueError – The file is invalid, unlicensed, or targets a different version of Phoenix 6

static close_file()

Ends the hoot log replay. This stops the replay if it is running, closes the hoot log, and clears all signals read from the file.

static is_file_loaded() bool

Gets whether a valid hoot log file is currently loaded.

Returns:

True if a valid hoot log file is loaded

Return type:

bool

static play() phoenix6.status_code.StatusCode

Starts or resumes the hoot log replay.

Returns:

Status of starting or resuming replay

Return type:

StatusCode

static pause() phoenix6.status_code.StatusCode

Pauses the hoot log replay. This maintains the current position in the log replay so it can be resumed later.

Returns:

Status of pausing replay

Return type:

StatusCode

static stop() phoenix6.status_code.StatusCode

Stops the hoot log replay. This resets the current position in the log replay to the start.

Returns:

Status of stopping replay

Return type:

StatusCode

classmethod restart() phoenix6.status_code.StatusCode

Restarts the hoot log replay from the start of the log. This is equivalent to calling stop() followed by play().

Returns:

Status of restarting replay

Return type:

StatusCode

classmethod is_playing() bool

Gets whether hoot log replay is actively playing.

This API will return true in programs that do not support replay, making it safe to call without first checking if the program supports replay.

Returns:

True if replay is playing back signals

Return type:

bool

static wait_for_playing(timeout: phoenix6.units.second) bool

Waits until hoot log replay is actively playing.

This API will immediately return true in programs that do not support replay, making it safe to call without first checking if the program supports replay.

Since this can block the calling thread, this should not be called with a non-zero timeout on the main thread.

This can also be used with a timeout of 0 to perform a non-blocking check, which is equivalent to is_playing().

Parameters:

timeout (second) – Max time to wait for replay to start playing

Returns:

True if replay is playing back signals

Return type:

bool

static is_finished() bool

Gets whether hoot log replay has reached the end of the log.

Returns:

True if replay has reached the end of the log, or if no log is currently loaded

Return type:

bool

static set_speed(speed: float)

Sets the speed of the hoot log replay. A speed of 1.0 corresponds to replaying the file in real time, and larger values increase the speed.

  • Minimum Value: 0.01

  • Maximum Value: 100.0

  • Default Value: 1.0

Parameters:

speed (float) – Speed of the hoot log replay

static step_timing(step_time_seconds: phoenix6.units.second) phoenix6.status_code.StatusCode

Advances the hoot log replay time by the given value. Replay must be paused or stopped before advancing its time.

Parameters:

step_time_seconds (second) – The amount of time to advance

Returns:

Status of advancing the replay time

Return type:

StatusCode

classmethod get_schema_value(name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType) phoenix6.status_signal.SignalMeasurement[bytearray]

Gets a schema-serialized user signal.

In an FRC robot program, users can call self.get_struct and self.get_struct_array to directly get schema values instead.

Parameters:
  • name (str) – Name of the signal

  • schema_type (HootSchemaType) – Type of the schema, such as struct or protobuf

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[bytearray]

classmethod get_struct(name: str, struct: type[T]) phoenix6.status_signal.SignalMeasurement[T | None]

Gets a WPILib Struct user signal.

Parameters:
  • name (str) – Name of the signal

  • struct (type[T]) – Type of struct to deserialize

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[T | None]

classmethod get_struct_array(name: str, struct: type[T]) phoenix6.status_signal.SignalMeasurement[list[T] | None]

Gets a WPILib Struct array user signal.

Parameters:
  • name (str) – Name of the signal

  • struct (type[T]) – Type of struct to deserialize

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[list[T] | None]

classmethod get_raw(name: str) phoenix6.status_signal.SignalMeasurement[bytearray]

Gets a raw-bytes user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[bytearray]

classmethod get_boolean(name: str) phoenix6.status_signal.SignalMeasurement[bool]

Gets a boolean user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[bool]

classmethod get_integer(name: str) phoenix6.status_signal.SignalMeasurement[int]

Gets an integer user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[int]

classmethod get_float(name: str) phoenix6.status_signal.SignalMeasurement[float]

Gets a float user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[float]

classmethod get_double(name: str) phoenix6.status_signal.SignalMeasurement[float]

Gets a double user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[float]

classmethod get_string(name: str) phoenix6.status_signal.SignalMeasurement[str]

Gets a string user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[str]

classmethod get_boolean_array(name: str) phoenix6.status_signal.SignalMeasurement[list[bool]]

Gets a boolean array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[list[bool]]

classmethod get_integer_array(name: str) phoenix6.status_signal.SignalMeasurement[list[int]]

Gets an integer array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[list[int]]

classmethod get_float_array(name: str) phoenix6.status_signal.SignalMeasurement[list[float]]

Gets a float array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[list[float]]

classmethod get_double_array(name: str) phoenix6.status_signal.SignalMeasurement[list[float]]

Gets a double array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[list[float]]

classmethod get_string_array(name: str) phoenix6.status_signal.SignalMeasurement[list[str]]

Gets a string array user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalMeasurement[list[str]]

class phoenix6.HootSchemaType(*args, **kwds)

Bases: enum.Enum

Supported schema types for a hoot user signal.

STRUCT = '1'

Serialize using the WPILib Struct format.

PROTOBUF = '2'

Serialize using the Protobuf format.

class phoenix6.Orchestra(instruments: list[phoenix6.hardware.traits.common_device.CommonDevice] = [], filepath: str = '')

Orchestra is used to play music through devices. It uses a “Chirp” (.chrp) music file that can be generated using Phoenix Tuner. Chirp files are generated from standard MIDI files.

Any Chirp file located in the src/main/deploy directory of your FRC project will automatically be copied to the roboRIO on code deploy.

Unless AudioConfigs.allow_music_dur_disable is enabled, the robot must be enabled to play music. Additionally, devices playing in Orchestra will not run any other control requests while Orchestra is running. Users can :ref:pause: or :ref:stop: the Orchestra to re-enable device control.

Each device can only play a single track within the music file. For multi-track files, multiple devices are needed. Devices can be added with an explicit track number. Otherwise, the first track will be played through the first Talon FX added, the second track will be played through the second Talon FX added, etc.

To use Orchestra:

  • Add the Talon FXs to be used as instruments using :ref:add_instrument:.

  • Load the Chirp file to be played using :ref:load_music:. This can also

be done in the Orchestra constructor.

Both of these can also be done in the Orchestra constructor.

Once ready, the Orchestra can be controlled using :ref:play:/:ref:pause:/:ref:stop:. New music files can be loaded at any time.

Parameters:
  • instruments (list[CommonDevice]) – A list of devices that will be used as instruments in the orchestra

  • filepath (str) – The path to the music file to immediately load into the orchestra. The API is blocking on the file read.

close()

Closes this Orchestra instance.

add_instrument(instrument: phoenix6.hardware.traits.common_device.CommonDevice) phoenix6.status_code.StatusCode

Adds an instrument to the orchestra.

This adds the instrument to the next track; it does not wrap back to track 0 if all tracks have been filled. To assign multiple instruments to a track, use add_instrument_with_track.

Parameters:

instrument (CommonDevice) – The device to add to the orchestra

Returns:

Status code of adding the device

Return type:

StatusCode

add_instrument_with_track(instrument: phoenix6.hardware.traits.common_device.CommonDevice, track_number: int) phoenix6.status_code.StatusCode

Adds an instrument to the orchestra on the given track.

This can be used to assign multiple instruments to a track.

Parameters:
  • instrument (CommonDevice) – The device to add to the orchestra

  • track_number (int) – The track number the device should play, starting at 0

Returns:

Status code of adding the device

Return type:

StatusCode

clear_instruments() phoenix6.status_code.StatusCode

Clears all instruments in the orchestra.

Returns:

Status code of clearing all devices

Return type:

StatusCode

load_music(filepath: str) phoenix6.status_code.StatusCode

Loads a Chirp file at the specified file path.

If the Chirp file is inside your “src/main/deploy” directory, it will be automatically deployed to a default directory on the roboRIO when you deploy code. For these files, the name and file extension is sufficient.

A Chirp file can be created from a MIDI file using Phoenix Tuner.

This API is blocking on the file read.

Parameters:

filepath (str) – The path to the Chirp file

Returns:

Status code of loading the Chirp file

Return type:

StatusCode

play() phoenix6.status_code.StatusCode

Plays the loaded music file. If the player is paused, this will resume the orchestra.

Returns:

Status code of playing the orchestra

Return type:

StatusCode

pause() phoenix6.status_code.StatusCode

Pauses the loaded music file. This saves the current position in the track so it can be resumed later.

Returns:

Status code of pausing the orchestra

Return type:

StatusCode

stop() phoenix6.status_code.StatusCode

Stops the loaded music file. This resets the current position in the track to the start.

Returns:

Status code of stopping the orchestra

Return type:

StatusCode

is_playing() bool

Gets whether the current track is actively playing.

Returns:

True if Orchestra is playing the music file

Return type:

bool

get_current_time() phoenix6.units.second

Gets the current timestamp of the music file. The timestamp will reset to zero whenever :ref:load_music: or :ref:stop: is called.

If :ref:isPlaying: returns false, this method can be used to determine if the music is stopped or paused.

Returns:

The current timestamp of the music file, in seconds

Return type:

second

class phoenix6.SignalLogger

Static class for controlling the Phoenix 6 signal logger.

This logs all the signals from the CAN buses into .hoot files. Each file name starts with the CANivore serial number or “rio” for the roboRIO CAN bus, followed by the timestamp. In the header of a hoot file, the CANivore name and firmware version are logged in plain text.

During an FRC match, the log file will be renamed to include the event name, match type, and match number at the start of the file name. The match type will be ‘P’ for practice matches, ‘Q’ for qualification matches, and ‘E’ for elimination matches.

During Hoot Replay, the signal logger always runs while replay is running. All custom signals written during replay will be automatically placed under hoot_replay/. Additionally, the log will contain all status signals and custom signals from the original log.

static set_path(path: str) phoenix6.status_code.StatusCode

Sets the destination for logging, restarting logger if the path changed.

If this is not called or the path is left empty, the default path will be used. The default path on the roboRIO is a logs folder on the first USB flash drive found, or /home/lvuser/logs if none is available. The default path on all other platforms is a logs folder in the current working directory.

Typical use for this routine is to use a removable USB flash drive for logging.

This is ignored during Hoot Replay, where the hoot log will always be written to a subfolder next to the log being replayed.

Parameters:

path (str) – Folder path for the log files; path must exist

Returns:

Status of setting the path and restarting the log

Return type:

StatusCode

static start() phoenix6.status_code.StatusCode

Starts logging status signals. Starts regardless of auto logging status.

If using a roboRIO 1, we recommend setting the logging path to an external drive using self.set_path to avoid running out of internal storage space.

This is ignored during Hoot Replay, where logging is automatically started when Hoot Replay starts running or restarts.

Returns:

Status of starting the logger

Return type:

StatusCode

static stop() phoenix6.status_code.StatusCode

Stops logging status signals. Stops regardless of auto logging status.

This is ignored during Hoot Replay, where logging is automatically stopped when Hoot Replay is stopped or reaches the end of the file.

Returns:

Status of stopping the logger

Return type:

StatusCode

static enable_auto_logging(enable: bool) phoenix6.status_code.StatusCode

Enables or disables auto logging.

Auto logging is only supported on the roboRIO. Additionally, on a roboRIO 1, auto logging will only be active if a USB flash drive is present.

When auto logging is enabled, logging is started by any of the following (whichever occurs first):

  • The robot is enabled.

  • It has been at least 5 seconds since program startup (allowing for calls to self.set_path), and the Driver Station is connected to the robot.

After auto logging has started the log once, logging will not be automatically stopped or restarted by auto logging.

Parameters:

enable (bool) – Whether to enable auto logging

Returns:

Status of auto logging enable/disable

Return type:

StatusCode

static add_schema(name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType, schema: bytes | str) phoenix6.status_code.StatusCode

Adds the schema to the log file.

In an FRC robot program, users can call self.write_struct and self.write_struct_array to directly write WPILib Struct values instead.

The schema name should typically exactly match the name of the type (without any extra prefix or suffix).

For protobuf, first register all relevant file descriptors by file name (such as “geometry2d.proto”). Then, for each top-level type being used, add a separate empty schema with the full name of the type (such as “wpi.proto.ProtobufPose2d”).

Parameters:
  • name (str) – Name of the schema

  • schema_type (HootSchemaType) – Type of the schema, such as struct or protobuf

  • schema – Schema bytes or string to write

Returns:

Status of adding the schema

Return type:

StatusCode

static has_schema(name: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType) bool

Checks if the schema has already been added to the log files.

Parameters:
  • name (str) – Name of the schema

  • schema_type (HootSchemaType) – Type of the schema, such as struct or protobuf

Returns:

Whether the schema has been added to the log files

Return type:

bool

static write_schema_value(name: str, schema: str, schema_type: phoenix6.hoot_schema_type.HootSchemaType, data: bytes, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the schema-serialized bytes to the log file.

In an FRC robot program, users can call self.write_struct and self.write_struct_array to directly write WPILib Struct values instead.

The name of the associated schema must exactly match the type of the data (such as “Pose2d” or “wpi.proto.ProtobufPose2d”). Additionally, the schema name must be registered with self.add_schema before calling this API.

Parameters:
  • name (str) – Name of the signal

  • schema (str) – Name of the associated schema

  • schema_type (HootSchemaType) – Type of the associated schema, such as struct or protobuf

  • data (bytes) – Serialized data bytes

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

classmethod write_struct(name: str, struct: type[T], value: T, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the WPILib Struct to the log file.

Parameters:
  • name (str) – Name of the signal

  • struct (type[T]) – Type of struct to serialize

  • value (T) – Value to write

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

classmethod write_struct_array(name: str, struct: type[T], values: list[T], latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the array of WPILib Structs to the log file.

Parameters:
  • name (str) – Name of the signal

  • struct (type[T]) – Type of struct to serialize

  • values (list[T]) – Values to write

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_raw(name: str, data: bytes, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the raw data bytes to the log file.

Parameters:
  • name (str) – Name of the signal

  • data (bytes) – Raw data bytes

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_boolean(name: str, value: bool, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the boolean to the log file.

Parameters:
  • name (str) – Name of the signal

  • value – Value to write

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_integer(name: str, value: int, units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the integer to the log file.

Parameters:
  • name (str) – Name of the signal

  • value – Value to write

  • units (str) – Units of the signal

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_float(name: str, value: float, units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the float to the log file.

Parameters:
  • name (str) – Name of the signal

  • value – Value to write

  • units (str) – Units of the signal

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_double(name: str, value: float, units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the double to the log file.

Parameters:
  • name (str) – Name of the signal

  • value – Value to write

  • units (str) – Units of the signal

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_string(name: str, value: str, latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the string to the log file.

Parameters:
  • name (str) – Name of the signal

  • value – Value to write

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_boolean_array(name: str, value: list[bool], latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the array of booleans to the log file.

Parameters:
  • name (str) – Name of the signal

  • value (list[bool]) – Array of values to write

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_integer_array(name: str, value: list[int], units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the array of integers to the log file.

Parameters:
  • name (str) – Name of the signal

  • value (list[int]) – Array of values to write

  • units (str) – Units of the signal

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_float_array(name: str, value: list[float], units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the array of floats to the log file.

Parameters:
  • name (str) – Name of the signal

  • value (list[float]) – Array of values to write

  • units (str) – Units of the signal

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_double_array(name: str, value: list[float], units: str = '', latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the array of doubles to the log file.

Parameters:
  • name (str) – Name of the signal

  • value (list[float]) – Array of values to write

  • units (str) – Units of the signal

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

static write_string_array(name: str, value: list[str], latency_seconds: phoenix6.units.second = 0) phoenix6.status_code.StatusCode

Writes the array of strings to the log file.

Parameters:
  • name (str) – Name of the signal

  • value (list[str]) – Array of values to write

  • latency_seconds (second) – Latency of the signal in seconds; this value is subtracted from the current time to get the timestamp written to the log

Returns:

Status of writing the data

Return type:

StatusCode

class phoenix6.StatusCode(*args, **kwds)

Bases: enum.Enum

Status codes reported by APIs, including OK, warnings, and errors.

property name: str

Gets the name of this StatusCode.

Returns:

Name of this StatusCode

Return type:

str

property description: str

Gets the description of this StatusCode.

Returns:

Description of this StatusCode

Return type:

str

OK = '0'

No Error

TASK_IS_BUSY = '-100'

Diagnostic Server is busy with another command.

INVALID_DEVICE_SPEC = '-101'

InvalidDeviceSpec

ECU_IS_NOT_PRESENT = '-102'

Device is not present. Verify the device is connected and powered, and that the CAN bus is terminated.

COULD_NOT_ENTER_BL = '-103'

Could not put the device into bootloader mode.

COULD_NOT_CONFIRM_BL = '-104'

Could not confirm the device has entered the bootloader.

COULD_NOT_ERASE = '-105'

Could not erase flash.

COULD_NOT_SEND_FLASH = '-106'

Could not field upgrade the device.

COULD_NOT_VALIDATE = '-107'

Bootloader could not verify integrity of the flashed application.

COULD_NOT_RUN_APP = '-108'

Could not run the device firmware application.

COULD_NOT_REQ_SET_ID = '-109'

Unable to set ID to this device.

COULD_NOT_CONFIRM_ID = '-110'

Could not verify that the changed ID took effect.

FLASH_WAS_GOOD = '-111'

Device field upgrade was successful.

APP_TOO_OLD = '-112'

Device firmware application is too old.

COULD_NOT_REQ_SET_DESC = '-113'

Unable to set name to this device.

COMPILE_SZ_IS_WRONG = '-114'

CompileSzIsWrong

GADGETEER_DEVICE_NO_SET_ID = '-115'

Cannot set the ID of a gadgeteer device.

INVALID_TASK = '-116'

This diagnostic action is not supported.

NOT_IMPLEMENTED = '-117'

Not Implemented, check latest installer.

NO_DEVICES_ON_BUS = '-118'

NoDevicesOnBus

MORE_THAN_ONE_FILE = '-119'

MoreThanOneFile

NODE_IS_INVALID = '-120'

Specified device was not found. Verify the device is connected and powered, and that the CAN bus is terminated.

INVALID_DEVICE_DESCRIPTOR = '-121'

InvalidDeviceDescriptor

COULD_NOT_SEND_CAN_FRAME = '-123'

CouldNotSendCanFrame

NORMAL_MODE_MSG_NOT_PRESENT = '-124'

NormalModeMsgNotPresent

FEATURE_NOT_SUPPORTED = '-125'

This feature is not supported.

NOT_UPDATING = '-126'

The diagnostic server is not field upgrading any devices.

CORRUPTED_POST = '-127'

CorruptedPOST

NO_CONFIGS = '-128'

This device did not report any available configs. Verify firmware and diagnostics are up-to-date.

CONFIG_FAILED = '-129'

ConfigFailed

COULD_NOT_REQ_FACTORY_DEFAULT = '-130'

Unable to factory default this device.

CUSTOM_NAME_NOT_SUPPORTED = '-131'

CustomNameNotSupported

CONFIG_READ_WRITE_MISMATCH = '-132'

The configs read from the device do not match the configs that were written.

COULD_NOT_REQ_SET_CONFIGS = '-133'

Could not apply the device configs.

INSUFFICIENT_SZ = '-134'

InsufficientSz

INVALID_MODEL = '-135'

This feature is not supported for this device model.

COULD_NOT_REQ_DEV_INFO = '-140'

CouldNotReqDevInfo

NO_CONTROLS = '-141'

This device does not support new controls.

DEVICE_IS_NULL = '-142'

DeviceIsNull

DEVICE_DID_NOT_RESPOND_TO_DIAG_REQ = '-143'

DeviceDidNotRespondToDiagReq

ONLY_SUPPORTED_IN_TUNER_X = '-144'

This feature requires Tuner X.

CANIV_CLI_ERROR = '-145'

Command-line issue with caniv.

INVALID_CRF_BAD_HEADER = '-200'

InvalidCrfBadHeader

INVALID_CRF_FILE_SZ_INVALD = '-201'

InvalidCrfFileSzInvald

INVALID_CRF_WRONG_PRODUCT = '-202'

Specified CRF is for the wrong product.

INVALID_CRF_NO_SECTS = '-203'

InvalidCrfNoSects

INVALID_CRF_BAD_SECT_HEADER = '-204'

InvalidCrfBadSectHeader

INVALID_CRF_BAD_SECT_SIZE = '-205'

InvalidCrfBadSectSize

NO_CRF_FILE = '-206'

Specified CRF file could not be found.

COULD_NOT_FIND_DYNAMIC_ID = '-300'

CouldNotFindDynamicId

DID_NOT_GET_DHCP = '-301'

DidNotGetDhcp

DID_NOT_GET_FULL_DHCP = '-302'

DidNotGetFullDhcp

INVALID_LICENSE_RESP = '-350'

InvalidLicenseResp

INVALID_CANIV_CACHE = '-351'

InvalidCanivCache

CANNOT_OPEN_SERIAL_PORT = '-500'

CannotOpenSerialPort

CANNOT_WRITE_SERIAL_PORT = '-501'

CannotWriteSerialPort

CANNOT_READ_SERIAL_PORT = '-502'

CannotReadSerialPort

CANNOT_SERIAL_TO_DEVICE = '-503'

CannotSerialToDevice

NO_SERIAL_CONTROL_FRAME_RESP = '-504'

NoSerialControlFrameResp

CANNOT_OPEN_UDP_PORT = '-600'

CannotOpenUdpPort

CANNOT_WRITE_UDP_PORT = '-601'

CannotWriteUdpPort

CANNOT_READ_UDP_PORT = '-602'

CannotReadUdpPort

CANNOT_UDP_TO_DEVICE = '-603'

CannotUdpToDevice

NO_UDP_CONTROL_FRAME_RESP = '-604'

NoUdpControlFrameResp

TIMEOUT_ISO15_RESPONSE = '-605'

TimeoutIso15Response

INVALID_JSON = '-700'

InvalidJson

APP_IS_TERMINATING = '-800'

The user application is shutting down.

CAN_MESSAGE_STALE = '1000'

CAN message is stale, data is valid but old. Check the CAN bus wiring, CAN bus utilization, and power to the device.

BUFFER_FULL = '1006'

Buffer is full, cannot insert more data.

PULSE_WIDTH_SENSOR_NOT_PRESENT = '1010'

PulseWidthSensorNotPresent

GENERAL_WARNING = '1100'

General Warning Occurred.

FIRM_VERSION_COULD_NOT_BE_RETRIEVED = '1103'

Firm Vers could not be retrieved. Use Phoenix Tuner X to check ID and firmware(CRF) version.

FEATURES_NOT_AVAILABLE_YET = '1104'

This feature will be supported in a future update.

CONTROL_MODE_NOT_VALID = '1105'

The control mode is not valid for this function.

CONTROL_MODE_NOT_SUPPORTED_YET = '1106'

This control mode is not supported yet. A future release will supported this soon.

MOT_PROF_FIRM_THRESHOLD = '1109'

Motor Controller must have >= 3.2 firmware for motion profile control mode.

MOT_PROF_FIRM_THRESHOLD2 = '1110'

Motor Controller must have >= 3.4 firmware for advanced PID0/PID1 features.

SIM_DEVICE_NOT_FOUND = '1200'

SimDeviceNotFound

SIM_PHYSICS_TYPE_NOT_SUPPORTED = '1201'

SimPhysicsTypeNotSupported

SIM_DEVICE_ALREADY_EXISTS = '1202'

SimDeviceAlreadyExists

TX_FAILED = '-1001'

Could not transmit CAN Frame.

INVALID_PARAM_VALUE = '-1002'

An invalid argument was passed into the function/VI, such as a null pointer.

RX_TIMEOUT = '-1003'

CAN frame not received/too-stale. Check the CAN bus wiring, CAN bus utilization, and power to the device.

TX_TIMEOUT = '-1004'

CAN Transmit timed out.

UNEXPECTED_ARB_ID = '-1005'

ArbID is incorrect.

CAN_OVERFLOWED = '-1006'

CanOverflowed

SENSOR_NOT_PRESENT = '-1007'

Sensor Not Present.

FIRMWARE_TOO_OLD = '-1008'

Firmware Too Old. Use Phoenix Tuner X to field upgrade your CTRE CAN device firmware(CRF). Then restart your robot application to clear this error.

COULD_NOT_CHANGE_PERIOD = '-1009'

Control Frame Period could not be changed. Most likely it is not being transmitted.

BUFFER_FAILURE = '-1010'

BufferFailure

FIRMWARE_NON_FRC = '-1011'

Firmware is legacy non-FRC version. Use Phoenix Tuner X to field upgrade your CTRE CAN device firmware(CRF). Firmware greater than 20.0 required.

GENERAL_ERROR = '-1100'

General Error Occurred.

SIG_NOT_UPDATED = '-1200'

No new response to update signal.

NOT_ALL_PID_VALUES_UPDATED = '-1201'

NotAllPIDValuesUpdated

GEN_PORT_ERROR = '-1300'

GEN_PORT_ERROR

PORT_MODULE_TYPE_MISMATCH = '-1301'

PORT_MODULE_TYPE_MISMATCH

GEN_MODULE_ERROR = '-1400'

GEN_MODULE_ERROR

MODULE_NOT_INIT_SET_ERROR = '-1401'

MODULE_NOT_INIT_SET_ERROR

MODULE_NOT_INIT_GET_ERROR = '-1402'

MODULE_NOT_INIT_GET_ERROR

WHEEL_RADIUS_TOO_SMALL = '-1500'

Wheel Radius is too small, cannot get distance traveled.

TICKS_PER_REV_ZERO = '-1501'

Ticks per revolution is 0, cannot get heading.

DISTANCE_BETWEEN_WHEELS_TOO_SMALL = '-1502'

Distance between wheels is too small, cannot get heading.

GAINS_ARE_NOT_SET = '-1503'

GainsAreNotSet

WRONG_REMOTE_LIMIT_SWITCH_SOURCE = '-1504'

Use RemoteLimitSwitchSource instead of LimitSwitchSource.

DOUBLE_VOLTAGE_COMPENSATING_WPI = '-1505'

Motor Controller Voltage Compensation should not be used with setVoltage(). This causes compensation to happen twice. Disable Voltage Compensation by calling enableVoltageCompensation(false) in order to use setVoltage().

CANDLE_ANIM_SLOT_OUT_OF_BOUNDS = '-1506'

CANdleAnimSlotOutOfBounds

INCOMPATIBLE_MODE = '-1600'

IncompatibleMode

INVALID_HANDLE = '-1601'

Handle passed into function is incorrect.

FEATURE_REQUIRES_HIGHER_FIRM = '-1700'

Features requires newer firmware version.

CONFIG_FACTORY_DEFAULT_REQUIRES_HIGHER_FIRM = '-1702'

Config factory default features require firmware >=3.10.

CONFIG_MOTION_S_CURVE_REQUIRES_HIGHER_FIRM = '-1703'

Config Motion S Curve Strength features require firmware >=4.16.

TALON_FX_FIRMWARE_PRE_V_BAT_DETECT = '-1704'

Talon FX(Falcon 500) Firmware Too Old. Use Phoenix Tuner to field upgrade your CTRE CAN device firmware(CRF) to >=20.3. Then restart your robot application to clear this error.

CANDLE_ANIMATIONS_REQUIRE_HIGHER_FIRM = '-1705'

CANdleAnimationsRequireHigherFirm

LIBRARY_COULD_NOT_BE_LOADED = '-1800'

LibraryCouldNotBeLoaded

MISSING_ROUTINE_IN_LIBRARY = '-1801'

MissingRoutineInLibrary

RESOURCE_NOT_AVAILABLE = '-1802'

ResourceNotAvailable

MUSIC_FILE_NOT_FOUND = '-1900'

Could not find music file specified, try specifying an absolute path.

MUSIC_FILE_WRONG_SIZE = '-1901'

Music file size is incorrect, could not parse correctly. Ensure you’re using Tuner to generate file.

MUSIC_FILE_TOO_NEW = '-1902'

Music file version is too new, update Phoenix to utilize this file.

MUSIC_FILE_INVALID = '-1903'

Music file is invalid. Ensure you’re using Tuner to generate file.

INVALID_ORCHESTRA_ACTION = '-1904'

An invalid orchestra action occurred. Ensure a music file is loaded.

MUSIC_FILE_TOO_OLD = '-1905'

This music file version is too old. Regenerate file using Tuner.

MUSIC_INTERRUPTED = '-1906'

Music interrupted due to one of the instruments being commanded a different control mode. Press Play to resume music.

MUSIC_NOT_SUPPORTED = '-1907'

This device doesn’t support MusicTone control mode.

INVALID_INTERFACE = '-2000'

kInvalidInterface

INVALID_GUID = '-2001'

kInvalidGuid

INVALID_CLASS = '-2002'

kInvalidClass

INVALID_PROTOCOL = '-2003'

kInvalidProtocol

INVALID_PATH = '-2004'

kInvalidPath

GENERAL_WIN_USB_ERROR = '-2005'

kGeneralWinUsbError

FAILED_SETUP = '-2006'

kFailedSetup

LISTEN_FAILED = '-2007'

kListenFailed

SEND_FAILED = '-2008'

kSendFailed

RECEIVE_FAILED = '-2009'

kReceiveFailed

INVALID_RESP_FORMAT = '-2010'

kInvalidRespFormat

WIN_USB_INIT_FAILED = '-2011'

kWinUsbInitFailed

WIN_USB_QUERY_FAILED = '-2012'

kWinUsbQueryFailed

WIN_USB_GENERAL_ERROR = '-2013'

kWinUsbGeneralError

ACCESS_DENIED = '-2014'

kAccessDenied

FIRMWARE_INVALID_RESPONSE = '-2015'

kFirmwareInvalidResponse

STATUS_CODE_NOT_INITIALIZED = '-10000'

This StatusCode has not been initialized. Make sure the StatusCode is getting assigned to the return of a method.

WARNING_NOT_INITIALIZED = '10000'

WarningNotInitialized

HW_TIMESTAMP_OUT_OF_SYNC = '10001'

The timestamp reported by CANivore is at least 10ms older than the timestamp reported by the system, indicating it’s fallen out of sync. This does not impact the data of this message, only the timing.

FREQUENT_CONFIG_CALLS = '10002'

Do not apply or refresh configs periodically, as configs are blocking.

INVALID_NETWORK = '-10001'

The given network/CAN bus is invalid. Verify that any status signals provided are on the same network and that the network is present.

MULTI_SIGNAL_NOT_SUPPORTED = '-10002'

The CAN bus does not support multi-signal synchronization.

COULD_NOT_CAST = '-10003'

Could not cast from base value to this particular signal’s type

NOT_FOUND = '-10004'

Could not find this value when searching for it

NOT_SUPPORTED = '-10005'

This is not supported

MISSING_CONTEXT = '-10006'

Could not determine context from this device hash

MODEL_MISMATCH = '-10007'

Model name in license file does not match model name of selected device.

SERIAL_MISMATCH = '-10008'

Serial Number in license file does not match model name of selected device.

NO_FILE = '-10009'

Could not find specified file.

LICENSE_DOWNLOAD_FAILED = '-10010'

License did not successfully download to Device.

SELF_TEST_IS_EMPTY = '-10011'

Self Test report does not have any values, is the firmware up to date?

SIGNAL_LOOKUP_FAILED = '-10012'

Failed to lookup signal properties. This can happen if the fimware is too new and supports signals that older APIs do not support.

INVALID_MODE_TO_GET_SIGNAL = '-10013'

The current mode of the device is invalid for getting this signal.

UNLICENSED_DEVICE = '-10014'

Device is not licensed. Cannot get any data from it.

INVALID_SIZE = '-10015'

Size is invalid.

INVALID_LICENSE_RESPONSE = '-10016'

InvalidLicenseResponse

INVALID_CONTEXT = '-10017'

InvalidContext

INTERNAL_ERROR = '-10018'

InternalError

DEVICE_RESPONSE_INCORRECT = '-10019'

kDeviceResponseIncorrect

ERROR_POLLING_FOR_DEVICES = '-10020'

kErrorPollingForDevices

COULD_NOT_RETRIEVE_V6_FIRMWARE = '-10021'

Device firmware could not be retrieved. Check that the device is running v6 firmware, the device ID is correct, the specified CAN bus is correct, and the device is powered.

COULD_NOT_DECODE_DEVICE_FIRMWARE = '-10022'

Device firmware could not be decoded. Check that the device is running v6 firmware, the device ID is correct, the specified CAN bus is correct, and the device is powered.

INVALID_ID_TO_FOLLOW = '-10023'

The values specified for master are in valid. Make sure the Device ID of master are correct.

USING_PRO_FEATURE_ON_UNLICENSED_DEVICE = '-10024'

Using a Pro only feature on an unlicensed device. The device may not behave as expected if it continues to operate while unlicensed.

FIRMWARE_TOO_NEW = '-10025'

Firmware Too New. Use Phoenix Tuner X to field upgrade your CTRE CAN device firmware(CRF) to a compatible version. Then restart your robot application to clear this error.

COULD_NOT_SERIALIZE = '-10026'

The data frame could not be serialized for transmit.

MECHANISM_FAULTED = '-10027'

The mechanism is disabled due to a fault in one of the devices.

FIRMWARE_VERS_NOT_COMPATIBLE = '-10028'

Firmware version is not compatible with this version of Phoenix. Make sure your firmware and API major versions match.

DIRECTORY_MISSING = '-10029'

Could not find specified directory.

API_TOO_OLD = '-10030'

This API version is too old for the firmware on the device. Either upgrade the API to a newer version or downgrade the device firmware to an older version for correct behavior.

LOGGER_NOT_RUNNING = '-10031'

The signal logger is not running. Start the signal logger before writing any signals.

TIMEOUT_CANNOT_BE_ZERO = '-10032'

Blocking operations, such as configs, cannot have a timeout of 0. Pass in a non-zero timeout (typically 0.050+ seconds) for normal operation.

CANNOT_LICENSE_WHILE_ENABLED = '-10033'

Device cannot be licensed while it is control enabled. Disable and neutral the device to apply the licenses.

INVALID_FILE = '-10034'

Could not open or read the given file.

HOOT_LOG_TOO_OLD = '-10035'

The given hoot log requires an older version of Phoenix API.

HOOT_LOG_TOO_NEW = '-10036'

The given hoot log requires a newer version of Phoenix API.

UNLICENSED_HOOT_LOG = '-10037'

Hoot log is not licensed. Cannot get any data from it.

CANNOT_STEP_WHILE_UNPAUSED = '-10038'

The simulation timing cannot be advanced by a time step while unpaused. Pause the simulator before advancing time.

MULTIPLE_REPLAY_NOT_SUPPORTED = '-10039'

Hoot replay does not support replaying multiple files. Ensure that only one file is loaded at a time.

USER_SIGNAL_LIMIT_EXCEEDED = '-10040'

The maximum number of loggable user signals has been exceeded. Additional user signals will not be logged.

INVALID_DEVICE_MODEL = '-10041'

The provided model was not a valid device type.

SIGNAL_NOT_SUPPORTED_OR_MISSING = '-10042'

The requested signal is missing or not supported. Verify that the device firmware is up-to-date.

MISSING_SCHEMA = '-10043'

The schema for the logged user signal is invalid or missing. Ensure that the schema is written before the user signal.

is_error() bool

Gets whether this code is an error.

Returns:

True if this code is an error

Return type:

bool

is_warning() bool

Gets whether this code is a warning.

Returns:

True if this code is a warning

Return type:

bool

is_ok() bool

Gets whether this code is OK.

Returns:

True if this code is OK

Return type:

bool