# ReadDIOChannels()

Reads digital I/O channel data from a binary file, and stores the values in an array.

Member of the DataLogger class.

## Function Prototype

VB .NET

Public Function ReadDIOChannels(ByVal startSample As Integer, ByVal count Integer, ByRef dioChannels As Single) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo ReadDIOChannels(int startSample, int count, ref float [] dioChannels)

## Parameter

startSample

The first sample to read from the binary file.

count

The number of samples to read from the binary file.

dioChannels

Receives the DIO channel values.

## Returns

- An ErrorInfo object that indicates the status of the operation.
- dioChannels – Returns the DIO channel values logged in the file.

### DIO array

The user is responsible for allocating the size of the DIO array, and ensuring that it is large enough to hold the data that will be returned. You can calculate the array allocation using the sampleCount value from GetSampleInfo(), and the dioCount value from GetDIOInfo().

float* dioChannels = new float[sampleCount * dioCount];

The figure below shows the layout of the DIO array, and how the elements should be indexed.

Where n is (dioCount - 1)

Use the following code fragment to access the elements of the DIO array:

for (i=0; i<numberOfSamples; i++)

{

for (j=0; j<numberOfDIOChannels; j++)

{

d = dioArray[(i * numberOfDIOChannels) + j];

}

}

where:

numberOfSamples is set by the sampleCount value from GetSampleInfo()

numberOfDIOChannels is set by the dioCount value from GetDIOInfo()