mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11: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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user