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[:]
(ok, ) = qusb.EraseEpcs(0, 0, progress, None) if (not ok): print "***EraseEpcs() failed with error: ", str( Error(qusb.LastError())) else: print "EraseEpcs OK" else: print "***Cannot test ConfigureEpcs(): No EPCS device found" print "***Cannot test VerifyEpcs(): No EPCS device found" print "***Cannot test EraseEpcs(): No EPCS device found" if "data" in test: # Test ReadData length = 1024 c_data = CreateByteBuffer(length) (ok, bytesRead) = qusb.ReadData(c_data, length) if (not ok): print "***ReadData() failed with error: ", str(Error(qusb.LastError())) else: print "ReadData OK" # Test ReadDataEx length = 1024 c_data = CreateByteBuffer(length) (ok, bytesRead) = qusb.ReadDataEx(c_data, length, DataFlags.OutOfOrder) if (not ok): print "***ReadDataEx() failed with error: ", str( Error(qusb.LastError())) else: print "ReadDataEx OK"