InStream.get_channels_buffer_size uses wrong encoding
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 592
- Forks
- 199
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 10
Description
InStream.get_channels_buffer_size and OutStream.get_channels_buffer_size read the Task.channel_names property to calculate the maximum buffer size for a fault condition status property such as overcurrent_chans.
The problem is that these functions are calculating the length of the channel_names property after decoding from bytes to str. If Python represents str as UTF-16 or UTF-32, the number of characters in a str may be smaller than the number of UTF-8 bytes used to return that str from the DAQmx C API. When this happens, reading the fault condition property will likely return a "buffer too small" error when there is a fault.
Some potential solutions:
- Use
DAQmxGetTaskChannels(task, NULL, 0)to query the size of the TaskChannels property in the C API's native encoding (UTF-8 or MBCS). This would also be a small optimization because it would query the size of the TaskChannels property without querying the actual value. - Convert the task channels back to the C API's native encoding. This is a hack, so the first solution is better.
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
Start in generated/nidaqmx/task/_in_stream.py at InStream.get_channels_buffer_size and generated/nidaqmx/task/_out_stream.py at OutStream.get_channels_buffer_size. Read how Task.channel_names is decoded, then inspect the DAQmxGetTaskChannels call and its native encoding behavior. Done means fault-condition properties receive a buffer size based on the C API representation and no longer produce a buffer-too-small error for multibyte channel names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100