mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Add new CAN API (#1036)
This commit is contained in:
committed by
Peter Johnson
parent
55b0fe0082
commit
680aabbe7c
26
hal/src/main/java/edu/wpi/first/wpilibj/CANData.java
Normal file
26
hal/src/main/java/edu/wpi/first/wpilibj/CANData.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
public class CANData {
|
||||
@SuppressWarnings("MemberName")
|
||||
public final byte[] data = new byte[8];
|
||||
@SuppressWarnings("MemberName")
|
||||
public int length;
|
||||
@SuppressWarnings("MemberName")
|
||||
public long timestamp;
|
||||
|
||||
/**
|
||||
* API used from JNI to set the data.
|
||||
*/
|
||||
public byte[] setData(int length, long timestamp) {
|
||||
this.length = length;
|
||||
this.timestamp = timestamp;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
34
hal/src/main/java/edu/wpi/first/wpilibj/hal/CANAPIJNI.java
Normal file
34
hal/src/main/java/edu/wpi/first/wpilibj/hal/CANAPIJNI.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj.hal;
|
||||
|
||||
import edu.wpi.first.wpilibj.CANData;
|
||||
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
public class CANAPIJNI extends JNIWrapper {
|
||||
public static native int initializeCAN(int manufacturer, int deviceId, int deviceType);
|
||||
|
||||
public static native void cleanCAN(int handle);
|
||||
|
||||
public static native void writeCANPacket(int handle, byte[] data, int apiId);
|
||||
|
||||
public static native void writeCANPacketRepeating(int handle, byte[] data, int apiId,
|
||||
int repeatMs);
|
||||
|
||||
public static native void stopCANPacketRepeating(int handle, int apiId);
|
||||
|
||||
public static native boolean readCANPacketNew(int handle, int apiId, CANData data);
|
||||
|
||||
public static native boolean readCANPacketLatest(int handle, int apiId, CANData data);
|
||||
|
||||
public static native boolean readCANPacketTimeout(int handle, int apiId, int timeoutMs,
|
||||
CANData data);
|
||||
|
||||
public static native boolean readCANPeriodicPacket(int handle, int apiId, int timeoutMs,
|
||||
int periodMs, CANData data);
|
||||
}
|
||||
Reference in New Issue
Block a user