def listDevices(flags=0):
"""Return a list of serial numbers(default), descriptions or
locations (Windows only) of the connected FTDI devices depending on value
of flags"""
n = _ft.DWORD()
call_ft(_ft.FT_ListDevices, c.byref(n), None, _ft.DWORD(LIST_NUMBER_ONLY))
devcount = n.value
if devcount:
# since ctypes has no pointer arithmetic.
bd = [c.c_buffer(MAX_DESCRIPTION_SIZE) for i in range(devcount)] +\
[None]
# array of pointers to those strings, initially all NULL
ba = (c.c_char_p *(devcount + 1))()
for i in range(devcount):
ba[i] = c.cast(bd[i], c.c_char_p)
call_ft(_ft.FT_ListDevices, ba, c.byref(n), _ft.DWORD(LIST_ALL|flags))
return [res for res in ba[:devcount]]
else:
return None
评论列表
文章目录