From 081d81f5e568bd8439c53ee4544521448f534f5a Mon Sep 17 00:00:00 2001 From: SammysHP Date: Fri, 23 Apr 2021 16:22:07 +0200 Subject: [PATCH] pos2nmea: Enforce line buffering When connected to stdout, perl uses line buffering. If not connected to stdout (e.g. from a pipe) it defaults to block buffering. This causes a long delay and decoding issues when using the NMEA output in other tools. With this change always use line buffering so that NMEA messages are flushed immediately. Tested with NMEAoIP and GPSD: | pos2nmea.pl | socat - tcp-l:4444,reuseaddr,fork | pos2nmea.pl | gpsd -Nnrb /dev/stdin --- tools/pos2nmea.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/pos2nmea.pl b/tools/pos2nmea.pl index 96dcc09..37ecedf 100755 --- a/tools/pos2nmea.pl +++ b/tools/pos2nmea.pl @@ -51,6 +51,8 @@ else { my $geoid = 50.0; ## GPS ueber Ellipsoid; Geoid-Hoehe in Europa ca 40-50m +$| = 1; ## line buffering erzwingen + while ($line = <$fpi>) { print STDERR $line; ## entweder: alle Zeilen ausgeben