print "***GetLastError() failed with error: ", str( Error(QuickUsb.GetLastError())) 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 out the name of each module found for x in modules: print "Found", x # Open the first device qusb = QuickUsb(devName) qusb.Open() # Read the Command register at address 0 length = 2 command = CreateByteBuffer(length) address = 0 (result, bytes) = qusb.ReadCommand(address, command, length) if (result == 0): print "Cannot read %s command register" % (devName) qusb.Close() sys.exit() print "ReadCommand address %d = %04x %04x" % (address, command[0], command[1]) # Make all the pins outputs for now port = 0 dir = 0xFF (result, ) = qusb.WritePortDir(port, dir) if (result == 0): print "Cannot write %s port A direction register" % (devName) qusb.Close() sys.exit() # Loop through a pattern length = 2 data = CreateByteBuffer(length)