Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

TypeError in cfg_samp_clk_timing() function

Solved!
Go to solution

I'm attempting to build a graphical user interface in python to easily configure and control measurements using a PCIe-6351 on a Windows machine (and eventually also compatible on Linux systems). The measurements performed will be long-duration, multi-channel time series' of voltages with optional real-time demodulation. I can successfully communicate with the card when the read_one_sample() function is used; the problems arise when trying to use the read_many_sample() function, as shown in my testing function below.

 

 

def RunMeasurement(self):
		task = nidaqmx.Task("NItask")


		for i in range(self.params[4]):
			task.ai_channels.add_ai_voltage_chan(self.params[6].split(",")[i])
		
		timingcfg = Timing(task)
		timingcfg.cfg_samp_clk_timing(
			rate=5.0,
			source="", 
			active_edge=nidaqmx.constants.Edge.RISING, 
			sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS, 
			samps_per_chan=32)

		task.start()
		datainput = in_stream.InStream(task)
		reader = nidaqmx.stream_readers.AnalogMultiChannelReader(datainput)

		data = np.zeros((self.params[4], 5))

		points_read = 0
		
		points_read = points_read + reader.read_many_sample(data, nidaqmx.constants.READ_ALL_AVAILABLE)


		print(data)
		print(points_read)


		task.close()

 

 

The problem comes from the timing.py module:

reidferguson_0-1615804025383.pngI tried printing the expected argtype (set by cfunc.argtypes = [lib_importer.task_handle ... ]), which returns <class 'ctypes.c_void_p'>. Ok, so it's a void pointer to the memory block where the task handle is stored.

 

However, the source code checks for self._handle, which is of type <class 'nidaqmx.task.Task'>. I'm guessing this is the meat of the problem.

 

My question is, then, what can I do to fix this? Is there something I'm doing incorrectly here?

0 Kudos
Message 1 of 2
(872 Views)
Solution
Accepted by reidferguson

I really don't know Python, but from prior threads I'm muddled through it seems like the syntax for navigating task configuration usually has a form like "task.qualifier.func()".

 

To my eye, it looks like you may have created a "disembodied" timing object as a *copy* of the not-yet-configured timing part of the task, then you configure timing on this copy which does not reference the task.  It's just hanging out there as a generic timing object.  Hence the null task pointer.

 

Very much just a guess, but trying to help.

 

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 2
(860 Views)