We rolling back ?
This commit is contained in:
@@ -34,11 +34,13 @@ class GROVEGPS:
|
||||
self.longitude = -1.0
|
||||
|
||||
def read(self):
|
||||
"""Reads the latest GGA sentence from serial, thread-safely."""
|
||||
"""Reads the freshest GGA sentence from serial, thread-safely."""
|
||||
with serial_lock:
|
||||
for _ in range(10): # Read pending lines from buffer
|
||||
if self.ser.in_waiting == 0:
|
||||
break
|
||||
# 1. Flush accumulated stale buffer data
|
||||
self.ser.reset_input_buffer()
|
||||
|
||||
# 2. Read through the fresh incoming stream to find a complete GGA line
|
||||
for _ in range(15):
|
||||
raw_bytes = self.ser.readline()
|
||||
try:
|
||||
line = raw_bytes.decode('utf-8', errors='ignore').strip()
|
||||
|
||||
Reference in New Issue
Block a user