001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.hal.can;
006
007import edu.wpi.first.hal.CANStreamMessage;
008import edu.wpi.first.hal.JNIWrapper;
009import java.nio.ByteBuffer;
010import java.nio.IntBuffer;
011
012@SuppressWarnings("MethodName")
013public class CANJNI extends JNIWrapper {
014  public static final int CAN_SEND_PERIOD_NO_REPEAT = 0;
015  public static final int CAN_SEND_PERIOD_STOP_REPEATING = -1;
016
017  /* Flags in the upper bits of the messageID */
018  public static final int CAN_IS_FRAME_REMOTE = 0x80000000;
019  public static final int CAN_IS_FRAME_11BIT = 0x40000000;
020
021  public static native void FRCNetCommCANSessionMuxSendMessage(
022      int messageID, byte[] data, int periodMs);
023
024  public static native byte[] FRCNetCommCANSessionMuxReceiveMessage(
025      IntBuffer messageID, int messageIDMask, ByteBuffer timeStamp);
026
027  public static native void getCANStatus(CANStatus status);
028
029  public static native int openCANStreamSession(int messageID, int messageIDMask, int maxMessages);
030
031  public static native void closeCANStreamSession(int sessionHandle);
032
033  public static native int readCANStreamSession(
034      int sessionHandle, CANStreamMessage[] messages, int messagesToRead);
035}