Added test util for sending frames

Adjusted timeouts for slow uarts
This commit is contained in:
Sebastian 2016-10-30 00:12:55 +02:00
parent 1cc7f90595
commit 090cb3a201
3 changed files with 44 additions and 2 deletions

View File

@ -77,7 +77,7 @@ Initial value: 0x0
unless it is currently receiving a frame.
- Collision detection on the sender side is done by reading back each sent byte.
- Collision checking on receiver side, is done by checking the CRC and frame header.
- If a frame has been started and there are no new bytes received for 20ms,
- If a frame has been started and there are no new bytes received for 50ms,
the frame is considered timed out and all received data can be dropped.
- Incoming messages are stored in a fifo until the application retrieves them.
- The receive fifo has a size of at least 2 messages.

View File

@ -0,0 +1,42 @@
#!/usr/bin/env python2
import sys
import serial
import crcmod.predefined
def send_byte(ser, byte):
ser.reset_input_buffer()
ser.write(byte)
read_byte = ser.read()
if read_byte != byte:
print "Written %s read %s" % (hex(ord(read_byte)), hex(ord(byte)))
sys.exit(-1)
def main():
if len(sys.argv) != 3:
print "Usage %s <port> <payload>" % (sys.argv[0])
sys.exit(-1)
payload = sys.argv[2]
payload += chr(0) * (16 - len(payload))
ser = serial.Serial(sys.argv[1], 9600, timeout=0.40)
crc = crcmod.predefined.Crc('crc-8-maxim')
send_byte(ser, chr(0xAA))
send_byte(ser, chr(0xFE))
for byte in payload:
crc.update(byte)
send_byte(ser, byte)
crc_sum = crc.digest()
send_byte(ser, crc_sum)
print "Send sucessfully !"
if __name__ == '__main__':
main()

View File

@ -15,7 +15,7 @@ def hexdump(data):
def main():
if len(sys.argv) < 2:
if len(sys.argv) != 2:
print "Usage %s <port>" % (sys.argv[0])
sys.exit(-1)