From 27a6338585de45fabbbe07aa4eb3e2a8dc015d72 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sun, 20 Nov 2016 02:20:05 +0100 Subject: [PATCH] Fixed sniffer crashing on timeout --- README.md | 2 +- software/testutils/sniff.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1733c1c..ac5d5bf 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Initial value: 0x0 - Incoming messages are stored in a fifo until the application retrieves them. - The receive fifo has a size of at least 2 messages. - If the fifo is full new messages will override the older ones. - It is up to the application retrieve message in time. + It is up to the application to retrieve message in time. - Even if sending was successful, there is still a chance that the receiver could not receive the frame due to missing buffer space or not enough processing time to react. **Important messages should utilize a ack-mechanism.** diff --git a/software/testutils/sniff.py b/software/testutils/sniff.py index 1a368dc..3fe2b82 100644 --- a/software/testutils/sniff.py +++ b/software/testutils/sniff.py @@ -21,11 +21,15 @@ def main(): ser = serial.Serial(sys.argv[1], 9600, timeout=0.40) + data = "" while True: - data = ser.read(19) - if data != "" and len(data) != 19: + while data == "": + data = ser.read(19) + + if len(data) != 19: print "No Frame:\t" + hexdump(data) + header_ok = data.startswith(chr(0xAA) + chr(0xFE)) line = "" @@ -43,7 +47,7 @@ def main(): else: line += "CRC not Ok " - line += hexdump(data) + line += hexdump(payload) print line