-
Notifications
You must be signed in to change notification settings - Fork 0
/
oldgps.sh
executable file
·38 lines (34 loc) · 1016 Bytes
/
oldgps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
while [ 1 ]
do
read this_line
# if cr/lf bothers you, make it lf only
# (os-specfic concern)
#
this_line=$( echo $this_line | sed s/$'\r'//g )
# get a precise time stamp
# %N = nanoseconds
#
ts=$(date +"%Y/%m/%d %H:%M:%S.%N")
echo $ts $this_line >> full-log.txt
# let us filter the current position
#
if [[ "$this_line" =~ "GPRMC" ]]
then
# ok, it looks like a GPS reading (may be void)
# if field 3 is V, the reading is void (or maybe
# only untrusted?), if it is A, then the position
# is Active (and therefore given with confidence?)
#
if [[ $(echo $this_line | cut -d, -f 4-6) != ",,," ]]
then
# get latitude and longitude
gps_pos=($(echo $this_line | \
cut -d, -f 3-7 | \
tr , ' ' | \
sed 's/\(^0*\)\|\(\b0*\)//g'))
# show
echo $ts ${gps_pos[@]}
# sleep 2s
fi
fi
done < /dev/ttyAMA0