From 8c46ad7c41eda61b9ed6e98e17d27e1df891252b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 11 Jul 2021 19:12:22 -0400 Subject: [PATCH] added test for USB device --- gpsd/gps-test.sh | 15 +++++++++++++++ gpsd/gps.sh | 9 --------- 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100755 gpsd/gps-test.sh delete mode 100755 gpsd/gps.sh diff --git a/gpsd/gps-test.sh b/gpsd/gps-test.sh new file mode 100755 index 00000000..1cb6183d --- /dev/null +++ b/gpsd/gps-test.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# from https://stackoverflow.com/questions/28387230/use-gpsd-or-cgps-to-return-latitude-and-longitude-then-quit + +gpspipe -w -n 5 | grep DEVICES | tail -n1|cut -d":" -f5|cut -d"," -f1 | grep ttyUSB +if [[ $(gpspipe -w -n 5 | grep DEVICES | tail -n1|cut -d":" -f5|cut -d"," -f1 | grep ttyUSB) ]]; then + + x=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f9|cut -d"," -f1) + y=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f10|cut -d"," -f1) + a=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f11|cut -d"," -f1) + echo "$x $y $a" +elif + echo "0 0 0" +fi + diff --git a/gpsd/gps.sh b/gpsd/gps.sh deleted file mode 100755 index a1ac5468..00000000 --- a/gpsd/gps.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# from https://stackoverflow.com/questions/28387230/use-gpsd-or-cgps-to-return-latitude-and-longitude-then-quit - -x=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f9|cut -d"," -f1) -y=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f10|cut -d"," -f1) -a=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f11|cut -d"," -f1) -echo "$x $y $a" -