if (not ok): print "***WritePortDir() failed with error: ", str( Error(qusb.LastError())) else: print "WritePortDir OK" # Test ReadPort c_data = CreateByteBuffer(1) (ok, value) = qusb.ReadPort(Port.A, c_data, 1) if (not ok): print "***ReadPort() failed with error: ", str(Error(qusb.LastError())) else: print "ReadPort OK" # Test WritePort (ok, ) = qusb.WritePort(Port.A, byte, 1) if (not ok): print "***WritePort() failed with error: ", str(Error( qusb.LastError())) else: print "WritePort OK" # Test ReadSetting (ok, value) = qusb.ReadSetting(Setting.PortA) if (not ok): print "***ReadSetting() failed with error: ", str( Error(qusb.LastError())) else: print "ReadSetting OK" value |= 0x80
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) port = 0 print "Writing 128 cycles of 0xAAAA, 0x5555 to %s, port A..." % (devName) for count in xrange(128): data = 0xAAAA (result, ) = qusb.WritePort(port, data, length) if (result == 0): print "Cannot write %s port A data" % (devName) qusb.Close() sys.exit() data = 0x5555 (result, ) = qusb.WritePort(port, data, length) if (result == 0): print "Cannot write %s port A data" % (devName) qusb.Close() sys.exit() # Write a 4k block of data length = 4096 bulkdata = CreateByteBuffer(length)