comtypes:在call_with_inout中,ctypes TypeError:“c_double”对象不是iterab

2024-10-01 11:28:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Python2.7.9中使用安捷伦IVI驱动程序,似乎无法让“经验证的”代码在特定的Windows7机器上运行。它在其他机器上成功执行。在

虽然这个问题似乎仅限于一种工具,但它似乎是一个更广泛的Python问题,因此我求助于堆栈溢出来寻求帮助。任何帮助或见解都会很好。在

以下代码

# Import the TLB

from comtypes.client import GetModule, CreateObject
GetModule('AgInfiniium.dll')

# Pull in the coefficients and classes, we'll need those
from comtypes.gen.AgilentInfiniiumLib import *

# Instantiate the driver
OScope = CreateObject('AgilentInfiniium.AgilentInfiniium')

# Make constants of our settings
Address = "TCPIP0::10.254.0.222::INSTR"
resetOScope = False

# Open a connection to the scope
OScope.Initialize(Address,False,resetOScope,'')

# Make a measurement
print OScope.Measurements.Item("Channel1").ReadWaveformMeasurement(
    MeasFunction=AgilentInfiniiumMeasurementAmplitude, MaxTime=10)

产生以下错误:

^{pr2}$

在我有限的调试尝试中,我看到了这个call_with_inout 函数试图将我的Python参数转换为以下C++函数的参数:

public void ReadWaveformMeasurement(
    AgilentInfiniiumMeasurementEnum MeasFunction,
    AgilentInfiniiumTimeOutEnum MaxTime,
    ref double pMeasurement)

它正在为pMeasurement指针创建某种类型的变量,该指针最终是c_double类型,然后抱怨它不可编辑。在

在这一点上,这似乎是本地的这台机器。我已经卸载了Python,重新安装了Agilent驱动程序,并尝试了comtypes的两个版本(1.1.0和1.1.1)。但问题依然存在。有什么想法吗?谢谢。在


Tags: the代码fromimport机器falsemakeaddress