mirror of
https://codeberg.org/ET-Kiel/tk102gpx.git
synced 2026-06-28 07:29:51 +02:00
Compare commits
No commits in common. "1712ebbded2d19a7a5d9cb8cab5b641ad087ae74" and "fa469cda30b568647736a254dc84b2683f1ab30d" have entirely different histories.
1712ebbded
...
fa469cda30
3 changed files with 9 additions and 20 deletions
6
Makefile
6
Makefile
|
|
@ -1,18 +1,16 @@
|
|||
|
||||
FILES=tk102-1
|
||||
|
||||
TIMELIMIT=
|
||||
|
||||
all: $(patsubst %, %.gpx, $(FILES))
|
||||
|
||||
%.gpx: %.log
|
||||
./tk102gpx.py $(TIMELIMIT) $< > $@
|
||||
./tk102gpx.py $< > $@
|
||||
|
||||
nc%: tk102-%.log
|
||||
(while true; do nc -lp 1020$* -w 999; done) | tee -a $< | cat -v
|
||||
|
||||
tail%: tk102-%.log
|
||||
./tk102gpx.py $(TIMELIMIT) -CFf $< | tee tk102-$*.txt
|
||||
./tk102gpx.py -t1w -CFf $< | tee tk102-$*.txt
|
||||
|
||||
%.txt: %.log
|
||||
./tk102gpx.py -CF $< > $@
|
||||
|
|
|
|||
2
cron.sh
2
cron.sh
|
|
@ -1,3 +1,3 @@
|
|||
#! /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
|
||||
|
|
|
|||
21
tk102gpx.py
21
tk102gpx.py
|
|
@ -57,15 +57,15 @@ 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>[0-9]+)?,",
|
||||
b"(?P<PHONE>\+?[0-9]+)?,",
|
||||
b"GPRMC,",
|
||||
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<NS>[NS])?,",
|
||||
b"(?P<LON>[0-9]+\.[0-9]+)?,",
|
||||
b"(?P<EW>[EW]),",
|
||||
b"(?P<EW>[EW])?,",
|
||||
b"(?P<SOG>[0-9]+\.[0-9]+)?,",
|
||||
b"(?P<COG>[0-9]+\.[0-9]+)?,",
|
||||
b"(?P<DATE>[0-9]{6})?,",
|
||||
|
|
@ -73,10 +73,9 @@ tk_re = re.compile(b"".join((
|
|||
b"(?P<WHAT>[^,]*,)?",
|
||||
b"A\*(?P<GPCKS>[0-9A-F][0-9A-F]),",
|
||||
b"(?P<SIGNAL>[FL])?,",
|
||||
b"(?P<MESSAGE>[^,]+,)?",
|
||||
b"imei:(?P<IMEI>[0-9]+),",
|
||||
b"(?P<LEN>[0-9]{3})",
|
||||
b"(?P<BCKS>2[^23]|[^2][^2])?"
|
||||
b"(?P<BCKS>..)"
|
||||
)), flags=re.DOTALL)
|
||||
|
||||
def gprmc2deg(d,dd):
|
||||
|
|
@ -155,9 +154,6 @@ class TKGPX(gpxpy.gpx.GPX):
|
|||
if verbose>0 and rd["SIGNAL"] != b"F":
|
||||
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 = {
|
||||
"latitude": gprmc2deg(rd["LAT"], rd["NS"]),
|
||||
"longitude": gprmc2deg(rd["LON"], rd["EW"]),
|
||||
|
|
@ -189,17 +185,12 @@ class TKGPX(gpxpy.gpx.GPX):
|
|||
cd = {}
|
||||
cd.update(strorbytes(rd, 'SIGNAL'))
|
||||
cd.update(strorbytes(rd, 'SERIAL'))
|
||||
if rd['PHONE'].isascii():
|
||||
cd.update(strorbytes(rd, 'PHONE'))
|
||||
else:
|
||||
cd['PHONE'] = "*"*14
|
||||
cd.update(strorbytes(rd, 'PHONE'))
|
||||
cd['time'] = pd['time'].isoformat()[:19]+'Z'
|
||||
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.update(strorbytes(rd, 'SOG'))
|
||||
cd.update(strorbytes(rd, 'COG'))
|
||||
if rd['MESSAGE']:
|
||||
cd.update(strorbytes(rd, 'MESSAGE'))
|
||||
if fieldnames:
|
||||
print(", ".join([f"{k}={cd[k]}" for k in cd]))
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue