diff options
author | Fred Wright <fw@fwright.net> | 2017-07-20 15:00:34 -0700 |
---|---|---|
committer | Fred Wright <fw@fwright.net> | 2017-07-20 15:30:46 -0700 |
commit | 00c4d620859603a9bab4001f6c69fc213c73625d (patch) | |
tree | cf5abb04c021360bb92bf363d1c08265e833b7ea /gpscat | |
parent | 41d6fa9fb4e4665b4afbbd851eee188d596084ea (diff) | |
download | gpsd-00c4d620859603a9bab4001f6c69fc213c73625d.tar.gz |
Fixes gpscat raw-mode file-input termination.
When reading from a file in packetizer mode, gpscat correctly
terminates at EOF. However, in raw mode it simply hung in a loop
retrying the read. This change makes it exit on EOF.
This change also removes the useless buffer append logic in raw mode,
which was a leftover from the old code that attempted to break on
newlines (removed by commit e4cbd2daf).
TESTED:
Ran gpscat in raw mode on all test/daemon log files, and observed
proper termination. Tested with Python 2.7 and Python 3.5.
Diffstat (limited to 'gpscat')
-rwxr-xr-x | gpscat | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -53,7 +53,6 @@ def printusage(): "serial-port\n") if __name__ == '__main__': - buf = bytes() try: try: (options, arguments) = getopt.getopt(sys.argv[1:], "hps:tD:V") @@ -122,7 +121,6 @@ if __name__ == '__main__': termios.tcsetattr(tty, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]) - buf = bytes() if not rawmode: getter = sniffer.new() sniffer.register_report(reporter) @@ -131,9 +129,10 @@ if __name__ == '__main__': rlist, wlist, xlist = select.select([tty], [], []) if rlist == [tty]: if rawmode: - buf += os.read(tty, NMEA_MAX) + buf = os.read(tty, NMEA_MAX) + if not buf: + break sys.stdout.write(hexdump(buf)) - buf = bytes() else: (length, ptype, packet, counter) = getter.get(tty) seqno += 1 |