我有以下問題:ctypes的UINT64轉換錯誤
我通過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)
EDIT2:
新增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.
你能再發表更多代碼?你如何打開DLL?看起來你並沒有使用'argtypes'。 – 101 2014-10-29 20:59:03
在我的問題中增加了更多代碼 – Gora 2014-10-30 07:56:36
TaskHandle是如何定義的? – 101 2014-10-30 09:44:59