summaryrefslogtreecommitdiff
path: root/gpscat
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2017-07-20 15:00:34 -0700
committerFred Wright <fw@fwright.net>2017-07-20 15:30:46 -0700
commit00c4d620859603a9bab4001f6c69fc213c73625d (patch)
treecf5abb04c021360bb92bf363d1c08265e833b7ea /gpscat
parent41d6fa9fb4e4665b4afbbd851eee188d596084ea (diff)
downloadgpsd-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-xgpscat7
1 files changed, 3 insertions, 4 deletions
diff --git a/gpscat b/gpscat
index 97a8a74f..f100c495 100755
--- a/gpscat
+++ b/gpscat
@@ -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