Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_di_chan and add_do_chan ignore name_to_assign_to_lines for returned channel object with CHAN_FOR_ALL_LINES #551

Open
bkeryan opened this issue Mar 27, 2024 · 0 comments

Comments

@bkeryan
Copy link
Collaborator

bkeryan commented Mar 27, 2024

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))

Output:

CHAN_PER_LINE, no name: Dev1/port0/line0:7 ['Dev1/port0/line0', 'Dev1/port0/line1', 'Dev1/port0/line2', 'Dev1/port0/line3', 'Dev1/port0/line4', 'Dev1/port0/line5', 'Dev1/port0/line6', 'Dev1/port0/line7']
CHAN_PER_LINE, MyChan MyChan0:7 ['MyChan0', 'MyChan1', 'MyChan2', 'MyChan3', 'MyChan4', 'MyChan5', 'MyChan6', 'MyChan7']
CHAN_FOR_ALL_LINES, no name Dev1/port0/line0... ['Dev1/port0/line0...']
CHAN_FOR_ALL_LINES, MyChan: Dev1/port0/line0:7 ['MyChan']

Expected output: last line should be

CHAN_FOR_ALL_LINES, MyChan: MyChan ['MyChan']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant