Example #1
0
def WaitForDeviceReenumeration():

    # should be called when setChipConfiguration, cycleDevicePort or resetDevicePort is called
    # todo: get optimal sleep times
    origValue = ftd3xx.raiseExceptionOnError(False)
    time.sleep(1)
    while (ftd3xx.listDevices() == None):
        time.sleep(1)
    time.sleep(1)
    ftd3xx.raiseExceptionOnError(origValue)
def DemoWaitForDeviceReenumeration():

    # should be called when setChipConfiguration, cycleDevicePort or resetDevicePort is called
    # todo: get optimal sleep times
    origValue = ftd3xx.raiseExceptionOnError(False)
    time.sleep(1)
    while (ftd3xx.listDevices() == None):
        time.sleep(1)
    time.sleep(1)
    ftd3xx.raiseExceptionOnError(origValue)

    if sys.platform == 'linux':
        count = 0
        while count == 0:
            count = ftd3xx.createDeviceInfoList()
def DemoEnumerateDevices():

    numDevices = ftd3xx.createDeviceInfoList()
    if (numDevices == 0):
        return False

    # list devices by listDevices(description)
    logging.debug("List devices by listDevices(description)")
    DEVICES = ftd3xx.listDevices(_ft.FT_OPEN_BY_DESCRIPTION)
    if (DEVICES is None):
        return False
    logging.debug("Device count = %d" % len(DEVICES))
    for i in range(len(DEVICES)):
        logging.debug("DEVICE[%d] = %s" % (i, DEVICES[i].decode('utf-8')))
    DEVICES = 0
    logging.debug("")

    # list devices by listDevices(serial number)
    logging.debug("List devices by listDevices(serial number)")
    DEVICES = ftd3xx.listDevices(_ft.FT_OPEN_BY_SERIAL_NUMBER)
    if (DEVICES is None):
        return False
    logging.debug("Device count = %d" % len(DEVICES))
    for i in range(len(DEVICES)):
        logging.debug("DEVICE[%d] = %s" % (i, DEVICES[i].decode('utf-8')))
    DEVICES = 0
    logging.debug("")

    # list devices by getDeviceInfoList()
    logging.debug("List devices by getDeviceInfoList()")
    logging.debug("Device count = %d" % numDevices)
    DEVICELIST = ftd3xx.getDeviceInfoList()
    for i in range(numDevices):
        logging.debug("DEVICE[%d]" % i)
        logging.debug("\tFlags = %d" % DEVICELIST[i].Flags)
        logging.debug("\tType = %d" % DEVICELIST[i].Type)
        logging.debug("\tID = %#010X" % DEVICELIST[i].ID)
        logging.debug("\tLocId = %d" % DEVICELIST[i].LocId)
        logging.debug("\tSerialNumber = %s" %
                      DEVICELIST[i].SerialNumber.decode('utf-8'))
        logging.debug("\tDescription = %s" %
                      DEVICELIST[i].Description.decode('utf-8'))
    DEVICELIST = 0
    logging.debug("")

    # list devices by getDeviceInfoDetail()
    logging.debug("List devices by getDeviceInfoDetail()")
    logging.debug("Device count = %d" % numDevices)
    for i in range(numDevices):
        DEVICE = ftd3xx.getDeviceInfoDetail(i)
        logging.debug("DEVICE[%d]" % i)
        logging.debug("\tFlags = %d" % DEVICE['Flags'])
        logging.debug("\tType = %d" % DEVICE['Type'])
        logging.debug("\tID = %#010X" % DEVICE['ID'])
        logging.debug("\tLocId = %d" % DEVICE['LocId'])
        logging.debug("\tSerialNumber = %s" %
                      DEVICE['SerialNumber'].decode('utf-8'))
        logging.debug("\tDescription = %s" %
                      DEVICE['Description'].decode('utf-8'))
        DEVICE = 0
    logging.debug("")

    return True
def DemoGetNumDevicesConnected():

    DEVICES = ftd3xx.listDevices()
    return len(DEVICES) if DEVICES is not None else 0