|
|
@ -136,6 +136,17 @@ class TTYPigeon: |
|
|
|
return True |
|
|
|
return True |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_almanac(pigeon: TTYPigeon) -> None: |
|
|
|
|
|
|
|
# store almanac in flash |
|
|
|
|
|
|
|
pigeon.send(b"\xB5\x62\x09\x14\x04\x00\x00\x00\x00\x00\x21\xEC") |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
if pigeon.wait_for_ack(ack=UBLOX_SOS_ACK, nack=UBLOX_SOS_NACK): |
|
|
|
|
|
|
|
cloudlog.info("Done storing almanac") |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
cloudlog.error("Error storing almanac") |
|
|
|
|
|
|
|
except TimeoutError: |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def init_baudrate(pigeon: TTYPigeon): |
|
|
|
def init_baudrate(pigeon: TTYPigeon): |
|
|
|
# ublox default setting on startup is 9600 baudrate |
|
|
|
# ublox default setting on startup is 9600 baudrate |
|
|
|
pigeon.set_baud(9600) |
|
|
|
pigeon.set_baud(9600) |
|
|
@ -245,16 +256,6 @@ def deinitialize_and_exit(pigeon: TTYPigeon | None): |
|
|
|
# controlled GNSS stop |
|
|
|
# controlled GNSS stop |
|
|
|
pigeon.send(b"\xB5\x62\x06\x04\x04\x00\x00\x00\x08\x00\x16\x74") |
|
|
|
pigeon.send(b"\xB5\x62\x06\x04\x04\x00\x00\x00\x08\x00\x16\x74") |
|
|
|
|
|
|
|
|
|
|
|
# store almanac in flash |
|
|
|
|
|
|
|
pigeon.send(b"\xB5\x62\x09\x14\x04\x00\x00\x00\x00\x00\x21\xEC") |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
if pigeon.wait_for_ack(ack=UBLOX_SOS_ACK, nack=UBLOX_SOS_NACK): |
|
|
|
|
|
|
|
cloudlog.warning("Done storing almanac") |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
cloudlog.error("Error storing almanac") |
|
|
|
|
|
|
|
except TimeoutError: |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# turn off power and exit cleanly |
|
|
|
# turn off power and exit cleanly |
|
|
|
set_power(False) |
|
|
|
set_power(False) |
|
|
|
sys.exit(0) |
|
|
|
sys.exit(0) |
|
|
@ -281,6 +282,7 @@ def run_receiving(pigeon: TTYPigeon, pm: messaging.PubMaster, duration: int = 0) |
|
|
|
def end_condition(): |
|
|
|
def end_condition(): |
|
|
|
return True if duration == 0 else time.monotonic() - start_time < duration |
|
|
|
return True if duration == 0 else time.monotonic() - start_time < duration |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
last_almanac_save = time.monotonic() |
|
|
|
while end_condition(): |
|
|
|
while end_condition(): |
|
|
|
dat = pigeon.receive() |
|
|
|
dat = pigeon.receive() |
|
|
|
if len(dat) > 0: |
|
|
|
if len(dat) > 0: |
|
|
@ -294,6 +296,11 @@ def run_receiving(pigeon: TTYPigeon, pm: messaging.PubMaster, duration: int = 0) |
|
|
|
msg = messaging.new_message('ubloxRaw', len(dat), valid=True) |
|
|
|
msg = messaging.new_message('ubloxRaw', len(dat), valid=True) |
|
|
|
msg.ubloxRaw = dat[:] |
|
|
|
msg.ubloxRaw = dat[:] |
|
|
|
pm.send('ubloxRaw', msg) |
|
|
|
pm.send('ubloxRaw', msg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# save almanac every 5 minutes |
|
|
|
|
|
|
|
if (time.monotonic() - last_almanac_save) > 60*5: |
|
|
|
|
|
|
|
save_almanac(pigeon) |
|
|
|
|
|
|
|
last_almanac_save = time.monotonic() |
|
|
|
else: |
|
|
|
else: |
|
|
|
# prevent locking up a CPU core if ublox disconnects |
|
|
|
# prevent locking up a CPU core if ublox disconnects |
|
|
|
time.sleep(0.001) |
|
|
|
time.sleep(0.001) |
|
|
|