提问者:小点点

ctype uint64转换错误


我遇到了以下问题:

我通过c类型加载nicaiu. dll来控制NI-USB6218数据采集板,我必须调用几个函数来初始化它(DAQmxCreateTask()、DAQmxCreateAIVoltageChan()和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)  

我还尝试了值=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:

添加了argtype行

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.

共1个答案

匿名用户

我不能测试它,因为我没有那个仪器,但我会从这样的东西开始:

samp_clk_timing = dll.DAQmxCfgSampClkTiming
samp_clk_timing.restype = c_int32
samp_clk_timing.argtypes = (TaskHandle,
                            c_char_p,          
                            c_double,         
                            c_int32,
                            c_int32,           
                            c_uint64)

return_val = samp_clk_timing(taskHandle,
                             "OnboardClock",
                             c_double(4000),
                             c_int32(10106),
                             c_int32(10178),
                             c_uint64(40000))