Verified Commit 7dad5e4c authored by Clayton Craft's avatar Clayton Craft
Browse files

stm_agps_serial: drop readline method in favor of inherited version

This just uses the readline implementation in stm_agps. The longer delay
(0.1s --> 0.5s) doesn't really seem to matter that much in my testing.
parent faf33713
# Copyright(c) 2021 by craftyguy "Clayton Craft" <>
# Distributed under GPLv3+ (see COPYING) WITHOUT ANY WARRANTY.
import logging
import trio
from .logger import LoggedException
from .stm_agps import STM_AGPS
......@@ -39,25 +38,5 @@ class STM_AGPS_SERIAL(STM_AGPS):
except Exception as e:
raise LoggedException(e)
async def readline(self):
# based on this implementation of readline:
idx = self._buf.find(b'\n')
if idx >= 0:
line = self._buf[:idx+1]
self._buf = bytearray(self._buf[idx+1:])
return bytes(line)
while True:
data = await self._ser.receive_some(40)
idx = data.find(b'\n')
if idx >= 0:
line = self._buf + data[:idx+1]
self._buf = bytearray(data[idx+1:])
return bytes(line)
# sleep to prevent spinning faster than the serial device can write
await trio.sleep(0.1)
async def _write(self, data):
await self._ser.send_all(data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment