mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Moves the DS new data wait calls down to the HAL. (#156)
This commit is contained in:
committed by
Peter Johnson
parent
0cb288ffba
commit
4a98e68815
@@ -100,8 +100,6 @@ public class DriverStation implements RobotState.Interface {
|
||||
private boolean m_userInTest = false;
|
||||
private boolean m_updatedControlLoopData;
|
||||
private boolean m_newControlData;
|
||||
private final long m_packetDataAvailableMutex;
|
||||
private final long m_packetDataAvailableSem;
|
||||
|
||||
/**
|
||||
* Gets an instance of the DriverStation
|
||||
@@ -132,10 +130,6 @@ public class DriverStation implements RobotState.Interface {
|
||||
m_joystickPOVsCache[i] = new HALJoystickPOVs(HAL.kMaxJoystickPOVs);
|
||||
}
|
||||
|
||||
m_packetDataAvailableMutex = HALUtil.initializeMutexNormal();
|
||||
m_packetDataAvailableSem = HALUtil.initializeMultiWait();
|
||||
HAL.setNewDataSem(m_packetDataAvailableSem);
|
||||
|
||||
m_thread = new Thread(new DriverStationTask(this), "FRCDriverStation");
|
||||
m_thread.setPriority((Thread.NORM_PRIORITY + Thread.MAX_PRIORITY) / 2);
|
||||
|
||||
@@ -155,7 +149,7 @@ public class DriverStation implements RobotState.Interface {
|
||||
private void task() {
|
||||
int safetyCounter = 0;
|
||||
while (m_threadKeepAlive) {
|
||||
HALUtil.takeMultiWait(m_packetDataAvailableSem, m_packetDataAvailableMutex);
|
||||
HAL.waitForDSData();
|
||||
getData();
|
||||
synchronized (m_dataSem) {
|
||||
m_updatedControlLoopData = true;
|
||||
|
||||
@@ -16,7 +16,7 @@ import edu.wpi.first.wpilibj.hal.JNIWrapper;
|
||||
*/
|
||||
@SuppressWarnings({"AbbreviationAsWordInName", "MethodName"})
|
||||
public class HAL extends JNIWrapper {
|
||||
public static native void setNewDataSem(long mutexId);
|
||||
public static native void waitForDSData();
|
||||
|
||||
public static native int initialize(int mode);
|
||||
|
||||
|
||||
@@ -18,24 +18,6 @@ public class HALUtil extends JNIWrapper {
|
||||
public static final int NO_AVAILABLE_RESOURCES = -104;
|
||||
public static final int PARAMETER_OUT_OF_RANGE = -1028;
|
||||
|
||||
// public static final int SEMAPHORE_WAIT_FOREVER = -1;
|
||||
// public static final int SEMAPHORE_Q_PRIORITY = 0x01;
|
||||
|
||||
public static native long initializeMutexNormal();
|
||||
|
||||
public static native void deleteMutex(long sem);
|
||||
|
||||
public static native void takeMutex(long sem);
|
||||
|
||||
// public static native long initializeSemaphore(int initialValue);
|
||||
// public static native void deleteSemaphore(long sem);
|
||||
// public static native byte takeSemaphore(long sem, int timeout);
|
||||
public static native long initializeMultiWait();
|
||||
|
||||
public static native void deleteMultiWait(long sem);
|
||||
|
||||
public static native void takeMultiWait(long sem, long ms);
|
||||
|
||||
public static native short getFPGAVersion();
|
||||
|
||||
public static native int getFPGARevision();
|
||||
|
||||
Reference in New Issue
Block a user