Last active
          November 6, 2017 07:26 
        
      - 
      
 - 
        
Save jpenalbae/15cdfdf5eefa7e7cbc8afba9b7aa89b1 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
jpenalbae revised this gist
Nov 6, 2017 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,7 @@ def send_data(devname, filename): data = bstream.read(1024) if data == '': break wrote += port.write(data) except Exception as e: print 'Error uploading bitstream'  - 
        
jpenalbae revised this gist
Nov 6, 2017 . 1 changed file with 3 additions and 24 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,40 +1,19 @@ #!/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 port.write(data) wrote += len(data)  - 
        
jpenalbae revised this gist
Nov 6, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -52,3 +52,4 @@ def send_data(devname, filename): sys.exit(1) send_data(sys.argv[1], sys.argv[2])  - 
        
jpenalbae created this gist
Nov 6, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ #!/usr/bin/python import sys import platform def set_rawmode(port): import termios orig_attr = termios.tcgetattr(port) iflag, oflag, cflag, lflag, ispeed, ospeed, cc = orig_attr cflag |= (termios.CLOCAL | termios.CREAD) lflag &= ~(termios.ICANON | termios.ECHO | termios.ECHOE | termios.ECHOK | termios.ECHONL | termios.ISIG | termios.IEXTEN) # |termios.ECHOPRT oflag &= ~(termios.OPOST | termios.ONLCR | termios.OCRNL) iflag &= ~(termios.INLCR | termios.IGNCR | termios.ICRNL | termios.IGNBRK) termios.tcsetattr( port, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]) def send_data(devname, filename): wrote = 0 try: port = open(devname, 'w') bstream = open(filename, 'r') if platform.system() != "Windows": set_rawmode(port) while True: data = bstream.read(1024) if data == '' or len(data) == 0: break port.write(data) wrote += len(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])