@@ -434,9 +434,17 @@ def _disabled(self) -> None:
434434 self .onException (forceReport = True )
435435 watchdog .addEpoch ("disabledInit()" )
436436
437+ refreshData = wpilib .DriverStation .refreshData
438+ DSControlWord = wpilib .DSControlWord
439+
437440 with NotifierDelay (self .control_loop_wait_time ) as delay :
438- while not self .__done and self .isDisabled ():
439- if ds_attached != self .__is_ds_attached ():
441+ while not self .__done :
442+ refreshData ()
443+ cw = DSControlWord ()
444+ if cw .isEnabled ():
445+ break
446+
447+ if ds_attached != cw .isDSAttached ():
440448 ds_attached = not ds_attached
441449 self .__nt_put_is_ds_attached (ds_attached )
442450
@@ -484,9 +492,15 @@ def _operatorControl(self) -> None:
484492 watchdog .addEpoch ("teleopInit()" )
485493
486494 observe = hal .observeUserProgramTeleop
495+ refreshData = wpilib .DriverStation .refreshData
496+ isTeleopEnabled = wpilib .DriverStation .isTeleopEnabled
487497
488498 with NotifierDelay (self .control_loop_wait_time ) as delay :
489- while not self .__done and self .isTeleopEnabled ():
499+ while not self .__done :
500+ refreshData ()
501+ if not isTeleopEnabled ():
502+ break
503+
490504 observe ()
491505 try :
492506 self .teleopPeriodic ()
@@ -526,8 +540,16 @@ def _test(self) -> None:
526540 self .onException (forceReport = True )
527541 watchdog .addEpoch ("testInit()" )
528542
543+ refreshData = wpilib .DriverStation .refreshData
544+ DSControlWord = wpilib .DSControlWord
545+
529546 with NotifierDelay (self .control_loop_wait_time ) as delay :
530- while not self .__done and self .isTest () and self .isEnabled ():
547+ while not self .__done :
548+ refreshData ()
549+ cw = DSControlWord ()
550+ if not (cw .isTest () and cw .isEnabled ()):
551+ break
552+
531553 hal .observeUserProgramTest ()
532554 try :
533555 self .testPeriodic ()
0 commit comments