Package com.thethriftybot.wrappers
Class CANAPIJNIWrapper
java.lang.Object
com.thethriftybot.wrappers.CANAPIJNIWrapper
Wrapper class for WPI hardware methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intinitializeCAN(int vendor, int device, int type) Initializes the CAN device.static booleanreadCANPacketLatest(int handle, int apiID, CANData data) Reads the latest CAN packet.static booleanreadCANPacketNew(int deviceHandle, int apiID, CANData data) Reads a new CAN packet.static voidUsed to reset the Delegate back to the CANAPIJNI from WPILib.static voidsetDelegate(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 CANAPIJNIstatic intwriteCANPacketNoThrow(int handle, byte[] data, int apiId) Writes a packet to the CAN device with a specific ID without throwing on error.
-
Method Details
-
setDelegate
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 handledata- 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
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
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.
-