Just a sample of the Echomail archive
[ << oldest | < older | list | newer > | newest >> ]
|  Message 260  |
|  Maurice Kinal to All  |
|  gawk and gps  |
|  04 Jul 15 16:22:29  |
 
-={ samedi, 04 juillet 2015, 16:22:29 +0000 }=-
Hey All!
A oneliner from a gawk/gps thingy I am picking away at;
-={ gawk oneliner starts }=-
gawk -F, '/\$GPRMC/ \
{print mktime(strftime("%C")substr($10,5,2)" "substr($10,3,2)" "\
substr($10,0,2)" "substr($2,0,2)" "substr($2,3,2)" "\
substr($2,5,2)), systime(); exit;}' /dev/ttyUSB0
-={ gawk oneliner ends }=-
Basically what it does is reformat the date and time from the RMC sentence
from the gps, which is attatched to /dev/ttyUSB0 in the situation here, and
send it to the mktime function to output it as unixtime (seconds) output for
comparison to the system's time in seconds -> the systime() function. For
continuous streaming, the exit call at the end needs to be changed to gawk's
fflush() function and then ye olde Ctrl+C keyboard combination is required to
end it's output.
Something worth noting is that 'strftime("%C")substr($10,5,2)' was needed to
tack on the century to the two digit year in the RMC sentence as mktime()
requires it's input to be of the form "YYYY MM DD HH MM SS".
I thought something like the above might be of interest to those using dialup
modems or other simular serial port type hardware. I have found GNU gawk to
be of great usage to bash scripts.
Life is good,
Maurice
... Don't cry for me I have vi.
--- GNU bash, version 4.3.39(1)-release (x86_64-atom-linux-gnu)
* Origin: Pointy Stick Society - Ladysmith BC, Canada (1:153/7001.0)
|
[ << oldest | < older | list | newer > | newest >> ]