Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #35 from miri64/sniffer/fix/script-decode
Browse files Browse the repository at this point in the history
sniffer: script: ignore non-ASCII characters on input
  • Loading branch information
miri64 committed Jul 14, 2018
2 parents 00d6473 + edb9337 commit ffe954a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sniffer/tools/sniffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def configure_interface(port, channel):
print("Application has no network interface defined",
file=sys.stderr)
sys.exit(2)
match = re.search(r'^Iface +(\d+)', line.decode())
match = re.search(r'^Iface +(\d+)', line.decode(errors="ignore"))
if match is not None:
iface = int(match.group(1))
break
Expand All @@ -86,7 +86,7 @@ def generate_pcap(port, out):
line = port.readline().rstrip()

pkt_header = re.match(r">? *rftest-rx --- len 0x(\w\w).*",
line.decode())
line.decode(errors="ignore"))
if pkt_header:
now = time()
sec = int(now)
Expand All @@ -98,9 +98,9 @@ def generate_pcap(port, out):
sys.stderr.write("RX: %i\r" % count)
continue

pkt_data = re.match(r"(0x\w\w )+", line.decode())
pkt_data = re.match(r"(0x\w\w )+", line.decode(errors="ignore"))
if pkt_data:
for part in line.decode().split(' '):
for part in line.decode(errors="ignore").split(' '):
byte = re.match(r"0x(\w\w)", part)
if byte:
out.write(pack('<B', int(byte.group(1), 16)))
Expand Down

0 comments on commit ffe954a

Please sign in to comment.