Skip to main content
Skip table of contents

eStreamRead [LJM User's Guide]

Returns ScansPerRead * NumAddresses samples from an initialized and running LJM stream buffer. By default, eStreamRead waits for data to become available, if necessary.

Syntax

LJM_ERROR_RETURN LJM_eStreamRead(
int Handle,
double * aData,
int * DeviceScanBacklog,
int * LJMScanBacklog)

Parameters

Handle [in]

A device handle. The handle is a connection ID for an active device. Generate a handle with LJM_Open or LJM_OpenS.

aData [out]

An array that contains the samples being read. Returns all channels interleaved (see note below). Must be large enough to hold ScansPerRead * NumAddresses values, where ScansPerRead and NumAddresses are values passed to LJM_eStreamStart. The data returned is removed from the LJM stream buffer according to first in, first out (FIFO) order.

DeviceScanBacklog [out]

The number of scans left in the device buffer, as measured from when data was last collected from the device. DeviceScanBacklog should usually be near zero and not growing.

LJMScanBacklog [out]

The number of scans left in the LJM buffer, which does not include concurrent data sent in the aData array. LJMScanBacklog should usually be near zero and not growing.

Returns

LJM errorcodes or 0 for no error.

By default, eStreamRead should be considered a blocking call. To make eStreamRead always return immediately, configure LJM_STREAM_SCANS_RETURN to LJM_STREAM_SCANS_RETURN_ALL_OR_NONE.

If LJM_eStreamRead returns an error, LJM nearly always attempts to command the device to stop streaming. LJM does not do so for the case when LJME_NO_SCANS_RETURNED is returned (due to LJM_STREAM_SCANS_RETURN_ALL_OR_NONE).

Remarks

Before calling this function, create a data buffer using LJM_eStreamStart. To stop stream, use LJM_eStreamStop.

If LJM_eStreamRead gives error 1301 (LJME_LJM_BUFFER_FULL) or many -9999 values in aData, here are some strategies to help.

LJM 1.2100 and later: If this function returns the error LJME_SYNCHRONIZATION_TIMEOUT, try setting a large send/receive timeout for the appropriate connection type.

Interleaved Channels

aData returns interleaved data. For example, when streaming two channels, AIN0 and AIN1, aData will look like this:

aData[0] contains the first AIN0 sample aData[1] contains the first AIN1 sample aData[2] contains the second AIN0 sample aData[3] contains the second AIN1 sample ...

Example

See the LJM_eStreamStart page for an example using LJM_eStreamRead.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.