diff --git a/host/pipeout.py b/host/pipeout.py new file mode 100755 index 0000000..c8a3e8b --- /dev/null +++ b/host/pipeout.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import usb +import time +import sys + +def getHandle(): + asp = None + busses = usb.busses() + for bus in busses: + devices = bus.devices + for dev in devices: + if dev.idVendor == 0x16c0 and dev.idProduct==0x05dc: + asp = dev #.open() + if asp is None: + return None + return asp.open() + +def enableSerialMode(USBaspHandle): + USBaspHandle.controlMsg(128|32, 32, 8) + +def disableSerialMode(USBaspHandle): + USBaspHandle.controlMsg(128|32, 34, 8) + +def getData(USBaspHandle): + return USBaspHandle.controlMsg(128|32, 33, 8) + +handle = getHandle() +if handle is None: + sys.stderr.write("USBASP not found!\n") + exit(1); + +try: + enableSerialMode(handle) + while True: + data = getData(handle) + time.sleep(0.01) + if len(data): + for char in data: + sys.stdout.write(chr(char)) + sys.stdout.flush() + +except KeyboardInterrupt: + disableSerialMode(handle) diff --git a/host/testcommunication.py b/host/testcommunication.py deleted file mode 100644 index 61bc09e..0000000 --- a/host/testcommunication.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python - -import usb -import time - -asp = None -busses = usb.busses() -for bus in busses: - devices = bus.devices - for dev in devices: - #print "Device:", dev.filename - #print " idVendor: %d (0x%04x)" % (dev.idVendor, dev.idVendor) - #print " idProduct: %d (0x%04x)" % (dev.idProduct, dev.idProduct) - if dev.idVendor == 0x16c0 and dev.idProduct==0x05dc: - asp = dev #.open() - -if asp is None: - print "USBASP not found!" - exit(1) - -handle = asp.open() - -def enableSerialMode(USBaspHandle): - USBaspHandle.controlMsg(128|32, 32, 8) - -def disableSerialMode(USBaspHandle): - USBaspHandle.controlMsg(128|32, 34, 8) - -def getData(USBaspHandle): - return USBaspHandle.controlMsg(128|32, 33, 8) - -try: - enableSerialMode(handle) - while True: - data = getData(handle) - time.sleep(0.01) - if len(data): - print data - -except KeyboardInterrupt: - disableSerialMode(handle)