import serial BUSPIRATE_PORT = '/dev/ttyUSB0' SETUP_SEQUENCE = [ # '#', # reset bus pirate (slow, maybe not needed) 'm', # change mode (goal is to get away from HiZ) '3', # UART MODE '9', # Port Speed 115200 '1', # Parity (NO) '1', # Stop Bit 1 '1', # Receive Polarity 1 '1', # Normal Output 'W', # turn power supply to OFF. ] WAKEUP_SEQUENCE = [ '0xFF 0xFF 0xFC 0x03 0xFF 0x1C 0xFC 0xFF 0x00 0x1C 0x80 0x7C 0x80 0x00 0x7C 0xFC' ] def send(ser,cmd): """send the command and listen to the response.""" ser.write(str(cmd+'\n').encode('ascii')) for line in ser.readlines(): print(line.decode('utf-8').strip()) ser=serial.Serial(BUSPIRATE_PORT, 115200, timeout=.1) assert ser.isOpen() for x in SETUP_SEQUENCE: send(ser, x) for y in WAKEUP_SEQUENCE: send(ser, y)