Added in new headers and libraries for image version 18. This image contains a change to fix artf3773, which switched setDataSem to be a pthread_cond_t variable instead of a mutex. As a result, a few new HAL functions had to be exposed over JNI, specifically the functions for MultiWait.

Change-Id: I28be07c8102acb078440ee74ded46527328dd271
This commit is contained in:
Fredric Silberberg
2014-11-16 16:57:02 -05:00
parent 6f4d6ed998
commit c6891fc034
19 changed files with 75 additions and 22 deletions

View File

@@ -8,14 +8,12 @@ package edu.wpi.first.wpilibj;
import java.nio.IntBuffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary;
import edu.wpi.first.wpilibj.communication.HALControlWord;
import edu.wpi.first.wpilibj.communication.HALAllianceStationID;
import edu.wpi.first.wpilibj.hal.HALUtil;
import edu.wpi.first.wpilibj.hal.PowerJNI;
import edu.wpi.first.wpilibj.Timer;
/**
* Provide access to the network communication data to / from the Driver Station.
@@ -73,6 +71,7 @@ public class DriverStation implements RobotState.Interface {
private boolean m_userInTeleop = false;
private boolean m_userInTest = false;
private boolean m_newControlData;
private final ByteBuffer m_packetDataAvailableMutex;
private final ByteBuffer m_packetDataAvailableSem;
/**
@@ -94,7 +93,8 @@ public class DriverStation implements RobotState.Interface {
m_semaphore = new Object();
m_dataSem = new Object();
m_packetDataAvailableSem = HALUtil.initializeMutexNormal();
m_packetDataAvailableMutex = HALUtil.initializeMutexNormal();
m_packetDataAvailableSem = HALUtil.initializeMultiWait();
FRCNetworkCommunicationsLibrary.setNewDataSem(m_packetDataAvailableSem);
m_thread = new Thread(new DriverStationTask(this), "FRCDriverStation");
@@ -116,7 +116,7 @@ public class DriverStation implements RobotState.Interface {
private void task() {
int safetyCounter = 0;
while (m_thread_keepalive) {
HALUtil.takeMutex(m_packetDataAvailableSem);
HALUtil.takeMultiWait(m_packetDataAvailableSem, m_packetDataAvailableMutex, 0);
synchronized (this) {
getData();
}

View File

@@ -23,6 +23,9 @@ public class HALUtil extends JNIWrapper {
//public static native ByteBuffer initializeSemaphore(int initialValue);
//public static native void deleteSemaphore(ByteBuffer sem);
//public static native byte takeSemaphore(ByteBuffer sem, int timeout);
public static native ByteBuffer initializeMultiWait();
public static native void deleteMultiWait(ByteBuffer sem);
public static native byte takeMultiWait(ByteBuffer sem, ByteBuffer m, int timeOut);
public static native short getFPGAVersion(IntBuffer status);
public static native int getFPGARevision(IntBuffer status);
public static native long getFPGATime(IntBuffer status);