如何解决无法使用python从Libmpsse获取ChannelInfo
我无法从我的 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 举报,一经查实,本站将立刻删除。