Created
September 25, 2014 20:02
-
-
Save revol/5246d09baca7b9ccbc6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Set date with GPS | |
## reV 2014-09-25 | |
GPS="/dev/ttyUSB0" | |
LAST="/sd/logs/date.last" | |
if [[ ! -e $GPS ]]; then | |
echo $GPS not found! | |
echo check last known date | |
if [[ -e $LAST ]]; then | |
GPSDATE=$(cat $LAST) | |
else | |
echo $LAST not found! | |
GPSDATE="2014-01-01 00:00:00" | |
fi | |
else | |
GPSDATE=$(gpspipe -w -n 10 | grep TPV | sed -r 's/.*"time":"([^"]*)".*/\1/' | tail -n 1 | sed -e 's/^\(.\{10\}\)T\(.\{8\}\).*/\1 \2/') | |
echo $GPSDATE > $LAST | |
fi | |
date -us "$GPSDATE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment