Member
Registered: Jan 2004
Location: USA, Pa
Distribution: Gentoo, Fedora Core 3, Mepis, Vector
Posts: 83
Rep:
|
cat to grep to textfile?
Hi,
I am goofing around with a GPS unit a purchased the other day. I have it connected to the PC via a serial cable. It is using ttyS0. If I I see the repetitive output of serial data on the terminal:
Code:
$GPRMC,170014,V,4050.5741,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*27
$GPRMB,V,,,,,,,,,,,,A,S*0E
$GPGGA,170014,4050.5741,N,08022.1031,W,8,09,2.0,370.8,M,-33.6,M,,*7B
$GPGSA,A,3,01,06,07,14,16,20,23,25,30,,,,3.6,2.0,3.0*33
$GPGSV,3,1,09,01,63,114,49,06,20,065,41,07,22,133,42,14,17,125,40*7C
$GPGLL,4050.5741,N,08022.1031,W,170014,V,S*5E
$GPBOD,,T,,M,,*47
$GPVTG,0.0,T,9.0,M,17.4,N,32.2,K*46
$PGRME,15.0,M,22.5,M,27.0,M*1A
$PGRMZ,1216,f,3*2F
$PGRMM,WGS 84*06
$GPRTE,1,1,c,*37
$GPRMC,170016,V,4050.5837,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2B
$GPRMB,V,,,,,,,,,,,,A,S*0E
$GPGGA,170016,4050.5837,N,08022.1031,W,8,09,2.0,370.8,M,-33.6,M,,*77
$GPGSA,A,3,01,06,07,14,16,20,23,25,30,,,,3.6,2.0,3.0*33
$GPGSV,3,2,09,16
If I
Code:
"cat /dev/ttyS0 | grep GPRMC"
I see:
Code:
$GPRMC,165548,V,4049.2892,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*21
$GPRMC,165550,V,4049.2988,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*22
$GPRMC,165552,V,4049.3085,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*25
$GPRMC,165554,V,4049.3181,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*26
$GPRMC,165556,V,4049.3278,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*21
$GPRMC,165558,V,4049.3375,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*23
$GPRMC,165600,V,4049.3471,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2E
$GPRMC,165602,V,4049.3568,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*25
$GPRMC,165604,V,4049.3664,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2C
$GPRMC,165606,V,4049.3761,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2A
$GPRMC,165608,V,4049.3858,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*21
$GPRMC,165610,V,4049.3954,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*25
$GPRMC,165612,V,4049.4051,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2C
$GPRMC,165614,V,4049.4147,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2C
$GPRMC,165616,V,4049.4244,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2E
$GPRMC,165618,V,4049.4341,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*24
$GPRMC,165620,V,4049.4437,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*29
$GPRMC,165622,V,4049.4534,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*29
$GPRMC,165624,V,4049.4631,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*29
$GPRMC,165626,V,4049.4727,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2D
$GPRMC,165628,V,4049.4824,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2F
$GPRMC,165630,V,4049.4920,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*23
$GPRMC,165632,V,4049.5017,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*2D
$GPRMC,165634,V,4049.5114,N,08022.1031,W,17.4,0.0,030906,9.0,W,S*29
What I would like to do is get this data which flows continously into a file. If I do
Code:
"cat /dev/ttyS0 | grep GPRMC >> /home/allen/gps.txt"
it creates the file but enters nothing into it.
where if I
Code:
"cat /dev/ttyS0 >> /home/allen/gps.txt"
it continously updates the file with new info but more info than I want. Where am I going wrong?
thanks.
|