Class CANAPIJNIWrapper

java.lang.Object
com.thethriftybot.wrappers.CANAPIJNIWrapper

public final class CANAPIJNIWrapper extends Object
Wrapper class for WPI hardware methods.
  • Method Details

    • setDelegate

      public static void setDelegate(CANAPIJNIInterface newDelegate)
      Used to pass in a new Delegate for the CAN API In our case it will be used to pass in the Mock CANAPIJNI
      Parameters:
      newDelegate - Mocked or different CANAPI
    • resetDelegate

      public static void resetDelegate()
      Used to reset the Delegate back to the CANAPIJNI from WPILib.
    • writeCANPacketNoThrow

      public static int writeCANPacketNoThrow(int handle, byte[] data, int apiId)
      Writes a packet to the CAN device with a specific ID without throwing on error. This ID is 10 bits.
      Parameters:
      handle - the CAN handle
      data - the data to write (0-8 bytes)
      apiId - the ID to write (0-1023 bytes)
      Returns:
      Error status varible. 0 on success.
    • initializeCAN

      public static int initializeCAN(int vendor, int device, int type)
      Initializes the CAN device.
      Parameters:
      vendor - The device vendor.
      device - The device ID.
      type - The device type.
      Returns:
      The handle for the device.
    • readCANPacketNew

      public static boolean readCANPacketNew(int deviceHandle, int apiID, CANData data)
      Reads a new CAN packet.
      Parameters:
      deviceHandle - The device handle.
      apiID - The API ID to read.
      data - The CANData object to populate.
      Returns:
      True if a new packet was found, false otherwise.
    • readCANPacketLatest

      public static boolean readCANPacketLatest(int handle, int apiID, CANData data)
      Reads the latest CAN packet.
      Parameters:
      handle - The device handle.
      apiID - The API ID to read.
      data - The CANData object to populate.
      Returns:
      True if a packet was found, false otherwise.