awk and NMEA strings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk and NMEA strings
# 8  
Old 01-02-2009
Quote:
Originally Posted by summer_cherry
Hi not very sure about your detail logic, but below perl script may help you some

Code:
#! /usr/bin/perl
open FH,"<a.txt";
while(<FH>){
    my @tmp=split(",",$_);
    if($tmp[0] eq "\$GPRMC"){
        $tmp=$tmp[9]."-".$tmp[1];
    }
    if($tmp[0] eq "\$SDDBT"){
        my @arr=split(",",$_);
        print $tmp.":".$arr[3]."\n" if($arr[3] ne "");
    }
}
close FH;

Thanks .
I tested basic awk scripts in the night like

awk '$1 ~ /foo/ { print $0 }'

awk '$1 ~ /GPGGA/) { print $0 }'
awk 'BEGIN { RS = "/" } ; { if ($1 ~ /$GPGGA/) print $1 }'

awk '$1 ~ /$GPGGA/ { print $0 }'
awk 'BEGIN { RS = "/" } ;{ $1 ~ /GPGGA/ { print $0 }}'

gawk -F "," '$1=="$SDDBT" && $4 !="" { print $4}' NMEAfile >output

awk '-F,>ouput '/GPGGA/ {
_ = $(NF-2) s $2 s substr($4, 1, 2) s substr($4, 3) s $6
}
/SDDBT/ && $2 { print _, $4 }
' s=" "'

awk -F,>ouput '/GPGGA/ {
_ = $(NF-2) s $2 s substr($4, 1, 2) s substr($4, 3) s $6
}
/GPGGA/ && $2 { print _, $4 }

The issue is how to store data fields from a number of processed NMEA
records for postprocessing by another pipelined application.

One solution is getline var to read and process 2 records of
fields.

Another is getline var < file
awk '{
if (NF == 2 && $1 == "@include") {
while ((getline line < $2) > 0)
print line
close($2)
} else
print

command | getline

example
awk '{
if ($1 == "@execute") {
tmp = substr($0, 10)
while ((tmp | getline) > 0)
print
close(tmp)
} else
print
}'

}'

' s=" "
---------

command | getline var===
the examples come from excellent awk on-line manual.
----cs.utah.edu/dept/old/texinfo/gawk/gawk_22.html------

awk 'BEGIN {
"date" | getline current_time
close("date")
print "Report printed on " current_time
}'
Working with two dimensional array I can save a series of NMEA records for
postprocessing.
The issue is I have to process live data stream on-the-fly.

Is awk fit for a live data stream processing .
Gps tick is 1 sec.

Darius
Darius
# 9  
Old 01-02-2009
Darius,

Which NMEA keywords are you interested in, what data do you want to extract and what format.

If you give the sentence keywords, what you want the output to look like it would be pretty trivial to get you started along the right path.
# 10  
Old 01-02-2009
Quote:
Originally Posted by reborg
Darius,

Which NMEA keywords are you interested in, what data do you want to extract and what format.

If you give the sentence keywords, what you want the output to look like it would be pretty trivial to get you started along the right path.
Thanks.
I need any data I can build routes, tracks, POI, waypoints, lead and so on.
So long, lat, time, speed, lead ..
Moe ideas to come soon.

Just reading NMEA manual.
Ok.
Today I can try to read senteces, filter them and filter fields in records.
To build tracks, routes I can print data to output or send to a file >

Replacing one data stream by another data stream based on filtering rules.

Frankly speaking I am looking for basic gps application to read such filtered data stream on-the-fly updating (refresh) a map...

First step is to write dialog script as a viewer of gps data.
Don't know if I can pipe awk | dialog script data refresh

Darius
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

(g)awk: Matching strings from one file in another file between two strings

Hello all, I can get close to what I am looking for but cannot seem to hit it exactly and was wondering if I could get your help. I have the following sample from textfile with many thousands of lines: File 1 PS001,001 HLK PS002,004 L<G PS004,002 XNN PS004,006 BVX PS004,006 ZBX=... (7 Replies)
Discussion started by: jvoot
7 Replies

2. UNIX for Beginners Questions & Answers

Use strings from nth field from one file to match strings in entire line in another file, awk

I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file. I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies

3. Shell Programming and Scripting

Using awk to replace strings

Hi.. I have a file that has the following content : abc 213 24 213 pqr 456#34 678 xyz 213 45%213 i need to write an awk script that will replace the second 213 in all the lines, if it is present. The IFS can not be specified and can be random. The number of lines in the file and the... (5 Replies)
Discussion started by: Hermione Grange
5 Replies

4. Shell Programming and Scripting

awk Splitting strings

Hi All, There is a file with a data. If the line is longer than 'n', we splitting the line on the parts and print them. Each of the parts is less than or equal 'n'. For example: n = 2; "ABCDEFGHIJK" -> length 11 Results: "AB" "CD" EF" GH" "IJ" "K" Code, but there are some errors.... (9 Replies)
Discussion started by: booyaka
9 Replies

5. Shell Programming and Scripting

awk to get text between 2 strings

Hi, I am trying different scenarios now, 1 of those is getting the text between the following 2 strings. Type of msg: -in_full >date >alr text >ID_on_exit AWXX-Ready to commit (98) msg type: (10) I need to get all the occurrences having the same start line and end line.... (6 Replies)
Discussion started by: ocramas
6 Replies

6. Shell Programming and Scripting

Grabbing strings with awk

Hello everyone, I am doing some sort of analysis for some data about organic solvents, and I have a problem with writing a command to do this: Here's a sample of my file: 1 ethanol 2 methanol 3 methanol/ethanol 4 ethanol/methanol 5 ethanol/DMF 6 ethyl... (6 Replies)
Discussion started by: Error404
6 Replies

7. Shell Programming and Scripting

Using Awk to Search Two Strings on One Line

If i wanted to search for two strings that are on lines in the log, how do I do it? The following code searches for just one string that is one one line. awk '/^/ {split($2,s,",");a=$1 FS s} /failure agaf@fafa/ {b=a} END{print b}' urfile What if I wanted to search for "failure agaf@fafa"... (3 Replies)
Discussion started by: SkySmart
3 Replies

8. Shell Programming and Scripting

gpsd, gpspipe NMEA sentences stream processing

Hi, running gpsd, gpspipe I get a stream of NMEA sentences. What I need is to write awk script for pipelining and on-the-fly processing of the streamed NMEA senteces to output (terminal session in my case). The issue is, I can get gpsd working in -D 5 mode (debug mode). There is no issue... (5 Replies)
Discussion started by: darius2
5 Replies

9. Shell Programming and Scripting

How to print only lines in between two strings using awk

Hi, I want to print only lines in between two strings and not the strings using awk. Eg: OUTPUT top 2 bottom 1 left 0 right 0 page 66 END I want to print into a new file only top 2 bottom 1 left 0... (4 Replies)
Discussion started by: jisha
4 Replies
Login or Register to Ask a Question