mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user