Add methods for checking Watchdog status, ds status, and brownout status

Change-Id: I723c87d0c50612cbffbb81b0e039efd0ef05fcd0
This commit is contained in:
Kevin O'Connor
2014-11-18 10:56:25 -05:00
parent c7a90b2ccc
commit e73b3ed7b5
7 changed files with 89 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ 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;
@@ -329,6 +330,22 @@ public class DriverStation implements RobotState.Interface {
public boolean isOperatorControl() {
return !(isAutonomous() || isTest());
}
public boolean isSysActive() {
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
boolean retVal = FRCNetworkCommunicationsLibrary.HALGetSystemActive(status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return retVal;
}
public boolean isBrownedOut() {
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
boolean retVal = FRCNetworkCommunicationsLibrary.HALGetBrownedOut(status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return retVal;
}
/**
* Has a new control packet from the driver station arrived since the last time this function was called?
@@ -393,6 +410,11 @@ public class DriverStation implements RobotState.Interface {
public boolean isFMSAttached() {
return m_controlWord.getFMSAttached();
}
public boolean isDSAttached() {
HALControlWord controlWord = FRCNetworkCommunicationsLibrary.HALGetControlWord();
return controlWord.getDSAttached();
}
/**
* Return the approximate match time

View File

@@ -468,6 +468,8 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper {
return HALAllianceStationID.Blue2;
case 5:
return HALAllianceStationID.Blue3;
default:
return null;
}
}