From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Get port and line in difference ways by using Task.DIChannels.CreateChannel

I know I can use this way like  (for example)
"/cardName/port2/line3"    or
"/cardName/port2/line1:5" or

"/cardName/port2:port3"

 

But if I want to get the bits     4567 from port 2 and bits 012 from port 3?

Something like "/cardName/port2/line4:7/port3/line4:7"??

0 Kudos
Message 1 of 6
(2,765 Views)

Hi there,

 

I think /cardName/port2/line4:7/port3/line0:2 shoud do the trick.

It is also an option to create a task with MAX and then use call it from your code, here is a reference.

0 Kudos
Message 2 of 6
(2,715 Views)

Thaks for your answer I try this like

You know what am I doing wrong?

 task = new NationalInstruments.DAQmx.Task();
            task.DIChannels.CreateChannel($"/CardName/port6/line0:7/port7/line0:2", "ch1", ChannelLineGrouping.OneChannelForAllLines);
            readerFirst = new DigitalSingleChannelReader(task.Stream);
            var xxxx = readerFirst.ReadSingleSampleMultiLine();

 

NationalInstruments.DAQmx.DaqException: 'Syntax for a range of objects in the input string is invalid.

For ranges of objects, specify a number immediately before and after every colon (":") in the input string. Or, if a name is specified after the colon, it must be identical to the name specified immediately before the colon. Colons are not allowed within the names of the individual objects.

 

0 Kudos
Message 3 of 6
(2,708 Views)

Hi there, 

 

I think this error proved us wrong, this is an invalid way to declare the range of lines.

Have you tried creating a second channel, removing the "port7" section of this line code and adding it in another line?

0 Kudos
Message 4 of 6
(2,703 Views)

Yes,  that what I did . 

0 Kudos
Message 5 of 6
(2,701 Views)

Glad that worked! Then you could mark this one as resolved now!

0 Kudos
Message 6 of 6
(2,698 Views)