Beispiel #1
0
            Error(qusb.LastError()))
    else:
        print "IsFpgaConfigured OK"

    # Test FpgaConfigure
    (ok, ) = qusb.ConfigureFpga("fpga.rbf")
    if (not ok):
        print "***FpgaConfigure() failed with error: ", str(
            Error(qusb.LastError()))
    else:
        print "FpgaConfigure OK"

if "command" in test:
    # Test ReadCommand
    c_data = CreateByteBuffer(64)
    (ok, data) = qusb.ReadCommand(0, c_data, 64)
    if (not ok):
        print "***ReadCommand() failed with error: ", str(
            Error(qusb.LastError()))
    else:
        print "ReadCommand OK"

    # Test WriteCommand
    c_data = CreateByteBuffer(64)
    (ok, ) = qusb.WriteCommand(0, c_data, 64)
    if (not ok):
        print "***WriteCommand() failed with error: ", str(
            Error(qusb.LastError()))
    else:
        print "WriteCommand OK"
Beispiel #2
0
# Just use the first device in the list because it's easy
devName = modules[0]

# 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()