07-05-2009 07:36 PM - edited 07-05-2009 07:39 PM
GaryS,
Have you tried using the python None type instead of using the null = ctypes.POINTER(ctypes.c_int)() syntax?
check out this example code
http://scipy.org/Cookbook/Data_Acquisition_with_NIDAQmx
07-05-2009 07:48 PM
GaryS,
Have you tried using the python None type instead of using the null = ctypes.POINTER(ctypes.c_int)() syntax? I've had success using the DAQmx dll in windows and problems typically reduce down to figuring out the proper way of passing variables from the python script to the C function.
Learning the ctypes module is the key.
nidaq.DAQmxWriteDigitalLines(enable,
None ) # reserved, supposed to be NULL
check out this example code as well
07-12-2009 04:43 AM
Hello,
I just tried (not being aware of this thread) to do the same thing: wrapping DAQmxBase into python under SuSE Linux 10.3, python 2.5.
My approach was using swig, but I unfortunately ran into the same problem -> the taskHandle pointer was NULL after createTask.
This just for the records. I might now consider to try the presented solution (compile into python), or I just stay in c++ - don't know yet.
Cheers
Volker
10-09-2009 02:56 PM
Gary S,
Your problem is not the last parameter, but with the third last. DAQmxWriteDigitalLines wants an array of samples. If you only have one sample, you can try replacing:
ctypes.c_uint8(1)
with:
ctypes.byref(ctypes.c_uint8(1))
I think the way to handle it generically would be:
numSamples = 1 # or however many samples you want
valArray = (ctypes.c_uint8*numSamples)()
valArray[0] = 1
nidaq.DAQmxWriteDigitalLines(enable,
ctypes.c_int32(1), # numSamplsPerChan
ctypes.c_int32(1), # autostart=1
ctypes.c_double(1), # timeout
DAQmx_Val_GroupByChannel,
ctypes.byref(valArray), # VALUES TO BE WRITTEN
ctypes.byref(sampsPerChanWritten),
null )