From 0d590e48bd9ab3be1254b381ccbbef9a649c49e5 Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Sat, 9 May 2015 09:02:17 +0200 Subject: [PATCH] dist/tools/sniffer: whitespace fixes --- dist/tools/sniffer/README.md | 1 - dist/tools/sniffer/rftestrx2pcap.py | 104 ++++++++++++++-------------- 2 files changed, 52 insertions(+), 53 deletions(-) diff --git a/dist/tools/sniffer/README.md b/dist/tools/sniffer/README.md index 31e197a186..2ab867c660 100644 --- a/dist/tools/sniffer/README.md +++ b/dist/tools/sniffer/README.md @@ -55,4 +55,3 @@ For windows you can use the optional third argument to output to a .pcap: $ ./rftestrx2pcap.py /dev/ttyUSB1 26 foo.pcap - diff --git a/dist/tools/sniffer/rftestrx2pcap.py b/dist/tools/sniffer/rftestrx2pcap.py index c43f2ea3af..55f5d3dd3e 100755 --- a/dist/tools/sniffer/rftestrx2pcap.py +++ b/dist/tools/sniffer/rftestrx2pcap.py @@ -33,41 +33,41 @@ import re import serial if len(sys.argv) < 3: - sys.stderr.write( "Usage: %s tty channel [outfile]\n" %(sys.argv[0])) - sys.stderr.write( " channel = 11-26\n") - sys.exit(2) + sys.stderr.write( "Usage: %s tty channel [outfile]\n" %(sys.argv[0])) + sys.stderr.write( " channel = 11-26\n") + sys.exit(2) # change the channel try: - serport = serial.Serial(sys.argv[1], baudrate=115200, dsrdtr=0, rtscts=0, timeout=1) - serport.setDTR(0) - serport.setRTS(0) + serport = serial.Serial(sys.argv[1], baudrate=115200, dsrdtr=0, rtscts=0, timeout=1) + serport.setDTR(0) + serport.setRTS(0) except IOError: - print "error opening port" - sys.exit(2) + print "error opening port" + sys.exit(2) time.sleep(1) chanstr = '' sys.stderr.write('chan %s\n' % sys.argv[2]) serport.write('chan %s\n' % sys.argv[2]) while 1: - c = serport.read(1) - if (c == '\n'): - chanstr = '' - continue - chanstr += c - m = re.match(".*channel: (\w+)", chanstr) - if m: - chan = int(m.group(1)) - sys.stderr.write(chanstr + '\n') - break + c = serport.read(1) + if (c == '\n'): + chanstr = '' + continue + chanstr += c + m = re.match(".*channel: (\w+)", chanstr) + if m: + chan = int(m.group(1)) + sys.stderr.write(chanstr + '\n') + break try: - sys.stderr.write('writing to file %s \n' % (sys.argv[3])) - outfile = open(sys.argv[3], 'w+b') + sys.stderr.write('writing to file %s \n' % (sys.argv[3])) + outfile = open(sys.argv[3], 'w+b') except IndexError: - outfile = sys.stdout + outfile = sys.stdout sys.stderr.write("RX: 0\r") @@ -88,39 +88,39 @@ fileempty = 1 newpacket = 0 try: - while 1: - line = serport.readline().rstrip() + while 1: + line = serport.readline().rstrip() - m_rftestline = re.match(".*rftest-rx --- len 0x(\w\w).*", line) + m_rftestline = re.match(".*rftest-rx --- len 0x(\w\w).*", line) - if m_rftestline: - newpacket = 1 - t = time.time() - sec = int(t) - usec = (t - sec) * 100000 - length = int(m_rftestline.group(1), 16) - continue - - # if this is a new packet, add a packet header - if newpacket == 1: - newpacket = 0 - outfile.write(pack('