mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-12 07:23:45 +08:00
guarded callback for supervisor
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
HW1_NORMAL_BUS0_LAYOUT = {(0, 0x108): 8, (0, 0x155): 8, (0, 0x20A): 8,
|
||||
(0, 0x368): 8, (0, 0x370): 8, (2, 0x488): 4, (2, 0x2B9): 8}
|
||||
|
||||
# Modern party-bus driver/chassis state and stock Autopilot messages are already
|
||||
# visible without switching CAN2 to OBD wiring. This only scopes live queries;
|
||||
# it does not distinguish Model 3/Y, establish firmware support or grant control.
|
||||
# Modern party-bus layout scopes live queries without granting control.
|
||||
MODERN_NORMAL_BUS0_LAYOUT = {(0, 0x118): 8, (0, 0x145): 8, (0, 0x155): 8,
|
||||
(0, 0x257): 8, (0, 0x311): 7, (0, 0x370): 8,
|
||||
(2, 0x488): 4, (2, 0x2B9): 8}
|
||||
|
||||
@@ -50,6 +50,8 @@ class CameraSnapshot:
|
||||
results[camera] = SnapshotUnavailable("Wait before another snapshot")
|
||||
else:
|
||||
self.last_request[camera] = self.clock()
|
||||
if len(results) == len(cameras):
|
||||
return results
|
||||
from openpilot.starpilot.galaxy.camera_request import request, boot_ns
|
||||
capture_started = self.clock()
|
||||
request()
|
||||
|
||||
@@ -253,6 +253,15 @@ class CameraSnapshotBatchTest(unittest.TestCase):
|
||||
self.assertEqual(self.launched, [('cabin', 0, [])])
|
||||
self.assert_released()
|
||||
|
||||
def test_fully_throttled_batch_does_not_request_camera(self):
|
||||
owner = self.owner()
|
||||
owner.last_request.update(wide=0, cabin=0)
|
||||
result = owner.capture_many(['wide', 'cabin'], permitted=lambda: True)
|
||||
self.assertTrue(all(isinstance(value, SnapshotUnavailable) for value in result.values()))
|
||||
self.request.assert_not_called()
|
||||
self.assertEqual(self.launched, [])
|
||||
self.assert_released()
|
||||
|
||||
def test_real_readers_revoked_together_and_exclusive_lock(self):
|
||||
children = []
|
||||
def spawn(args, **kwargs):
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -320,9 +320,11 @@ class SharedRadioWatch:
|
||||
last = current
|
||||
self.changed_at = time.monotonic()
|
||||
self.log("other_wifi_changed", interface=self.interface)
|
||||
if not self._carrier():
|
||||
if self.on_down is not None:
|
||||
if self.on_down is not None and not self._carrier():
|
||||
try:
|
||||
self.on_down()
|
||||
except Exception as error:
|
||||
self.log("other_wifi_hold_failed", error=str(error) or type(error).__name__)
|
||||
|
||||
def stalled(self) -> None:
|
||||
if self.on_stall is not None:
|
||||
|
||||
@@ -144,6 +144,34 @@ def test_watch_without_the_counter_never_reports(tmp_path):
|
||||
watch.stop()
|
||||
|
||||
|
||||
def test_watch_continues_after_hold_failure(tmp_path):
|
||||
counter, carrier = tmp_path / 'carrier_changes', tmp_path / 'carrier'
|
||||
counter.write_text('1\n')
|
||||
carrier.write_text('0\n')
|
||||
calls, logged = [], []
|
||||
|
||||
def fail_hold():
|
||||
calls.append(True)
|
||||
raise RuntimeError('lease failed')
|
||||
|
||||
watch = SharedRadioWatch(lambda name, **data: logged.append((name, data)), interval=0.01,
|
||||
counter=counter, carrier=carrier, on_down=fail_hold).start()
|
||||
try:
|
||||
time.sleep(0.05)
|
||||
counter.write_text('2\n')
|
||||
deadline = time.monotonic() + 2
|
||||
while len(calls) < 1:
|
||||
assert time.monotonic() < deadline
|
||||
time.sleep(0.01)
|
||||
counter.write_text('3\n')
|
||||
while len(calls) < 2:
|
||||
assert time.monotonic() < deadline
|
||||
time.sleep(0.01)
|
||||
assert [name for name, _ in logged].count('other_wifi_hold_failed') == 2
|
||||
finally:
|
||||
watch.stop()
|
||||
|
||||
|
||||
def test_notice_is_shown_once_and_only_while_fresh(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(reconnect_notice.identity_store, "boot_id", lambda: "current") # no /proc off device
|
||||
path = tmp_path / "notice.json"
|
||||
|
||||
Reference in New Issue
Block a user