Exemplo n.º 1
0
        print "***GetFirmwareVersion() failed with error: ", str(
            Error(qusb.LastError()))
    else:
        print "GetFirmwareVersion OK"

    # Test ReadPortDir
    (ok, byte) = qusb.ReadPortDir(Port.A)
    if (not ok):
        print "***ReadPortDir() failed with error: ", str(
            Error(qusb.LastError()))
    else:
        print "ReadPortDir OK"
    byte |= 0x80

    # Test WritePortDir
    (ok, ) = qusb.WritePortDir(Port.A, byte)
    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
Exemplo n.º 2
0
# 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)
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)