Beispiel #1
0
    test = sys.argv[1:]

if "base" in test:
    # Test FindModules
    (ok, nameList) = QuickUsb.FindModules()
    if (not ok):
        print "***FindModules() failed with error: ", str(
            Error(QuickUsb.GetLastError()))
        sys.exit(1)
    else:
        print "FindModules OK"

    qusb = QuickUsb(nameList[0])

    # Test Open
    (ok, ) = qusb.Open()
    if (not ok):
        print "***Open() failed with error: ", str(
            Error(QuickUsb.GetLastError()))
    else:
        print "Open OK"

    # Test GetLastError
    if (QuickUsb.GetLastError()):
        print "***GetLastError() failed with error: ", str(
            Error(QuickUsb.GetLastError()))
    else:
        print "GetLastError OK"

    qusb = QuickUsb(nameList[0])
Beispiel #2
0
# Check for no modules and bail if we don't find any
if len == 0:
    print "Couldn't find any modules\n"
    sys.exit()

# 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