Hi all:
I have a file with NMEA sentences of the type:
$GPVTG,012.0,T,,M,00.0,N,,K*7D
$GPRMC,180541,A,3631.874,N,00617.423,W,00.0,004.0,210608,,*36
$SDDBT,,f,,M,,F*28
$GPGLL,3631.874,N,00617.423,W,180542,A*3B
$GPVTG,009.0,T,,M,00.0,N,,K*77
$GPVTG,019.0,T,,M,00.0,N,,K*76
$GPRMC,180546,A,3631.874,N,00617.423,W,00.0,019.0,210608,,*3D
$SDDBT,,f,,M,,F*28
$GPGLL,3631.874,N,00617.423,W,180548,A*31
$GPVTG,012.0,T,,M,00.0,N,,K*7D
$GPRMC,180551,A,3631.874,N,00617.423,W,00.0,004.0,210608,,*37
$GPVTG,004.0,T,,M,00.0,N,,K*7A
$SDDBT,,f,,M,,F*28
$GPGLL,3631.874,N,00617.423,W,180554,A*3C
$GPVTG,009.0,T,,M,00.0,N,,K*77
$GPRMC,180556,A,3631.874,N,00617.423,W,00.0,017.0,210608,,*32
$SDDBT,000016,f,00005,M,0002.7,F*01
$GPVTG,017.0,T,,M,00.0,N,,K*78
$GPGLL,3631.874,N,00617.423,W,180600,A*3E
$GPVTG,038.0,T,,M,00.0,N,,K*75
$GPRMC,180601,A,3631.874,N,00617.423,W,00.0,038.0,210608,,*3E
$SDDBT,000016,f,00005,M,0002.7,F*01
$GPRMC for position and time, $SDDBT for depth. All sentences are sequential in time.
I can extract position and time with awk, no problem:
gawk -F "," '$1=="$GPRMC" && $3 != "V" { print 20substr($10,5,2),substr($10,3,2),substr($10,1,2),substr($2,1,2),substr($2,3,2),substr($2,5,2),substr($6,1,3),substr($6,4),substr($4,1,2),substr($4,3)}' NMEAfile >output
and depth:
gawk -F "," '$1=="$SDDBT" && $4 !="" { print $4}' NMEAfile >output
I would like to combine position, time and depth into one single file, only if depth is true (note that sometimes $SDDBT,,f,,M,,F*28 -no depth info-). That is, if depth is true then use the position from the previous occurrence of $GPRMC and combine them into a single line. Sure that's possible with awk/gawk, but don't know how to do it.
Thanks in advance,
r.-
