From ef24c1df97e06e0e0b779c7095bac2ba93966907 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 14 Jul 2025 23:45:28 -0700 Subject: [PATCH] [hal] Implement HAL_GetSystemTimeValid on SystemCore (#8051) --- hal/src/main/native/systemcore/FRCDriverStation.cpp | 10 ++++++++++ hal/src/main/native/systemcore/HAL.cpp | 4 ---- hal/src/mrc/include/mrc/NtNetComm.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hal/src/main/native/systemcore/FRCDriverStation.cpp b/hal/src/main/native/systemcore/FRCDriverStation.cpp index 37a6f19ff1..564623cf91 100644 --- a/hal/src/main/native/systemcore/FRCDriverStation.cpp +++ b/hal/src/main/native/systemcore/FRCDriverStation.cpp @@ -66,6 +66,8 @@ struct SystemServerDriverStation { nt::BooleanPublisher hasUserCodePublisher; nt::BooleanPublisher hasUserCodeReadyPublisher; + nt::BooleanSubscriber hasSetWallClockSubscriber; + nt::ProtobufSubscriber controlDataSubscriber; nt::ProtobufSubscriber matchInfoSubscriber; nt::StringSubscriber gameSpecificMessageSubscriber; @@ -119,6 +121,10 @@ struct SystemServerDriverStation { consoleLinePublisher = ntInst.GetStringTopic(ROBOT_CONSOLE_LINE_PATH).Publish(options); + hasSetWallClockSubscriber = + ntInst.GetBooleanTopic(ROBOT_HAS_SET_WALL_CLOCK_PATH) + .Subscribe(false, options); + errorInfoPublisher = ntInst.GetProtobufTopic(ROBOT_ERROR_INFO_PATH) .Publish(options); @@ -643,6 +649,10 @@ HAL_Bool HAL_GetOutputsEnabled(void) { return systemServerDs->controlDataSubscriber.Get().ControlWord.WatchdogActive; } +HAL_Bool HAL_GetSystemTimeValid(int32_t* status) { + return systemServerDs->hasSetWallClockSubscriber.Get(false); +} + } // extern "C" namespace hal { diff --git a/hal/src/main/native/systemcore/HAL.cpp b/hal/src/main/native/systemcore/HAL.cpp index 5e74560f7e..e0db58155c 100644 --- a/hal/src/main/native/systemcore/HAL.cpp +++ b/hal/src/main/native/systemcore/HAL.cpp @@ -276,10 +276,6 @@ HAL_Bool HAL_GetRSLState(int32_t* status) { return false; } -HAL_Bool HAL_GetSystemTimeValid(int32_t* status) { - return false; -} - HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) { static std::atomic_bool initialized{false}; static wpi::mutex initializeMutex; diff --git a/hal/src/mrc/include/mrc/NtNetComm.h b/hal/src/mrc/include/mrc/NtNetComm.h index 4806c263ff..363d426573 100644 --- a/hal/src/mrc/include/mrc/NtNetComm.h +++ b/hal/src/mrc/include/mrc/NtNetComm.h @@ -15,6 +15,8 @@ #define ROBOT_MATCH_INFO_PATH (ROBOT_CONTROL_DATA_PREFIX "MatchInfo") #define ROBOT_JOYSTICK_DESCRIPTORS_PATH \ (ROBOT_CONTROL_DATA_PREFIX "JoystickDescriptors/") +#define ROBOT_HAS_SET_WALL_CLOCK_PATH \ + (ROBOT_CONTROL_DATA_PREFIX "HasSetWallClock") #define ROBOT_STATUS_DATA_PREFIX "/Netcomm/Status/" #define ROBOT_HAS_USER_CODE_PATH (ROBOT_STATUS_DATA_PREFIX "HasUserCode")