From 9113816e1dd08f7368bcc311d2514dc91033540c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 23 Jul 2023 15:59:26 -0700 Subject: [PATCH] rawgpsd: fix double setup (#29108) * rawgpsd: fix double setup * speedup test * update that one * minimal diff --------- Co-authored-by: Comma Device --- system/sensord/rawgps/rawgpsd.py | 21 ++++++++++++--------- system/sensord/rawgps/test_rawgps.py | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/system/sensord/rawgps/rawgpsd.py b/system/sensord/rawgps/rawgpsd.py index 3f8fd8c67a..956da086e1 100755 --- a/system/sensord/rawgps/rawgpsd.py +++ b/system/sensord/rawgps/rawgpsd.py @@ -162,7 +162,9 @@ def inject_assistance(): returncode=e.returncode ) -def setup_quectel(diag: ModemDiag): +def setup_quectel(diag: ModemDiag) -> bool: + ret = False + # enable OEMDRE in the NV # TODO: it has to reboot for this to take effect DIAG_NV_READ_F = 38 @@ -186,7 +188,9 @@ def setup_quectel(diag: ModemDiag): at_cmd("AT+QGPSXTRA=1") at_cmd("AT+QGPSSUPLURL=\"NULL\"") if os.path.exists(ASSIST_DATA_FILE): + ret = True inject_assistance() + os.remove(ASSIST_DATA_FILE) #at_cmd("AT+QGPSXTRADATA?") time_str = datetime.utcnow().strftime("%Y/%m/%d,%H:%M:%S") at_cmd(f"AT+QGPSXTRATIME=0,\"{time_str}\",1,1,1000") @@ -213,6 +217,8 @@ def setup_quectel(diag: ModemDiag): 0,0 )) + return ret + def teardown_quectel(diag): at_cmd("AT+QGPSCFG=\"outport\",\"none\"") if gps_enabled(): @@ -260,8 +266,8 @@ def main() -> NoReturn: # connect to modem diag = ModemDiag() - setup_quectel(diag) - want_assistance = True + r = setup_quectel(diag) + want_assistance = not r current_gps_time = utc_to_gpst(GPSTime.from_datetime(datetime.utcnow())) cloudlog.warning("quectel setup done") gpio_init(GPIO.UBLOX_PWR_EN, True) @@ -270,12 +276,9 @@ def main() -> NoReturn: pm = messaging.PubMaster(['qcomGnss', 'gpsLocation']) while 1: - if os.path.exists(ASSIST_DATA_FILE): - if want_assistance: - setup_quectel(diag) - want_assistance = False - else: - os.remove(ASSIST_DATA_FILE) + if os.path.exists(ASSIST_DATA_FILE) and want_assistance: + setup_quectel(diag) + want_assistance = False opcode, payload = diag.recv() if opcode != DIAG_LOG_F: diff --git a/system/sensord/rawgps/test_rawgps.py b/system/sensord/rawgps/test_rawgps.py index 682cdecbd5..8c2e246764 100755 --- a/system/sensord/rawgps/test_rawgps.py +++ b/system/sensord/rawgps/test_rawgps.py @@ -67,7 +67,7 @@ class TestRawgpsd(unittest.TestCase): os.system("sudo systemctl stop systemd-resolved") with self.subTest(internet=internet): managed_processes['rawgpsd'].start() - assert self._wait_for_output(10) + assert self._wait_for_output(7) managed_processes['rawgpsd'].stop() def test_turns_off_gnss(self):