Created
October 27, 2024 12:40
-
-
Save iomonad/d16aeae13a23f3aae333bf1cfd9802c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment