def openEx(id_str, flags=OPEN_BY_SERIAL_NUMBER): """Open a handle to a usb device by serial number(default), description or location(Windows only) depending on value of flags and return an FTD2XX instance for it""" h = _ft.FT_HANDLE() call_ft(_ft.FT_OpenEx, id_str, _ft.DWORD(flags), c.byref(h)) return FTD2XX(h)
def getDeviceInfoDetail(devnum=0): """Get an entry from the internal device info list. """ f = _ft.DWORD() t = _ft.DWORD() i = _ft.DWORD() l = _ft.DWORD() h = _ft.FT_HANDLE() n = c.c_buffer(MAX_DESCRIPTION_SIZE) d = c.c_buffer(MAX_DESCRIPTION_SIZE) createDeviceInfoList() call_ft(_ft.FT_GetDeviceInfoDetail, _ft.DWORD(devnum), c.byref(f), c.byref(t), c.byref(i), c.byref(l), n, d, c.byref(h)) return {'index': devnum, 'flags': f.value, 'type': t.value, 'id': i.value, 'location': l.value, 'serial': n.value, 'description': d.value, 'handle': h}
def getDeviceInfoDetail(devnum=0, update=True): """Get an entry from the internal device info list. Set update to False to avoid a slow call to createDeviceInfoList.""" f = _ft.DWORD() t = _ft.DWORD() i = _ft.DWORD() l = _ft.DWORD() h = _ft.FT_HANDLE() n = c.c_buffer(MAX_DESCRIPTION_SIZE) d = c.c_buffer(MAX_DESCRIPTION_SIZE) # createDeviceInfoList is slow, only run if update is True if update: createDeviceInfoList() call_ft(_ft.FT_GetDeviceInfoDetail, _ft.DWORD(devnum), c.byref(f), c.byref(t), c.byref(i), c.byref(l), n, d, c.byref(h)) return {'index': devnum, 'flags': f.value, 'type': t.value, 'id': i.value, 'location': l.value, 'serial': n.value, 'description': d.value, 'handle': h}
def open(dev=0): """Open a handle to a usb device by index and return an FTD2XX instance for it""" h = _ft.FT_HANDLE() call_ft(_ft.FT_Open, dev, c.byref(h)) return FTD2XX(h)