问题描述
我无法从我的 FTDI USB-I2C 智能电缆 (C232HM-DHSL-0) 获取频道信息。我可以获得通道号,但它总是在 I2C_GetChannelInfo() 处显示 status = 1。任何人都可以帮助找出原因吗?我的代码如下:
import ctypes
from ctypes import wintypes
import ctypes as c
import os
class FT_DEVICE_LIST_INFO_NODE(ctypes.Structure): # Add this structure refering to ...
_fields_ = [("Flags",ctypes.c_ulong),("Type",("ID",("LociD",ctypes.c_long),("SerialNumber",ctypes.c_byte * 16),("Description",ctypes.c_byte * 64),("ftHandle",ctypes.c_void_p)]
def libmPSSE_Method():
chn_count = ctypes.c_int()
libmPSSE = ctypes.cdll.LoadLibrary(str(os.getcwd())+"\\libmPSSE.dll")
libmPSSE.Init_libmPSSE()
status = libmPSSE.I2C_GetNumChannels(ctypes.byref(chn_count))
print 'Total I2C Channel -->>',str(chn_count.value),' channels'
if chn_count.value > 0:
flags = c.c_ulong()
typ = c.c_ulong()
ID = c.c_ulong()
LociD = c.c_ulong()
serial = c.create_string_buffer(16)
desc = c.create_string_buffer(64)
handle = c.c_void_p()
for i in range(chn_count.value):
channel_info = FT_DEVICE_LIST_INFO_NODE()
# =========== getting Channel info ======================================
status = libmPSSE.I2C_GetChannelInfo(c.byref(channel_info))
print 'status = ',status
#status = libmPSSE.I2C_GetChannelInfo(i,channel_info)
print '=======Channel[',i,']=============='
print channel_info.Flags # ("Flags",print channel_info.Type # ("Type",print channel_info.ID # ("ID",print channel_info.LociD # ("Locid",print channel_info.SerialNumber
#print(''.join([chr(i) for i in channel_info.SerialNumber]).rstrip('\x00')) # ("SerialNumber",# just to print string in ctype bytearray( refering https://stackoverflow.com/questions/29291624/python-convert-ctypes-ubyte-array-to-string)
print(''.join([chr(i) for i in channel_info.Description]).rstrip('\x00')) # ("Description",print '=============================='
print '*************************************************************************************'
libmPSSE_Method()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)