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