Fixed sniffer crashing on timeout

This commit is contained in:
Sebastian 2016-11-20 02:20:05 +01:00
parent e53fbf06a6
commit 27a6338585
2 changed files with 8 additions and 4 deletions

View File

@ -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.**

View File

@ -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