Last active
November 6, 2017 07:26
-
-
Save jpenalbae/15cdfdf5eefa7e7cbc8afba9b7aa89b1 to your computer and use it in GitHub Desktop.
Programmer for blackice
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/python | |
import sys | |
import serial | |
def send_data(devname, filename): | |
wrote = 0 | |
try: | |
port = serial.Serial(devname) | |
bstream = open(filename, 'r') | |
while True: | |
data = bstream.read(1024) | |
if data == '': | |
break | |
wrote += port.write(data) | |
except Exception as e: | |
print 'Error uploading bitstream' | |
print e | |
sys.exit(1) | |
print 'Wrote %d bytes' % wrote | |
if len(sys.argv) != 3: | |
print 'Usage: %s serial_device bitstream_file' % sys.argv[0] | |
sys.exit(1) | |
send_data(sys.argv[1], sys.argv[2]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment