Small things because fuck sd cards
This commit is contained in:
@@ -2,7 +2,7 @@ import serial
|
||||
import time
|
||||
import threading
|
||||
from shared.logging import log
|
||||
from sensors.lock import serial_lock
|
||||
from sensors.lock import safe_serial_access
|
||||
|
||||
def calculate_nmea_checksum(line: str) -> bool:
|
||||
"""Validates standard NMEA 0183 sentence checksum ($...*HH)."""
|
||||
@@ -35,7 +35,12 @@ class GROVEGPS:
|
||||
|
||||
def read(self):
|
||||
"""Reads the freshest GGA sentence from serial, thread-safely."""
|
||||
with serial_lock:
|
||||
# Allow sufficient time for the serial reads (readline can block up to timeout=1s per line)
|
||||
with safe_serial_access(timeout=2.0) as acquired:
|
||||
if not acquired:
|
||||
log("GPS: Serial lock acquisition timed out")
|
||||
return False
|
||||
|
||||
# 1. Flush accumulated stale buffer data
|
||||
self.ser.reset_input_buffer()
|
||||
|
||||
@@ -115,5 +120,4 @@ def get_gps_data():
|
||||
else:
|
||||
log(f"GPS: No valid fix or data available. Satellites: {gps.satellites}, Quality: {gps.quality}")
|
||||
|
||||
# Return None so main.py doesn't process or log empty GPS data
|
||||
return None
|
||||
Reference in New Issue
Block a user