def __init__(self, devnum = 0, timeout = 0, baud = B57600, crtscts = False, format_strings = None): super(usb, self).__init__() if baud is None: self.fd = comm.open(devnum, timeout, crtscts=crtscts) else: self.fd = comm.open(devnum, timeout, baud = baud, crtscts=crtscts) self.name = "usb%d" % devnum self.format_strings = format_strings
def run(devnum = 0): global Arduino fd = comm.open(devnum=devnum, baud=comm.B500000) with contextlib.closing(os.fdopen(fd, "r+b", 1)) as Arduino: try: while True: line = Arduino.readline().rstrip() print "start up line:", repr(line) if line == "READY": break print "Power up the chip and press ENTER." raw_input() enable_programming() read_configuration() while menu(): pass finally: power_off() print "Power off the chip and hit ENTER." raw_input()