Rename hostside script to pipeout.py
It will write exactly the received characters to stdout.
This commit is contained in:
parent
1b839d2388
commit
6611eb2c8f
|
@ -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)
|
|
@ -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)
|
|
Loading…
Reference in New Issue