mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] RobotController: Add isSystemTimeValid() (#5696)
This returns true when the system date/time (wall clock) is valid.
This commit is contained in:
@@ -190,6 +190,14 @@ public final class HAL extends JNIWrapper {
|
||||
*/
|
||||
public static native boolean getRSLState();
|
||||
|
||||
/**
|
||||
* Gets if the system time is valid.
|
||||
*
|
||||
* @return True if the system time is valid, false otherwise
|
||||
* @see "HAL_GetSystemTimeValid"
|
||||
*/
|
||||
public static native boolean getSystemTimeValid();
|
||||
|
||||
/**
|
||||
* Gets a port handle for a specific channel and module.
|
||||
*
|
||||
|
||||
@@ -472,6 +472,12 @@ HAL_Bool HAL_GetRSLState(int32_t* status) {
|
||||
return global->readLEDs_RSL(status);
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetSystemTimeValid(int32_t* status) {
|
||||
uint8_t timeWasSet = 0;
|
||||
*status = FRC_NetworkCommunication_getTimeWasSet(&timeWasSet);
|
||||
return timeWasSet != 0;
|
||||
}
|
||||
|
||||
static bool killExistingProgram(int timeout, int mode) {
|
||||
// Kill any previous robot programs
|
||||
std::fstream fs;
|
||||
|
||||
@@ -151,6 +151,21 @@ Java_edu_wpi_first_hal_HAL_getRSLState
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_HAL
|
||||
* Method: getSystemTimeValid
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_hal_HAL_getSystemTimeValid
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
int32_t status = 0;
|
||||
bool val = HAL_GetSystemTimeValid(&status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_hal_HAL
|
||||
* Method: getPortWithModule
|
||||
|
||||
@@ -186,6 +186,14 @@ uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status);
|
||||
*/
|
||||
HAL_Bool HAL_GetRSLState(int32_t* status);
|
||||
|
||||
/**
|
||||
* Gets if the system time is valid.
|
||||
*
|
||||
* @param[out] status the error code, or 0 for success
|
||||
* @return True if the system time is valid, false otherwise
|
||||
*/
|
||||
HAL_Bool HAL_GetSystemTimeValid(int32_t* status);
|
||||
|
||||
/**
|
||||
* Call this to start up HAL. This is required for robot programs.
|
||||
*
|
||||
|
||||
@@ -336,6 +336,10 @@ HAL_Bool HAL_GetRSLState(int32_t* status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetSystemTimeValid(int32_t* status) {
|
||||
return true;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
static std::atomic_bool initialized{false};
|
||||
static wpi::mutex initializeMutex;
|
||||
|
||||
@@ -15,7 +15,7 @@ nativeUtils {
|
||||
configureDependencies {
|
||||
opencvYear = "frc2023"
|
||||
googleTestYear = "frc2023"
|
||||
niLibVersion = "2024.1.0"
|
||||
niLibVersion = "2024.1.1"
|
||||
opencvVersion = "4.6.0-5"
|
||||
googleTestVersion = "1.12.1-2"
|
||||
}
|
||||
|
||||
@@ -87,6 +87,13 @@ bool RobotController::GetRSLState() {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool RobotController::IsSystemTimeValid() {
|
||||
int32_t status = 0;
|
||||
bool retVal = HAL_GetSystemTimeValid(&status);
|
||||
FRC_CheckErrorStatus(status, "IsSystemTimeValid");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
double RobotController::GetInputVoltage() {
|
||||
int32_t status = 0;
|
||||
double retVal = HAL_GetVinVoltage(&status);
|
||||
|
||||
@@ -115,6 +115,13 @@ class RobotController {
|
||||
*/
|
||||
static bool GetRSLState();
|
||||
|
||||
/**
|
||||
* Gets if the system time is valid.
|
||||
*
|
||||
* @return True if the system time is valid, false otherwise
|
||||
*/
|
||||
static bool IsSystemTimeValid();
|
||||
|
||||
/**
|
||||
* Get the input voltage to the robot controller.
|
||||
*
|
||||
|
||||
@@ -121,6 +121,15 @@ public final class RobotController {
|
||||
return HAL.getRSLState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the system time is valid.
|
||||
*
|
||||
* @return True if the system time is valid, false otherwise
|
||||
*/
|
||||
public static boolean isSystemTimeValid() {
|
||||
return HAL.getSystemTimeValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the input voltage to the robot controller.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user