[wpilib] Wait for expansion hub connected for up to half a second during boot (#8715)

Closes #8714
This commit is contained in:
Thad House
2026-04-06 08:50:47 -07:00
committed by GitHub
parent 173ecd3d02
commit e4ef8a2515
2 changed files with 24 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import org.wpilib.hardware.hal.HAL;
import org.wpilib.networktables.BooleanSubscriber;
import org.wpilib.networktables.NetworkTableInstance;
import org.wpilib.system.SystemServer;
import org.wpilib.system.Timer;
/** This class controls a REV ExpansionHub plugged in over USB to Systemcore. */
public class ExpansionHub implements AutoCloseable {
@@ -28,6 +29,16 @@ public class ExpansionHub implements AutoCloseable {
m_hubConnectedSubscriber =
systemServer.getBooleanTopic("/rhsp/" + usbId + "/connected").subscribe(false);
// Wait up to half a second for connected to come up, using a poll loop to
// ensure we don't block.
double startTime = Timer.getMonotonicTimestamp();
while (Timer.getMonotonicTimestamp() - startTime < 0.5) {
if (m_hubConnectedSubscriber.get(false)) {
break;
}
Timer.delay(0.01);
}
}
@Override