mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add methods for checking Watchdog status, ds status, and brownout status
Change-Id: I723c87d0c50612cbffbb81b0e039efd0ef05fcd0
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -468,6 +468,8 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper {
|
||||
return HALAllianceStationID.Blue2;
|
||||
case 5:
|
||||
return HALAllianceStationID.Blue3;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user