#!/usr/bin/python import serial import sys from chirp import util s = serial.Serial(port=sys.argv[1], baudrate=9600) s.setTimeout(.25) # Return whatever we have read if wait is >1 sec #s.setParity("E") count = 0 while True: data = s.read(256) # Read up to 256 bytes if data: block_length = len(data) if block_length == 8: print "Header Received: %s\n" % (util.hexprint(data)) s.write("\x06") # Send ACK print "ACK sent" s.read(1) # Chew up that ACK, because the cables echo them else: print "Received %i bytes:\n%s" % (len(data), util.hexprint(data)) s.write("\x06") # Send ACK print "ACK sent" s.read(1) # Chew up that ACK, because the cables echo them count += 1 print "Block Count: %i\n\n" % (count) else: # No data print "Received nothing..."