Raw read/write methods fail when input/output range varies by channel
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 592
- Forks
- 199
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 10
Description
Calling task.in_stream.read() with different input/output ranges for each channel returns an error.
Steps to reproduce:
import nidaqmx
with nidaqmx.Task() as task:
task.ai_channels.add_ai_voltage_chan("Dev1/ai0", min_val=-1.0, max_val=1.0)
task.ai_channels.add_ai_voltage_chan("Dev1/ai1:3", min_val=-10.0, max_val=10.0)
data = task.in_stream.read(number_of_samples_per_channel=1)
print(data)
Expected result: it prints the raw data.
Actual result:
Traceback (most recent call last):
File "D:\dev\nidaqmx-python\examples\analog_in\ai_raw.py", line 7, in <module>
data = task.in_stream.read(number_of_samples_per_channel=1)
File "D:\dev\nidaqmx-python\generated\nidaqmx\task\_in_stream.py", line 1086, in read
has_negative_range = channels_to_read.ai_rng_low < 0
File "D:\dev\nidaqmx-python\generated\nidaqmx\task\channels\_ai_channel.py", line 2596, in ai_rng_low
val = self._interpreter.get_chan_attribute_double(self._handle, self._name, 0x1816)
File "D:\dev\nidaqmx-python\generated\nidaqmx\_library_interpreter.py", line 2483, in get_chan_attribute_double
self.check_for_error(error_code)
File "D:\dev\nidaqmx-python\generated\nidaqmx\_library_interpreter.py", line 6412, in check_for_error
raise DaqError(extended_error_info, error_code)
nidaqmx.errors.DaqError: Attempt to get property failed, because you specified multiple channels, and the property has different values for different channels.
Get this property one channel at a time.
Property: DAQmx_AI_Rng_Low
Task Name: _unnamedTask<0>
Status Code: -200657
Workaround: set task.ai_channels.all.ai_rng_high/low or task.ao_channels.all.ao_dac_rng_high/low.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example from the issue, then start in generated/nidaqmx/task/_in_stream.py at read(), following its use of channels_to_read.ai_rng_low and the related range properties in generated/nidaqmx/task/channels/_ai_channel.py. Check how varying per-channel ranges are handled and use the reported successful raw read with mixed ranges as the done condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100