You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I wrote a class to to synchronize the Analog Inputs and Outputs of an NI PCI6221 card. Things were working just fine, but when we tried to run this program on a different computer, we received an error message when using one of the methods from this library. The strange thing is, the computer we are getting this error on is running on more recent NI drivers and the latest PyDAQmx. Here is the code:
try:
fromPyDAQmximport*exceptImportError:
print"This program requires PyDAQmx to run."fromPyDAQmx.DAQmxCallBackimport*importnumpyasnpimportctypesimportreimporttimeNI_PCI_6221_MAX_VOLTAGE=10.0; # Max voltage outputNI_PCI_6221_MAX_SAMP_RATE=10000; # Measurement/generation rate ?? double check this#Input 250 kS/s#Output 833 kS/s for single channel, 740 kS.s for two channelstrigName=""classCallbackTask(Task):
def__init__(self):
Task.__init__(self)
self.buffLen=0self.callback=Noneself.trigName=""defconfigureCallbackTask(self, analogInputNameStr, sampRate, numSamples):
self.buffLen=numSamplesself.data=np.zeros(self.buffLen)
self.CreateAIVoltageChan(analogInputNameStr,"",DAQmx_Val_Diff,-10.0,10.0,DAQmx_Val_Volts,None)
self.CfgSampClkTiming("",float(sampRate),DAQmx_Val_Rising,DAQmx_Val_ContSamps,numSamples)
self.trigName=self.GetTerminalNameWithDevPrefix("ai/StartTrigger")
self.AutoRegisterEveryNSamplesEvent(DAQmx_Val_Acquired_Into_Buffer,1000,0)
self.AutoRegisterDoneEvent(0)
defEveryNCallback(self):
numReadBack=int32()
self.data=np.zeros(self.buffLen)
self.ReadAnalogF64(self.buffLen,10.0,DAQmx_Val_GroupByChannel,self.data,self.buffLen,byref(numReadBack),None)
ifself.callbackisnotNone:
self.callback(self.data)
return0# The function should return an integerdefDoneCallback(self, status):
print"Status",status.valuereturn0# The function should return an integerdefsetCallback(self, function):
self.callback=functiondefGetTerminalNameWithDevPrefix(self, terminalName):
device=ctypes.create_string_buffer(256)
productCategory=int32()
numDevices=uInt32()
self.GetTaskNumDevices(byref(numDevices))
foriinrange(1, numDevices.value+1):
self.GetNthTaskDevice(i,device,256)
#Issue occurs in the line belowDAQmxGetDevProductCategory(device,byref(productCategory))
ifproductCategory.value!=DAQmx_Val_CSeriesModuleandproductCategory.value!=DAQmx_Val_SCXIModule:
triggername="/"+device.value+"/"+terminalNamebreakreturntriggernamedefgetTrigName(self):
returnself.trigName
When I create an instance of the CallbackTask class, the error from the terminal says
"Error initializing wave output:
argument 1: <type 'exceptions.TypeError'>: string or integer address expected instead of c_char_Array_256 instance"
Any thoughts?
The text was updated successfully, but these errors were encountered:
Hi, I wrote a class to to synchronize the Analog Inputs and Outputs of an NI PCI6221 card. Things were working just fine, but when we tried to run this program on a different computer, we received an error message when using one of the methods from this library. The strange thing is, the computer we are getting this error on is running on more recent NI drivers and the latest PyDAQmx. Here is the code:
When I create an instance of the
CallbackTask
class, the error from the terminal says"Error initializing wave output:
argument 1: <type 'exceptions.TypeError'>: string or integer address expected instead of c_char_Array_256 instance"
Any thoughts?
The text was updated successfully, but these errors were encountered: