Reading and Writing with NI-DAQmx Streams

NI-DAQmx 17.1 .NET Class Library Help

Edition Date: June 2017

Part Number: 370473J-01

»View Product Info
Download Help (Windows Only)

To read and write with the NI-DAQmx .NET library, use reader, writer, and stream objects.

This programming pattern is similar to the pattern used throughout the .NET Framework for file and network I/O.

To perform I/O in the NI-DAQmx library:

  1. (Optional) Create a task object.
  2. Create an instance of a reader or writer, passing the task's DaqStream (Task.Stream) in the constructor.
  3. Perform reads or writes.
The following example demonstrates this process:

VB.NET
'Given a Task instance "myTask", 
'Create the reader and attach it to the stream 
Dim reader as AnalogSingleChannelReader
reader = New AnalogSingleChannelReader(myTask.Stream)
'Perform the read 
Dim data as Double()
data = reader.ReadMultiSample(100)

C#

// Given a Task instance "myTask", 
// Create the reader and attach it to the stream
AnalogSingleChannelReader reader = new AnalogSingleChannelReader(myTask.Stream);
// Perform the read 
double[] data = reader.ReadMultiSample(100);
Related information

WAS THIS ARTICLE HELPFUL?

Not Helpful