Skip to main content
Skip table of contents

SetStreamCallback [LJM User's Guide]

Sets a callback that is called by LJM when the stream has collected ScansPerRead scans. The callback should call LJM_eStreamRead.

LJM_SetStreamCallback is alternative to manually calling LJM_eStreamRead. Manually calling LJM_eStreamRead is more straightforward than using LJM_SetStreamCallback, but LJM_SetStreamCallback allocates a work thread within LJM that calls the callback. Because of this, it's more appropriate for applications that need to perform other work, such as updating a GUI.

Syntax

typedef void (*LJM_StreamReadCallback)(void *);

LJM_ERROR_RETURN LJM_SetStreamCallback(
int Handle,
LJM_StreamReadCallback Callback,
void * Arg)

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.

Callback [in]

The callback function for LJM's stream thread to call when ScansPerRead scans of stream data are ready, which should call LJM_eStreamRead to acquire data. ScansPerRead is a value of LJM_eStreamStart.

Arg [in]

The user-defined argument that is passed to Callback when it is invoked.

Returns

LJM errorcodes or 0 for no error.

Remarks

Before calling this function, start stream using LJM_eStreamStart.

The Callback function is executed by a dedicated thread within LJM. LJM_SetStreamCallback should not be called from within Callback. In versions of LJM before 1.1405, LJM_eStreamStop should not be called from within Callback.

To disable the previous callback for stream reading, pass 0 or NULL as Callback.

As an alternative to LJM_SetStreamCallback, the LJM configuration LJM_STREAM_SCANS_RETURN may also be useful. It controls the block on LJM_eStreamRead, allowing LJM_eStreamRead to return immediately with an error if a full read of data is not ready.

JavaScript errors detected

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

If this problem persists, please contact our support.