Created
June 17, 2020 04:48
-
-
Save akarpenko/f6ab909c0497679d86b9c33502347895 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import serial | |
import sys | |
from xmodem import XMODEM | |
# Setup: | |
# pip install pyserial | |
# pip install xmodem | |
ser = serial.Serial('/dev/ttyUSB0', timeout=0) # or whatever port you need | |
def getc(size, timeout=1): | |
return ser.read(size) or None | |
def putc(data, timeout=1): | |
return ser.write(data) # note that this ignores the timeout | |
modem = XMODEM(getc, putc) | |
with open(sys.argv[1], "rb") as f: | |
modem.send(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment