From 083bf60be5666376ee9e8db23725ba2c8b9a0b5d Mon Sep 17 00:00:00 2001 From: Zilog80 Date: Sat, 5 Nov 2016 10:35:41 +0100 Subject: [PATCH] rs92,rs41,imet1ab,dfm,m10: output -> nmea, viking-gpsd --- rs92/pos2nmea.pl | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/rs92/pos2nmea.pl b/rs92/pos2nmea.pl index 0975d37..abbb746 100755 --- a/rs92/pos2nmea.pl +++ b/rs92/pos2nmea.pl @@ -3,7 +3,21 @@ use strict; use warnings; -my $filename = $ARGV[0]; +my $filename = undef; +my $date = undef; + +while (@ARGV) { + if ($ARGV[0] eq "--date") { + shift @ARGV; + if (defined $ARGV[0]) { + $date = shift @ARGV; + } + } + else { + $filename = shift @ARGV; + } +} + my $fpi; if (defined $filename) { @@ -13,7 +27,6 @@ else { $fpi = *STDIN; } - my $fpo = *STDOUT; @@ -25,10 +38,18 @@ my $NS; my $EW; my $cs; my $str; -my $date = 271016; ## (d)dmmyy ohne fuehrende 0 (wenn log kein Datum enthaelt) my $speed = 0.00; my $course = 0.00; +if (defined $date && $date =~ /(\d?\d\d\d\d\d)/) { + $date = $1; +} +else { + $date = 21116; ## (d)dmmyy ohne fuehrende 0 (wenn pos-log kein Datum enthaelt) +} + +my $geoid = 50.0; ## GPS ueber Ellipsoid; Geoid-Hoehe in Europa ca 40-50m + while ($line = <$fpi>) { if ($line =~ /(\d\d):(\d\d):(\d\d\.?\d?\d?\d?).*\ +lat:\ *(-?\d*)(\.\d*)\ +lon:\ *(-?\d*)(\.\d*)\ +alt:\ *(-?\d*\.\d*).*/) { @@ -52,13 +73,12 @@ print STDERR $line; $course = $2; } - $str = sprintf ("GPRMC,%010.3f,A,%08.3f,$NS,%09.3f,$EW,%.2f,%.2f,%06d,,", $hms, $lat, $lon, $speed, $course, $date); + $str = sprintf("GPRMC,%010.3f,A,%08.3f,$NS,%09.3f,$EW,%.2f,%.2f,%06d,,", $hms, $lat, $lon, $speed, $course, $date); $cs = 0; $cs ^= $_ for unpack 'C*', $str; printf $fpo "\$$str*%02X\n", $cs; - ## GPS ueber Ellipsoid; Geoid-Hoehe nicht beruecksichtigt - $str = sprintf ("GPGGA,%010.3f,%08.3f,$NS,%09.3f,$EW,1,04,0.0,%.3f,M,0.0,M,,", $hms, $lat, $lon, $alt); + $str = sprintf("GPGGA,%010.3f,%08.3f,$NS,%09.3f,$EW,1,04,0.0,%.3f,M,%.1f,M,,", $hms, $lat, $lon, $alt-$geoid, $geoid); $cs = 0; $cs ^= $_ for unpack 'C*', $str; printf $fpo "\$$str*%02X\n", $cs; @@ -70,13 +90,14 @@ close $fpi; close $fpo; -############################################################################################################################################# +############################################################################################################################# ## ## term-1$ socat -d -d pty,raw,echo=0 pty,raw,b4800,echo=0 #[default baudrate 38400] ## N PTY is /dev/pts/12 ## N PTY is /dev/pts/15 ## -## term-2$ sox -t oss /dev/dsp -t wav - lowpass 3600 2>/dev/null | ./rs92ecc --ecc --crc --vel2 -e brdc3010.16n | ./pos2nmea.pl > /dev/pts/12 +## term-2$ sox -t oss /dev/dsp -t wav - lowpass 3600 2>/dev/null | ./rs92ecc --ecc --crc --vel2 -e brdc3010.16n | \ +## ./pos2nmea.pl --date 31116 > /dev/pts/12 ## ## term-3$ gpsd -D2 -b -n -N /dev/pts/15 ## @@ -84,5 +105,6 @@ close $fpo; ## ## Viking: GPS-layer, Realtime Tracking Mode, gpsd-port: 2947 ## -############################################################################################################################################# +############################################################################################################################# +