When you call add_di_chan or add_do_chan with name_to_assign_to_lines!="" and line_grouping==CHAN_FOR_ALL_LINES, two things happen:
The channel collection passes name_to_assign_to_lines to the DAQmx C API, which honors the user's requested channel name.
The channel collection ignores name_to_assign_to_lines when returning a channel object for the newly created channel. Instead, it uses the physical channel names (lines). This works when accessing line-based DI/DO properties but not channel-based DI/DO properties.
Example:
import nidaqmx
from nidaqmx.constants import LineGrouping
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", line_grouping=LineGrouping.CHAN_PER_LINE)
print("CHAN_PER_LINE, no name:", chan.name, repr(task.di_channels.channel_names))
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", "MyChan", line_grouping=LineGrouping.CHAN_PER_LINE)
print("CHAN_PER_LINE, MyChan", chan.name, repr(task.di_channels.channel_names))
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
print("CHAN_FOR_ALL_LINES, no name", chan.name, repr(task.di_channels.channel_names))
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", "MyChan", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
print("CHAN_FOR_ALL_LINES, MyChan:", chan.name, repr(task.di_channels.channel_names))
When you call add_di_chan or add_do_chan with name_to_assign_to_lines!="" and line_grouping==CHAN_FOR_ALL_LINES, two things happen:
Example:
Output:
Expected output: last line should be