else: print "GetLastError OK" qusb = QuickUsb(nameList[0]) # Test GetLastDriverError if (QuickUsb.GetLastDriverError()): print "***GetLastDriverError() failed with error: ", str( Error(QuickUsb.GetLastDriverError())) else: print "GetLastDriverError OK" # Test Close (ok, ) = qusb.Close() if (not ok): print "***Close() failed with error: ", str(Error(qusb.LastError())) else: print "Close OK" # Test OpenEx (ok, ) = qusb.OpenEx(nameList[0], 0) if (not ok): print "***OpenEx() failed with error: ", str(Error(qusb.LastError())) else: print "OpenEx OK" # Test GetStringDescriptor (ok, string) = qusb.GetStringDescriptor(0) if (not ok): print "***GetStringDescriptor() failed with error: ", str( Error(qusb.LastError()))
import sys import time from QuickUsb import * LEN = int(sys.argv[1]) (ok, qusbList) = QuickUsb.FindModules() if len(qusbList) == 0: print "Cannot find any modules" qusb = QuickUsb(qusbList[0]) print qusb.Name, qusb.Serial #qusb.SetTimeout(10000) arr = CreateByteBuffer(LEN) stime = time.time() (ok, bytes) = qusb.ReadData(arr, LEN) etime = time.time() print(ok, bytes) if not ok: print "Read failed: ", qusb.LastError() else: print "Data Rate: ", (bytes / (1024.0 * 1024.0)) / (etime - stime), "MB/s" if len(sys.argv) > 2 and sys.argv[2] == "show": print arr[:]
import time from QuickUsb import * LEN = int(sys.argv[1]) (ok, qusbList) = QuickUsb.FindModules() if len(qusbList) == 0: print "Cannot find any modules" qusb = QuickUsb(qusbList[0]) print qusb.Name, qusb.Serial #qusb.SetTimeout(10000) arr = CreateByteBuffer(LEN) for k in xrange(LEN): arr[k] = k stime = time.time() (ok, ) = qusb.WriteData(arr, LEN) etime = time.time() print(ok, bytes) if not ok: print "Write failed: ", qusb.LastError() else: print "Data Rate: ", (LEN / (1024.0 * 1024.0)) / (etime - stime), "MB/s" if len(sys.argv) > 2 and sys.argv[2] == "show": print arr[:]