Fixed sniffer crashing on timeout
This commit is contained in:
parent
e53fbf06a6
commit
27a6338585
|
@ -82,7 +82,7 @@ Initial value: 0x0
|
||||||
- Incoming messages are stored in a fifo until the application retrieves them.
|
- Incoming messages are stored in a fifo until the application retrieves them.
|
||||||
- The receive fifo has a size of at least 2 messages.
|
- The receive fifo has a size of at least 2 messages.
|
||||||
- If the fifo is full new messages will override the older ones.
|
- 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
|
- 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.
|
receive the frame due to missing buffer space or not enough processing time to react.
|
||||||
**Important messages should utilize a ack-mechanism.**
|
**Important messages should utilize a ack-mechanism.**
|
||||||
|
|
|
@ -21,11 +21,15 @@ def main():
|
||||||
|
|
||||||
ser = serial.Serial(sys.argv[1], 9600, timeout=0.40)
|
ser = serial.Serial(sys.argv[1], 9600, timeout=0.40)
|
||||||
|
|
||||||
|
data = ""
|
||||||
while True:
|
while True:
|
||||||
data = ser.read(19)
|
while data == "":
|
||||||
if data != "" and len(data) != 19:
|
data = ser.read(19)
|
||||||
|
|
||||||
|
if len(data) != 19:
|
||||||
print "No Frame:\t" + hexdump(data)
|
print "No Frame:\t" + hexdump(data)
|
||||||
|
|
||||||
|
|
||||||
header_ok = data.startswith(chr(0xAA) + chr(0xFE))
|
header_ok = data.startswith(chr(0xAA) + chr(0xFE))
|
||||||
|
|
||||||
line = ""
|
line = ""
|
||||||
|
@ -43,7 +47,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
line += "CRC not Ok "
|
line += "CRC not Ok "
|
||||||
|
|
||||||
line += hexdump(data)
|
line += hexdump(payload)
|
||||||
print line
|
print line
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue