Compare commits

..

No commits in common. "1712ebbded2d19a7a5d9cb8cab5b641ad087ae74" and "fa469cda30b568647736a254dc84b2683f1ab30d" have entirely different histories.

3 changed files with 9 additions and 20 deletions

View file

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

View file

@ -1,3 +1,3 @@
#! /bin/bash #! /bin/bash
make -C /home/ncrs1/stephan/tk102gpx TIMELIMIT=-t1d tk102-1.gpx tk102-1.png tk102-2.gpx tk102-2.png make -C /home/ncrs1/stephan/tk102gpx tk102-1.gpx tk102-1.png

View file

@ -57,15 +57,15 @@ for o,v in options:
print(f"--serial={serial}", file=sys.stderr) print(f"--serial={serial}", file=sys.stderr)
tk_re = re.compile(b"".join(( tk_re = re.compile(b"".join((
b"(?P<SERIAL>23[0-9]+)?,", b"(?P<SERIAL>[0-9]+)?,",
b"(?P<PHONE>\+?[^,]+)?,", b"(?P<PHONE>\+?[0-9]+)?,",
b"GPRMC,", b"GPRMC,",
b"(?P<TIME>[0-9]{6}(\.[0-9]+)?)?,", b"(?P<TIME>[0-9]{6}(\.[0-9]+)?)?,",
b"(?P<AV>[AV])?,", b"(?P<AV>[AV])?,",
b"(?P<LAT>[0-9]+\.[0-9]+)?,", b"(?P<LAT>[0-9]+\.[0-9]+)?,",
b"(?P<NS>[NS]),", b"(?P<NS>[NS])?,",
b"(?P<LON>[0-9]+\.[0-9]+)?,", b"(?P<LON>[0-9]+\.[0-9]+)?,",
b"(?P<EW>[EW]),", b"(?P<EW>[EW])?,",
b"(?P<SOG>[0-9]+\.[0-9]+)?,", b"(?P<SOG>[0-9]+\.[0-9]+)?,",
b"(?P<COG>[0-9]+\.[0-9]+)?,", b"(?P<COG>[0-9]+\.[0-9]+)?,",
b"(?P<DATE>[0-9]{6})?,", b"(?P<DATE>[0-9]{6})?,",
@ -73,10 +73,9 @@ tk_re = re.compile(b"".join((
b"(?P<WHAT>[^,]*,)?", b"(?P<WHAT>[^,]*,)?",
b"A\*(?P<GPCKS>[0-9A-F][0-9A-F]),", b"A\*(?P<GPCKS>[0-9A-F][0-9A-F]),",
b"(?P<SIGNAL>[FL])?,", b"(?P<SIGNAL>[FL])?,",
b"(?P<MESSAGE>[^,]+,)?",
b"imei:(?P<IMEI>[0-9]+),", b"imei:(?P<IMEI>[0-9]+),",
b"(?P<LEN>[0-9]{3})", b"(?P<LEN>[0-9]{3})",
b"(?P<BCKS>2[^23]|[^2][^2])?" b"(?P<BCKS>..)"
)), flags=re.DOTALL) )), flags=re.DOTALL)
def gprmc2deg(d,dd): def gprmc2deg(d,dd):
@ -155,9 +154,6 @@ class TKGPX(gpxpy.gpx.GPX):
if verbose>0 and rd["SIGNAL"] != b"F": if verbose>0 and rd["SIGNAL"] != b"F":
print(f"Signal is {repr(rd['SIGNAL'])} at {rd['SERIAL']}", file=sys.stderr) 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)
pd = { pd = {
"latitude": gprmc2deg(rd["LAT"], rd["NS"]), "latitude": gprmc2deg(rd["LAT"], rd["NS"]),
"longitude": gprmc2deg(rd["LON"], rd["EW"]), "longitude": gprmc2deg(rd["LON"], rd["EW"]),
@ -189,17 +185,12 @@ class TKGPX(gpxpy.gpx.GPX):
cd = {} cd = {}
cd.update(strorbytes(rd, 'SIGNAL')) cd.update(strorbytes(rd, 'SIGNAL'))
cd.update(strorbytes(rd, 'SERIAL')) cd.update(strorbytes(rd, 'SERIAL'))
if rd['PHONE'].isascii():
cd.update(strorbytes(rd, 'PHONE')) cd.update(strorbytes(rd, 'PHONE'))
else:
cd['PHONE'] = "*"*14
cd['time'] = pd['time'].isoformat()[:19]+'Z' cd['time'] = pd['time'].isoformat()[:19]+'Z'
cd['lat'] = f"{rd['LAT'][:2].decode()}°{rd['LAT'][2:].decode()}'{rd['NS'].decode()}" cd['lat'] = f"{rd['LAT'][:2].decode()}°{rd['LAT'][2:].decode()}'{rd['NS'].decode()}"
cd['lon'] = f"{rd['LON'][:3].decode()}°{rd['LAT'][3:].decode()}'{rd['EW'].decode()}" cd['lon'] = f"{rd['LON'][:3].decode()}°{rd['LAT'][3:].decode()}'{rd['EW'].decode()}"
cd.update(strorbytes(rd, 'SOG')) cd.update(strorbytes(rd, 'SOG'))
cd.update(strorbytes(rd, 'COG')) cd.update(strorbytes(rd, 'COG'))
if rd['MESSAGE']:
cd.update(strorbytes(rd, 'MESSAGE'))
if fieldnames: if fieldnames:
print(", ".join([f"{k}={cd[k]}" for k in cd])) print(", ".join([f"{k}={cd[k]}" for k in cd]))
else: else: