Package edu.wpi.first.hal.can
Class CANJNI
java.lang.Object
edu.wpi.first.hal.JNIWrapper
edu.wpi.first.hal.can.CANJNI
CAN API HAL JNI Functions.
- See Also:
-
- "hal/CAN.h"
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.hal.JNIWrapper
JNIWrapper.Helper -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMask for "is frame 11 bits" in message ID.static final intMask for "is frame remote" in message ID.static final intFlag for sending a CAN message once.static final intFlag for stopping periodic CAN message sends. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseCANStreamSession(int sessionHandle) Closes a CAN stream session.static byte[]FRCNetCommCANSessionMuxReceiveMessage(IntBuffer messageID, int messageIDMask, ByteBuffer timeStamp) Receives a CAN message.static voidFRCNetCommCANSessionMuxSendMessage(int messageID, byte[] data, int periodMs) Sends a CAN message.static voidgetCANStatus(CANStatus status) Retrieves the current status of the CAN bus.static intopenCANStreamSession(int messageID, int messageIDMask, int maxMessages) Opens a new CAN stream session for receiving CAN messages with specified filters.static intreadCANStreamSession(int sessionHandle, CANStreamMessage[] messages, int messagesToRead) Reads messages from a CAN stream session.Methods inherited from class edu.wpi.first.hal.JNIWrapper
forceLoad, suppressUnused
-
Field Details
-
CAN_SEND_PERIOD_NO_REPEAT
Flag for sending a CAN message once.- See Also:
-
CAN_SEND_PERIOD_STOP_REPEATING
Flag for stopping periodic CAN message sends.- See Also:
-
CAN_IS_FRAME_REMOTE
Mask for "is frame remote" in message ID.- See Also:
-
CAN_IS_FRAME_11BIT
Mask for "is frame 11 bits" in message ID.- See Also:
-
-
Constructor Details
-
CANJNI
public CANJNI()Default constructor.
-
-
Method Details
-
FRCNetCommCANSessionMuxSendMessage
Sends a CAN message.- Parameters:
messageID- The ID of the CAN message.data- The data bytes to be sent.periodMs- The period in milliseconds at which to send the message, useCAN_SEND_PERIOD_NO_REPEATfor a single send.
-
FRCNetCommCANSessionMuxReceiveMessage
public static byte[] FRCNetCommCANSessionMuxReceiveMessage(IntBuffer messageID, int messageIDMask, ByteBuffer timeStamp) Receives a CAN message.- Parameters:
messageID- store for the received message ID (output parameter).messageIDMask- the message ID mask to look fortimeStamp- the packet received timestamp (based off of CLOCK_MONOTONIC) (output parameter).- Returns:
- The data bytes of the received message.
-
getCANStatus
Retrieves the current status of the CAN bus.- Parameters:
status- The CANStatus object to hold the retrieved status.
-
openCANStreamSession
Opens a new CAN stream session for receiving CAN messages with specified filters.- Parameters:
messageID- The CAN messageID to match against. The bits of the messageID are bitwise ANDed with the messageIDMask.messageIDMask- The CAN messageIDMask is a bit-wise mask of bits in the messageID to match against. This allows matching against multiple frames. For example, providing an messageID of 0x2050001 and a mask of 0x1FFF003F would match all REV motor controller frames for a device with CAN ID 1. Providing a mask of 0x1FFFFFFF means that only the exact messageID will be matched. Providing a mask of 0 would match any frame of any type.maxMessages- The maximum number of messages that can be buffered in the session.- Returns:
- The handle to the opened CAN stream session.
-
closeCANStreamSession
Closes a CAN stream session.- Parameters:
sessionHandle- The handle of the CAN stream session to be closed.
-
readCANStreamSession
public static int readCANStreamSession(int sessionHandle, CANStreamMessage[] messages, int messagesToRead) throws CANStreamOverflowException Reads messages from a CAN stream session.- Parameters:
sessionHandle- The handle of the CAN stream session.messages- An array to hold the CANStreamMessage objects (output parameter).messagesToRead- The number of messages to read from the session.- Returns:
- The number of messages read into the buffer
- Throws:
CANStreamOverflowException- If the number of messages to read exceeds the capacity of the provided messages array.
-