我遇到了以下问题:
我通过 c 类型加载 nicaiu.dll 来控制NI-USB6218
数据采集板,我必须调用几个函数来初始化它(DAQmxCreateTask(), DAQmxCreateAIVoltageChan() and DAQmxCfgSampClkTiming()
)。
前两个调用有效,但DAQmxCfgSampClkTiming()
引发此错误
Traceback (most recent call last):
File "C:/*********/Voltage.py", line 68, in <module>
values)
ctypes.ArgumentError: argument 6: <type 'exceptions.TypeError'>: Don't know how to convert
parameter 6
参数 6 应该是 uint64 参见Doc 这是我的函数调用:
DAQmx_Val_Rising = 10280 #see NIDAQmx.h
DAQmx_Val_FiniteSamps = 10178 # see NIDAQmx.h
values = uint64(40000) #numpy function
dll.DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", c_float(4000.0), DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
values)
我也尝试过 values = c_uint64(40000)
,但没有奏效。
Edit1: dll 位于 System32 文件夹 (Win7)
dll = cdll.nicaiu
例如,此函数调用有效(返回值 = 0)
DAQmx_Val_Diff = 10106
DAQmx_Val_RSE = 10083
DAQmx_Val_Volts = 10348
returnvalue = dll.DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai1", taskName, DAQmx_Val_RSE,
c_float(-1.0),c_float(1.0), DAQmx_Val_Volts, None)
编辑2:
添加了 argtypes 行
dll.DAQmxCfgSampClkTiming.argtypes = [c_int, c_char_p, c_float, c_int32, c_int32, c_uint64]
returnvalue = dll.DAQmxCfgSampClkTiming(taskHandle, None, c_float(4000.0), DAQmx_Val_Rising,
DAQmx_Val_FiniteSamps,values)
仍然得到错误代码 -200077 此代码的定义是:
nierror code = -200077
Requested value is not a supported value for this property. The property value may be invalid
because it conflicts with another property.