Class CanDeviceId

java.lang.Object
frc.spectrumLib.util.CanDeviceId

public class CanDeviceId extends Object
Identifies a CAN device by its numeric device ID and the CAN bus name it lives on. Equality and hashing consider both fields, so two instances with the same device number on different buses are treated as distinct.
  • Constructor Details

    • CanDeviceId

      public CanDeviceId(int deviceNumber, String bus)
      Creates a CAN device identifier with an explicit bus name.
      Parameters:
      deviceNumber - the numeric CAN ID assigned to the device
      bus - the name of the CAN bus (e.g. "rio" or "canivore")
    • CanDeviceId

      public CanDeviceId(int deviceNumber)
      Creates a CAN device identifier on the default CAN bus (empty string).
      Parameters:
      deviceNumber - the numeric CAN ID assigned to the device
  • Method Details

    • getDeviceNumber

      public int getDeviceNumber()
      Returns the numeric CAN device ID.
      Returns:
      the device number
    • getBus

      public String getBus()
      Returns the CAN bus name this device is on.
      Returns:
      the bus name, or an empty string for the default bus
    • equals

      public boolean equals(CanDeviceId other)
      Type-safe equality check against another CanDeviceId.
      Parameters:
      other - the other instance to compare
      Returns:
      true if both the device number and bus name match
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object