Table of Contents

Interface CommonDevice

Namespace
CTRE.Phoenix6.Hardware.Traits
Assembly
Phoenix6.Hardware.dll

Contains everything common between Phoenix 6 devices.

public interface CommonDevice

Properties

AppliedControl

The latest applied control request. Caller can cast this to the derived class if they know its type. Otherwise, use GetControlInfo() to get info out of it.

ControlRequest AppliedControl { get; }

Property Value

ControlRequest

DeviceHash

Hash of this device.

uint DeviceHash { get; }

Property Value

uint

DeviceID

ID of this device.

int DeviceID { get; }

Property Value

int

HasResetOccurred

Returns true if device has reset since the previous call of this routine.

bool HasResetOccurred { get; }

Property Value

bool

Network

Network this device is on.

CANBus Network { get; }

Property Value

CANBus

Methods

GetResetOccurredChecker()

Return a lambda that checks for device resets

Func<bool> GetResetOccurredChecker()

Returns

Func<bool>

OptimizeBusUtilization(double, double)

Optimizes the device's bus utilization by reducing the update frequencies of its status signals.

All status signals that have not been explicitly given an update frequency using SetUpdateFrequency(double, double) will be slowed down. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.

This function only needs to be called once on this device in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.

To restore the default status update frequencies, call ResetSignalFrequencies(double). Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies using SetUpdateFrequency(double, double).
StatusCode OptimizeBusUtilization(double optimizedFreqHz = 4, double timeoutSeconds = 0.1)

Parameters

optimizedFreqHz double

The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).

timeoutSeconds double

Maximum amount of time to wait for each status frame when performing the action

Returns

StatusCode

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

ResetSignalFrequencies(double)

Resets the update frequencies of all the device's status signals to the defaults.

This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using SetUpdateFrequency(double, double) and status signals optimized out using OptimizeBusUtilization(double, double).
StatusCode ResetSignalFrequencies(double timeoutSeconds = 0.1)

Parameters

timeoutSeconds double

Maximum amount of time to wait for each status frame when performing the action

Returns

StatusCode

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