[wpilib] Add function to wait for DS Connection (#5230)

This commit is contained in:
Thad House
2023-07-10 09:53:16 -07:00
committed by GitHub
parent a6463ed761
commit b250a03944
3 changed files with 49 additions and 0 deletions

View File

@@ -568,6 +568,20 @@ int DriverStation::GetLocation() {
}
}
bool DriverStation::WaitForDsConnection(units::second_t timeout) {
wpi::Event event{true, false};
HAL_ProvideNewDataEventHandle(event.GetHandle());
bool result = false;
if (timeout == 0_s) {
result = wpi::WaitForObject(event.GetHandle());
} else {
result = wpi::WaitForObject(event.GetHandle(), timeout.value(), nullptr);
}
HAL_RemoveNewDataEventHandle(event.GetHandle());
return result;
}
double DriverStation::GetMatchTime() {
int32_t status = 0;
return HAL_GetMatchTime(&status);