[hal] Explicitly wait for mrccomm server to be ready (#8490)

Avoids a race if robot ready happens before mrccomm is fully booted
This commit is contained in:
Thad House
2025-12-16 22:24:13 -08:00
committed by GitHub
parent 5bebaebcc0
commit 5a22abb85b
2 changed files with 18 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ struct SystemServerDriverStation {
wpi::nt::BooleanPublisher hasUserCodeReadyPublisher;
wpi::nt::BooleanSubscriber hasSetWallClockSubscriber;
wpi::nt::BooleanSubscriber serverReadySubscriber;
wpi::nt::ProtobufSubscriber<mrc::ControlData> controlDataSubscriber;
wpi::nt::ProtobufSubscriber<mrc::MatchInfo> matchInfoSubscriber;
@@ -166,6 +167,22 @@ struct SystemServerDriverStation {
ntInst.GetIntegerTopic(ROBOT_CURRENT_OPMODE_TRACE_PATH)
.Publish(options);
traceOpModePublisher.GetTopic().SetCached(false);
serverReadySubscriber =
ntInst.GetBooleanTopic(ROBOT_SERVER_READY_PATH).Subscribe(false);
int checkCount = 0;
while (!serverReadySubscriber.Get()) {
if (++checkCount > 500) {
fmt::print(stderr,
"Error: Waiting for server ready failed. Restarting app and "
"retrying...\n",
ROBOT_SERVER_READY_PATH);
std::terminate();
}
std::this_thread::sleep_for(std::chrono::milliseconds(20));
}
}
void HandleListener(const wpi::nt::Event& event);