Class CanandcolorFaults
java.lang.Object
com.reduxrobotics.sensors.canandcolor.CanandcolorFaults
- All Implemented Interfaces:
StructSerializable
,WPISerializable
A class to hold device faults for the
Canandcolor
, as returned by
Canandcolor.getStickyFaults()
and Canandcolor.getActiveFaults()
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final CanandcolorFaultsStruct
This field is necessary for WPILib structs to work around Java type erasure. -
Constructor Summary
ConstructorDescriptionCanandcolorFaults
(int faultField) Constructor, assuming valid data.CanandcolorFaults
(int faultField, boolean valid) Constructor for theCanandcolorFaults
object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the CAN general error flag, which will raise if the device cannot RX packets reliably.boolean
Returns the CAN ID conflict flag, which is set to true if there is a CAN id conflict.int
Returns the faults bitfield as an integer.boolean
Flag if any faults data has been received at all from the device.boolean
Returns the color sensor hardware fault flag, which will raise if the color sensor is unreadable.boolean
Returns the proximity sensor hardware fault flag, which will raise if the proximity sensor is unreadable.boolean
Returns the I²C bus recovery fault flag, which will raise if the color sensor is resetting its internal I²C bus.boolean
Returns the temperature range flag, which will raise if the device is not in its rated temperature range.boolean
Returns the power cycle fault flag, which is set to true when the device first boots.
-
Field Details
-
struct
This field is necessary for WPILib structs to work around Java type erasure.
-
-
Constructor Details
-
CanandcolorFaults
public CanandcolorFaults(int faultField, boolean valid) Constructor for theCanandcolorFaults
object.- Parameters:
faultField
- The byte from which to extract faults.valid
- whether the data bitfield is valid (and not just uninited data)
-
CanandcolorFaults
public CanandcolorFaults(int faultField) Constructor, assuming valid data.- Parameters:
faultField
- The byte from which to extract faults.
-
-
Method Details
-
faultBitField
public int faultBitField()Returns the faults bitfield as an integer.Which bits corresponds to which fault is documented in the online message spec.
- Returns:
- faults bitfield
-
powerCycle
public boolean powerCycle()Returns the power cycle fault flag, which is set to true when the device first boots. Clearing sticky faults and then checking this flag can be used to determine if the device rebooted.- Returns:
- fault state
-
canIDConflict
public boolean canIDConflict()Returns the CAN ID conflict flag, which is set to true if there is a CAN id conflict. In practice, you should physically inspect the device to ensure it's not flashing blue.- Returns:
- fault state
-
canGeneralError
public boolean canGeneralError()Returns the CAN general error flag, which will raise if the device cannot RX packets reliably. This is usually due to wiring issues, such as a shorted CAN bus.- Returns:
- fault state
-
outOfTemperatureRange
public boolean outOfTemperatureRange()Returns the temperature range flag, which will raise if the device is not in its rated temperature range. This may be of concern if the device is near very active motors.- Returns:
- fault state
-
hardwareFaultProximity
public boolean hardwareFaultProximity()Returns the proximity sensor hardware fault flag, which will raise if the proximity sensor is unreadable.- Returns:
- fault state
-
hardwareFaultColor
public boolean hardwareFaultColor()Returns the color sensor hardware fault flag, which will raise if the color sensor is unreadable.- Returns:
- fault state
-
i2cBusRecovery
public boolean i2cBusRecovery()Returns the I²C bus recovery fault flag, which will raise if the color sensor is resetting its internal I²C bus.This fault is of no concern as long as it is not continuously active for long. If the device is stuck in bus recovery, that may indicate a hardware defect.
- Returns:
- fault state
-
faultsValid
public boolean faultsValid()Flag if any faults data has been received at all from the device.This will be faults until the first status frame arrives either after the start of robot code or after sticky faults have been cleared.
- Returns:
- if fault data has actually been received (and thus if the other fields are valid)
-