Class Canandmag.Faults

java.lang.Object
com.reduxrobotics.sensors.canandmag.Canandmag.Faults
All Implemented Interfaces:
StructSerializable, WPISerializable
Enclosing class:
Canandmag

public static class Canandmag.Faults extends Object implements StructSerializable
A class to hold device faults for the Canandmag. Returned by Canandmag.getStickyFaults() and Canandmag.getActiveFaults().
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    This field is necessary for WPILib structs to work around Java type erasure.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Faults(int faultField)
    Constructor for the CanandmagFaults object.
    Faults(int faultField, boolean valid)
    Constructor for the CanandmagFaults object.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the CAN general error flag, which will raise if the encoder 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 hardware fault flag, which will raise if a hardware issue is detected.
    boolean
    Returns the magnet out of range flag, which will raise if the measured shaft's magnet is not detected.
    boolean
    Returns the temperature range flag, which will raise if the encoder is not between 0-70 degrees Celsius.
    boolean
    Returns the power cycle fault flag, which is set to true when the encoder first boots.
    boolean
    Returns the undervolt flag, which will raise if the encoder is experiencing brownout conditions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • struct

      public static final CanandmagFaultsStruct struct
      This field is necessary for WPILib structs to work around Java type erasure.
  • Constructor Details

    • Faults

      public Faults(int faultField, boolean valid)
      Constructor for the CanandmagFaults object.
      Parameters:
      faultField - The byte from which to extract faults.
      valid - Whether or not the data is valid (and not from some initialization value)
    • Faults

      public Faults(int faultField)
      Constructor for the CanandmagFaults object.
      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 encoder first boots. Clearing sticky faults and then checking this flag can be used to determine if the encoder 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 encoder 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 encoder 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 encoder is not between 0-70 degrees Celsius. This may be of concern if the encoder is near very active motors.
      Returns:
      fault state
    • hardwareFault

      public boolean hardwareFault()
      Returns the hardware fault flag, which will raise if a hardware issue is detected. Generally will raise if the device's controller cannot read the physical sensor itself.
      Returns:
      fault state
    • magnetOutOfRange

      public boolean magnetOutOfRange()
      Returns the magnet out of range flag, which will raise if the measured shaft's magnet is not detected. This will match the encoder's LED shining red in normal operation.
      Returns:
      fault state
    • underVolt

      public boolean underVolt()
      Returns the undervolt flag, which will raise if the encoder is experiencing brownout conditions.
      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)