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

Cannot access properties on DO/DIChannel with multiple lines an LineGrouping.CHAN_FOR_ALL_LINES #514

Open
jgersti opened this issue Feb 23, 2024 · 1 comment

Comments

@jgersti
Copy link

jgersti commented Feb 23, 2024

Properties on DI/DOChannels with multiple lines and Grouping.CHAN_FOR_ALL_LINES cannot be accessed, because channel.name contains the wrong name.

On an (emulated and real) PCIe-6612 the following code snippet

with nidaqmx.Task() as task:
    channel = task.do_channel.add_do_chan(
        lines="Dev1/PFI25,Dev1/PFI26,Dev1/PFI29,Dev1/PFI30",
        line_grouping=LineGrouping.CHAN_FOR_ALL_LINES,
        name_to_assign_to_lines="Input",
    )
    print(channel.do_num_lines)

results in

nidaqmx.errors.DaqError: Property cannot be set seperately for each line.
When setting this property, specify a virtual channel as the active channel.
Property: DAQmx_DO_NumLines
Channel Name: Input
Physical Channel Name: Dev1/PFI25

Task Name: _unnamedTask<0>

Status Code: -200641

Unassigning channel._name (so that channel.name is resolved to channel._all_channels_name) or directly setting it to "Input" fixes this issues and the proper value (4) is returned.

@bkeryan
Copy link
Collaborator

bkeryan commented Feb 23, 2024

@jgersti, thank you for reporting this.

To work around this issue without using private implementation details, you should be able to index the channel collection to create a new channel object with the right name. The channel object is a proxy for the task and channel name, so it's ok to create a new channel object. (Note: I haven't tested this code snippet.)

task.do_channels.add_do_chan(
    lines="Dev1/PFI25,Dev1/PFI26,Dev1/PFI29,Dev1/PFI30",
    line_grouping=LineGrouping.CHAN_FOR_ALL_LINES,
    name_to_assign_to_lines="Input",
)
channel = task.do_channels["Input"]

FYI, when getting/setting per-line DIO properties, you should be able to index the channel collection with the physical channel name (again, untested code snippet):

task.di_channels["Dev1/PFI25"].di_dig_fltr_enable = true

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

2 participants