From 636632b1d03f14c45911c1051d39ff01bd6f118a Mon Sep 17 00:00:00 2001 From: spv Date: Tue, 29 Jul 2025 18:35:09 -0400 Subject: wait for gps fix, use file extensions, make the logging all professional-like --- .gitignore | 2 ++ src/dirty_hack | 8 -------- src/dirty_hack.sh | 8 ++++++++ src/log_shit.py | 12 ++++++------ src/setup.sh | 13 +++++++++++++ src/skid.sh | 10 +++++++++- src/wait_for_fix.sh | 14 ++++++++++++++ 7 files changed, 52 insertions(+), 15 deletions(-) delete mode 100755 src/dirty_hack create mode 100755 src/dirty_hack.sh create mode 100755 src/setup.sh create mode 100755 src/wait_for_fix.sh diff --git a/.gitignore b/.gitignore index f493e93..c50a43d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +log + *.log *.swp diff --git a/src/dirty_hack b/src/dirty_hack deleted file mode 100755 index 67691a3..0000000 --- a/src/dirty_hack +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env zsh - -mmcli -m any --location-get | # get location from modem manager -grep "long\|lat\|alt" | # select only relevant lines -cut -d':' -f2 | # remove colons, -cut -d' ' -f2 | # and leading spaces -tr '\n' ',' | # csv-esque -cut -d',' -f1-3 # remove unwanted newline \ No newline at end of file diff --git a/src/dirty_hack.sh b/src/dirty_hack.sh new file mode 100755 index 0000000..67691a3 --- /dev/null +++ b/src/dirty_hack.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh + +mmcli -m any --location-get | # get location from modem manager +grep "long\|lat\|alt" | # select only relevant lines +cut -d':' -f2 | # remove colons, +cut -d' ' -f2 | # and leading spaces +tr '\n' ',' | # csv-esque +cut -d',' -f1-3 # remove unwanted newline \ No newline at end of file diff --git a/src/log_shit.py b/src/log_shit.py index a60711f..7e5da43 100644 --- a/src/log_shit.py +++ b/src/log_shit.py @@ -16,20 +16,20 @@ except: print("fake file.") sys.exit(-1) -print("file: %s\n\ -how often: %f\n\ -how long: %f" % (log_file, how_often, time_to_do_it)) +print("[i] file: %s\n\ +[i] how often: %f\n\ +[i] how long: %f" % (log_file, how_often, time_to_do_it)) start = time.time() now = time.time -print("we out here, yo", flush=True) +print("[i] we out here, yo", flush=True) while (start + time_to_do_it) > now(): # print("we out here, yo", flush=True) - lat, lon, alt = [float(x) for x in subprocess.getoutput("src/dirty_hack").split(",")] + lat, lon, alt = [float(x) for x in subprocess.getoutput("src/dirty_hack.sh").split(",")] - print("%f: %f, %f, %f" % (time.time_ns() / (10**9), lat, lon, alt)) + print("[i] %f: %f, %f, %f" % (time.time_ns() / (10**9), lat, lon, alt)) f.write("%f: %f, %f, %f\n" % (time.time_ns() / (10**9), lat, lon, alt)) f.flush() diff --git a/src/setup.sh b/src/setup.sh new file mode 100755 index 0000000..c329f76 --- /dev/null +++ b/src/setup.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env zsh + +echo '[*] enabling gps-raw & agps-msb' +printf '[i] mmcli: ' +mmcli -m any --location-enable-{gps-raw,agps-msb} + +echo '[*] fixing refresh rate' +printf '[i] mmcli: ' +mmcli -m any --location-set-gps-refresh-rate 1 + +echo '[*] enabling signal' +printf '[i] mmcli: ' +mmcli -m any --location-set-enable-signal \ No newline at end of file diff --git a/src/skid.sh b/src/skid.sh index 5671560..07cc305 100755 --- a/src/skid.sh +++ b/src/skid.sh @@ -4,9 +4,17 @@ clear read figlet gps_haxx +echo '=============================================' sleep 1 -echo doing it. +echo '[*] setting up...' + +src/setup.sh +src/wait_for_fix.sh + +sleep 1 + +echo '[*] doing it.' python3 src/log_shit.py `date +%s`.log 1 600 \ No newline at end of file diff --git a/src/wait_for_fix.sh b/src/wait_for_fix.sh new file mode 100755 index 0000000..ab83968 --- /dev/null +++ b/src/wait_for_fix.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env zsh + +function got_fix { + mmcli -m any --location-get | + grep -q GPS && + echo 'true' +} + +while [ "`got_fix`" != 'true' ]; do + echo "[i] waiting for fix..." + sleep 1 +done + +echo "[*] got it." \ No newline at end of file -- cgit v1.2.3