Compare commits

...

3 commits

Author SHA1 Message Date
Stephan I. Böttcher
6a3bef6e1a tk102gpx: fix ndata read loop 2023-09-29 19:42:31 +02:00
af5da452dd re fixes 2023-09-29 19:20:10 +02:00
d6b17ed839 use tk102cat.py for target nc% 2023-09-29 19:19:45 +02:00
2 changed files with 14 additions and 9 deletions

View file

@ -9,7 +9,7 @@ all: $(patsubst %, %.gpx, $(FILES))
./tk102gpx.py $(TIMELIMIT) $< > $@
nc%: tk102-%.log
(while true; do nc -lp 1020$* -w 999; done) | tee -a $< | cat -v
./tk102cat.py -p 1020$* | tee -a $< | cat -v
tail%: tk102-%.log
./tk102gpx.py $(TIMELIMIT) -CFf $< | tee tk102-$*.txt

View file

@ -57,18 +57,18 @@ for o,v in options:
print(f"--serial={serial}", file=sys.stderr)
tk_re = re.compile(b"".join((
b"(?P<SERIAL>23[0-9]+)?,",
b"(?P<PHONE>\+?[^,]+)?,",
b"(?P<SERIAL>23[0-9]+),",
b"(?P<PHONE>[^,]+(,[^,]*)?),",
b"GPRMC,",
b"(?P<TIME>[0-9]{6}(\.[0-9]+)?)?,",
b"(?P<AV>[AV])?,",
b"(?P<LAT>[0-9]+\.[0-9]+)?,",
b"(?P<TIME>[0-9]{6}(\.[0-9]+)?),",
b"(?P<AV>[AV]),",
b"(?P<LAT>[0-9]+\.[0-9]+),",
b"(?P<NS>[NS]),",
b"(?P<LON>[0-9]+\.[0-9]+)?,",
b"(?P<LON>[0-9]+\.[0-9]+),",
b"(?P<EW>[EW]),",
b"(?P<SOG>[0-9]+\.[0-9]+)?,",
b"(?P<COG>[0-9]+\.[0-9]+)?,",
b"(?P<DATE>[0-9]{6})?,",
b"(?P<DATE>[0-9]{6}),",
b"(?P<VAR>[^,]+)?,",
b"(?P<WHAT>[^,]*,)?",
b"A\*(?P<GPCKS>[0-9A-F][0-9A-F]),",
@ -122,6 +122,7 @@ class TKGPX(gpxpy.gpx.GPX):
if not ndata:
break
data += ndata
m = tk_re.search(data)
if m is None:
if not follow:
break
@ -156,7 +157,7 @@ class TKGPX(gpxpy.gpx.GPX):
print(f"Signal is {repr(rd['SIGNAL'])} at {rd['SERIAL']}", file=sys.stderr)
if verbose>0 and rd["MESSAGE"]:
print(f"MESAAGE is {repr(rd['MESSAGE'])} at {rd['SERIAL']}", file=sys.stderr)
print(f"MESSAGE is {repr(rd['MESSAGE'])} at {rd['SERIAL']}", file=sys.stderr)
pd = {
"latitude": gprmc2deg(rd["LAT"], rd["NS"]),
@ -227,6 +228,10 @@ class TKGPX(gpxpy.gpx.GPX):
if follow and not raw and verbose < 2:
print(repr(point), file=sys.stderr)
if verbose > 1:
sys.stdout.flush()
print(f"Unprocessed data: {len(data)} Bytes: {repr(data)}", file=sys.stderr)
def strorbytes(rd, f):
if not f in rd:
return {}