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
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.
The text was updated successfully, but these errors were encountered:
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.
Correction: it doesn't matter what the internal representation of str is. What matters is that len() on a str counts Unicode code points, not UTF-8 bytes:
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 asovercurrent_chans
.The problem is that these functions are calculating the length of the
channel_names
property after decoding frombytes
tostr
. If Python representsstr
as UTF-16 or UTF-32, the number of characters in astr
may be smaller than the number of UTF-8 bytes used to return thatstr
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:
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.The text was updated successfully, but these errors were encountered: