| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | gawk and gps |
-={ 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)SEEN-BY: 123/500 138/146 140/1 153/802 7001 7715 154/10 203/0 221/0 1 6 360 SEEN-BY: 227/51 249/303 261/38 266/404 280/464 5003 288/34 320/119 340/200 SEEN-BY: 342/77 633/267 640/384 712/848 770/1 @PATH: 153/7001 7715 140/1 221/0 1 203/0 280/464 712/848 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.