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:

<decoder> | pos2nmea.pl | socat - tcp-l:4444,reuseaddr,fork
<decoder> | pos2nmea.pl | gpsd -Nnrb /dev/stdin
pull/37/head
SammysHP 2021-04-23 16:22:07 +02:00
rodzic 3ca76b02bb
commit 081d81f5e5
1 zmienionych plików z 2 dodań i 0 usunięć

Wyświetl plik

@ -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