phoenix6

Subpackages

Submodules

Package Contents

class phoenix6.AllTimestamps

A collection of timestamps for a received signal.

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.

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])

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

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

Gets 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

Check 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

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 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 is_all_good(*signals: BaseStatusSignal | list[BaseStatusSignal]) bool

Checks if all signals have an OK error code. :param signals: Signals to check error code of :type signals: tuple[BaseStatusSignal | list[BaseStatusSignal], …] :returns: True if all are good, False otherwise :rtype: 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.

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

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.

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

class phoenix6.StatusSignal(error: phoenix6.status_code.StatusCode | None, device_identifier: phoenix6.hardware.device_identifier.DeviceIdentifier, spn: int, report_if_old_func: Callable[[], None], generator: Callable[[], dict[int, str]] | None, signal_name: str, 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.

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]

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.

Note 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.

value: T

The value of the signal

timestamp: phoenix6.units.second = 0.0

Timestamp of when the data point was taken, in seconds

status

Status code response of getting the data

units = ''

Units that correspond to this point

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.

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

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.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.

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.

class SignalData

Bases: Generic[T]

Stores information about a user signal from replay.

name: str = ''

The name of the signal

units: str = ''

The units of the signal

timestamp: phoenix6.units.second = 0

The timestamp of the signal, in seconds

status: phoenix6.status_code.StatusCode

Status code response of getting the signal

value: T

The value of the signal

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 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_raw(name: str) SignalData[bytearray]

Gets a raw-bytes user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[bytearray]

classmethod get_boolean(name: str) SignalData[bool]

Gets a boolean user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[bool]

classmethod get_integer(name: str) SignalData[int]

Gets an integer user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[int]

classmethod get_float(name: str) SignalData[float]

Gets a float user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[float]

classmethod get_double(name: str) SignalData[float]

Gets a double user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[float]

classmethod get_string(name: str) SignalData[str]

Gets a string user signal.

Parameters:

name (str) – Name of the signal

Returns:

Structure with all information about the signal

Return type:

SignalData[str]

classmethod get_boolean_array(name: str) SignalData[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:

SignalData[list[bool]]

classmethod get_integer_array(name: str) SignalData[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:

SignalData[list[int]]

classmethod get_float_array(name: str) SignalData[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:

SignalData[list[float]]

classmethod get_double_array(name: str) SignalData[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:

SignalData[list[float]]

class phoenix6.Orchestra(instruments: list[phoenix6.hardware.parent_device.ParentDevice] = [], 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[ParentDevice]) – 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.parent_device.ParentDevice) 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 (ParentDevice) – The device to add to the orchestra

Returns:

Status code of adding the device

Return type:

StatusCode

add_instrument_with_track(instrument: phoenix6.hardware.parent_device.ParentDevice, 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 (ParentDevice) – 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.

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.

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 SetPath to avoid running out of internal storage space.

If auto logging is enabled, the log will be stopped at the end of the match.

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.

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. When auto logging is enabled, logging is started at the beginning of an FRC match and stopped at the end.

Parameters:

enable (bool) – Whether to enable auto logging

Returns:

Status of auto logging enable/disable

Return type:

StatusCode

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

Writes the raw data bytes to the log file. The data cannot exceed 64 bytes.

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

  • data (bytes) – Raw data bytes

  • size (int) – Size of the raw data (in 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. The string cannot exceed 64 characters.

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. The array cannot exceed 64 elements.

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

  • value – 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. The array cannot exceed 8 elements.

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

  • value – 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. The array cannot exceed 16 elements.

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

  • value – 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. The array cannot exceed 8 elements.

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

  • value – 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

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

Diagnostic Server is busy with another command.

INVALID_DEVICE_SPEC

InvalidDeviceSpec

ECU_IS_NOT_PRESENT

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

COULD_NOT_ENTER_BL

Could not put the device into bootloader mode.

COULD_NOT_CONFIRM_BL

Could not confirm the device has entered the bootloader.

COULD_NOT_ERASE

Could not erase flash.

COULD_NOT_SEND_FLASH

Could not field upgrade the device.

COULD_NOT_VALIDATE

Bootloader could not verify integrity of the flashed application.

COULD_NOT_RUN_APP

Could not run the device firmware application.

COULD_NOT_REQ_SET_ID

Unable to set ID to this device.

COULD_NOT_CONFIRM_ID

Could not verify that the changed ID took effect.

FLASH_WAS_GOOD

Device field upgrade was successful.

APP_TOO_OLD

Device firmware application is too old.

COULD_NOT_REQ_SET_DESC

Unable to set name to this device.

COMPILE_SZ_IS_WRONG

CompileSzIsWrong

GADGETEER_DEVICE_NO_SET_ID

Cannot set the ID of a gadgeteer device.

INVALID_TASK

This diagnostic action is not supported.

NOT_IMPLEMENTED

Not Implemented, check latest installer.

NO_DEVICES_ON_BUS

NoDevicesOnBus

MORE_THAN_ONE_FILE

MoreThanOneFile

NODE_IS_INVALID

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

INVALID_DEVICE_DESCRIPTOR

InvalidDeviceDescriptor

COULD_NOT_SEND_CAN_FRAME

CouldNotSendCanFrame

NORMAL_MODE_MSG_NOT_PRESENT

NormalModeMsgNotPresent

FEATURE_NOT_SUPPORTED

This feature is not supported.

NOT_UPDATING

The diagnostic server is not field upgrading any devices.

CORRUPTED_POST

CorruptedPOST

NO_CONFIGS

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

CONFIG_FAILED

ConfigFailed

COULD_NOT_REQ_FACTORY_DEFAULT

Unable to factory default this device.

CUSTOM_NAME_NOT_SUPPORTED

CustomNameNotSupported

CONFIG_READ_WRITE_MISMATCH

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

COULD_NOT_REQ_SET_CONFIGS

Could not apply the device configs.

INSUFFICIENT_SZ

InsufficientSz

INVALID_MODEL

This feature is not supported for this device model.

COULD_NOT_REQ_DEV_INFO

CouldNotReqDevInfo

NO_CONTROLS

This device does not support new controls.

DEVICE_IS_NULL

DeviceIsNull

DEVICE_DID_NOT_RESPOND_TO_DIAG_REQ

DeviceDidNotRespondToDiagReq

ONLY_SUPPORTED_IN_TUNER_X

This feature requires Tuner X.

CANIV_CLI_ERROR

Command-line issue with caniv.

INVALID_CRF_BAD_HEADER

InvalidCrfBadHeader

INVALID_CRF_FILE_SZ_INVALD

InvalidCrfFileSzInvald

INVALID_CRF_WRONG_PRODUCT

Specified CRF is for the wrong product.

INVALID_CRF_NO_SECTS

InvalidCrfNoSects

INVALID_CRF_BAD_SECT_HEADER

InvalidCrfBadSectHeader

INVALID_CRF_BAD_SECT_SIZE

InvalidCrfBadSectSize

NO_CRF_FILE

Specified CRF file could not be found.

COULD_NOT_FIND_DYNAMIC_ID

CouldNotFindDynamicId

DID_NOT_GET_DHCP

DidNotGetDhcp

DID_NOT_GET_FULL_DHCP

DidNotGetFullDhcp

INVALID_LICENSE_RESP

InvalidLicenseResp

INVALID_CANIV_CACHE

InvalidCanivCache

CANNOT_OPEN_SERIAL_PORT

CannotOpenSerialPort

CANNOT_WRITE_SERIAL_PORT

CannotWriteSerialPort

CANNOT_READ_SERIAL_PORT

CannotReadSerialPort

CANNOT_SERIAL_TO_DEVICE

CannotSerialToDevice

NO_SERIAL_CONTROL_FRAME_RESP

NoSerialControlFrameResp

CANNOT_OPEN_UDP_PORT

CannotOpenUdpPort

CANNOT_WRITE_UDP_PORT

CannotWriteUdpPort

CANNOT_READ_UDP_PORT

CannotReadUdpPort

CANNOT_UDP_TO_DEVICE

CannotUdpToDevice

NO_UDP_CONTROL_FRAME_RESP

NoUdpControlFrameResp

TIMEOUT_ISO15_RESPONSE

TimeoutIso15Response

INVALID_JSON

InvalidJson

APP_IS_TERMINATING

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

Could not transmit CAN Frame.

INVALID_PARAM_VALUE

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

RX_TIMEOUT

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

TX_TIMEOUT

CAN Transmit timed out.

UNEXPECTED_ARB_ID

ArbID is incorrect.

CAN_OVERFLOWED

CanOverflowed

SENSOR_NOT_PRESENT

Sensor Not Present.

FIRMWARE_TOO_OLD

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

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

BUFFER_FAILURE

BufferFailure

FIRMWARE_NON_FRC

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

General Error Occurred.

SIG_NOT_UPDATED

No new response to update signal.

NOT_ALL_PID_VALUES_UPDATED

NotAllPIDValuesUpdated

GEN_PORT_ERROR

GEN_PORT_ERROR

PORT_MODULE_TYPE_MISMATCH

PORT_MODULE_TYPE_MISMATCH

GEN_MODULE_ERROR

GEN_MODULE_ERROR

MODULE_NOT_INIT_SET_ERROR

MODULE_NOT_INIT_SET_ERROR

MODULE_NOT_INIT_GET_ERROR

MODULE_NOT_INIT_GET_ERROR

WHEEL_RADIUS_TOO_SMALL

Wheel Radius is too small, cannot get distance traveled.

TICKS_PER_REV_ZERO

Ticks per revolution is 0, cannot get heading.

DISTANCE_BETWEEN_WHEELS_TOO_SMALL

Distance between wheels is too small, cannot get heading.

GAINS_ARE_NOT_SET

GainsAreNotSet

WRONG_REMOTE_LIMIT_SWITCH_SOURCE

Use RemoteLimitSwitchSource instead of LimitSwitchSource.

DOUBLE_VOLTAGE_COMPENSATING_WPI

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

CANdleAnimSlotOutOfBounds

INCOMPATIBLE_MODE

IncompatibleMode

INVALID_HANDLE

Handle passed into function is incorrect.

FEATURE_REQUIRES_HIGHER_FIRM

Features requires newer firmware version.

CONFIG_FACTORY_DEFAULT_REQUIRES_HIGHER_FIRM

Config factory default features require firmware >=3.10.

CONFIG_MOTION_S_CURVE_REQUIRES_HIGHER_FIRM

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

TALON_FX_FIRMWARE_PRE_V_BAT_DETECT

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

CANdleAnimationsRequireHigherFirm

LIBRARY_COULD_NOT_BE_LOADED

LibraryCouldNotBeLoaded

MISSING_ROUTINE_IN_LIBRARY

MissingRoutineInLibrary

RESOURCE_NOT_AVAILABLE

ResourceNotAvailable

MUSIC_FILE_NOT_FOUND

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

MUSIC_FILE_WRONG_SIZE

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

MUSIC_FILE_TOO_NEW

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

MUSIC_FILE_INVALID

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

INVALID_ORCHESTRA_ACTION

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

MUSIC_FILE_TOO_OLD

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

MUSIC_INTERRUPTED

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

MUSIC_NOT_SUPPORTED

This device doesn’t support MusicTone control mode.

INVALID_INTERFACE

kInvalidInterface

INVALID_GUID

kInvalidGuid

INVALID_CLASS

kInvalidClass

INVALID_PROTOCOL

kInvalidProtocol

INVALID_PATH

kInvalidPath

GENERAL_WIN_USB_ERROR

kGeneralWinUsbError

FAILED_SETUP

kFailedSetup

LISTEN_FAILED

kListenFailed

SEND_FAILED

kSendFailed

RECEIVE_FAILED

kReceiveFailed

INVALID_RESP_FORMAT

kInvalidRespFormat

WIN_USB_INIT_FAILED

kWinUsbInitFailed

WIN_USB_QUERY_FAILED

kWinUsbQueryFailed

WIN_USB_GENERAL_ERROR

kWinUsbGeneralError

ACCESS_DENIED

kAccessDenied

FIRMWARE_INVALID_RESPONSE

kFirmwareInvalidResponse

STATUS_CODE_NOT_INITIALIZED

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

InvalidNetwork

MULTI_SIGNAL_NOT_SUPPORTED

The CAN bus does not support multi-signal synchronization.

COULD_NOT_CAST

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

NOT_FOUND

Could not find this value when searching for it

NOT_SUPPORTED

This is not supported

MISSING_CONTEXT

Could not determine context from this device hash

MODEL_MISMATCH

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

SERIAL_MISMATCH

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

NO_FILE

Could not find specified file.

LICENSE_DOWNLOAD_FAILED

License did not successfully download to Device.

SELF_TEST_IS_EMPTY

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

SIGNAL_LOOKUP_FAILED

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

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

UNLICENSED_DEVICE

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

INVALID_SIZE

Size is invalid.

INVALID_LICENSE_RESPONSE

InvalidLicenseResponse

INVALID_CONTEXT

InvalidContext

INTERNAL_ERROR

InternalError

DEVICE_RESPONSE_INCORRECT

kDeviceResponseIncorrect

ERROR_POLLING_FOR_DEVICES

kErrorPollingForDevices

COULD_NOT_RETRIEVE_V6_FIRMWARE

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

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

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

USING_PRO_FEATURE_ON_UNLICENSED_DEVICE

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

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

The data frame could not be serialized for transmit.

MECHANISM_FAULTED

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

FIRMWARE_VERS_NOT_COMPATIBLE

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

DIRECTORY_MISSING

Could not find specified directory.

API_TOO_OLD

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

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

TIMEOUT_CANNOT_BE_ZERO

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

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

INVALID_FILE

Could not open or read the given file.

HOOT_LOG_TOO_OLD

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

HOOT_LOG_TOO_NEW

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

UNLICENSED_HOOT_LOG

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

CANNOT_STEP_WHILE_UNPAUSED

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

MULTIPLE_REPLAY_NOT_SUPPORTED

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

USER_SIGNAL_LIMIT_EXCEEDED

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

INVALID_DEVICE_MODEL

The provided model was not a valid device type.

SIGNAL_NOT_SUPPORTED_OR_MISSING

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

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