Skip to main content
Skip table of contents

4.9 - AIStreamRead [U12 Datasheet]

Waits for a specified number of scans to be available and reads them. AIStreamStart should be called before this function and AIStreamClear should be called when finished with the stream. Note that while streaming the LabJack U12 is too busy to do anything else. If any function besides AIStreamRead is called while a stream is in progress, the stream will be stopped.

Note that you must pass the actual local ID to this function, not the idnum parameter used for most functions. Usually you simply pass the value returned by the idnum parameter in AIStreamStart.

Declaration:

long AIStreamRead ( long localID,
long numScans,
long timeout,
float (*voltages)[4],
long *stateIOout,
long *reserved,
long *ljScanBacklog,
long *overVoltage )

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:

  • localID – Send the local ID from AIStreamStart.
  • numScans – Function will wait until this number of scans is available. Minimum is 1. Maximum numSamples is 4096, where numSamples is numScans * numChannels. Internally this function gets data from the LabJack in blocks of 64 samples, so it is recommended that numSamples be at least 64.
  • timeout – Function timeout value in seconds. 1 is usually a good value.
  • *voltages – Pointer to a 4096 by 4 array where voltage readings are returned. Send filled with zeros.
  • *stateIOout – Pointer to a 4096 element array where IO states are returned. Send filled with zeros.

Outputs:

  • *voltages – Pointer to a 4096 by 4 array where voltage readings are returned. Unused locations are filled with 9999.0.
  • *stateIOout – Pointer to a 4096 element array where IO states are returned. Unused locations are filled with 9999.0.
  • *reserved – Reserved for future use. Send a pointer to a 0.
  • *ljScanBacklog – Returns the scan backlog of the LabJack RAM buffer. This is the number of scans remaining in the U12 buffer after this read. If this value is growing from read to read, data is not being read fast enough and the buffer will eventually overflow. In normal operation this will return 0 almost all the time. The size of the buffer in terms of scans is 4096/numChannels.
  • *overVoltage – If >0, an overvoltage has been detected on at least one sample of one of the selected analog inputs.

ActiveX Function Differences:
The “voltages” and “stateIOout” arrays are represented as strings. Floating point data is returned as 13 characters per number (XXXX.XXXXXXXX) and integers are returned as 10 characters per number (XXXXXXXXXX). Zeros are used for padding where necessary. . The total number of bytes in the “voltages” string is 13*numSamples. The total number of bytes in the “stateIOout” string is 10*numScans. Note that to avoid a memory leak, these strings should be emptied (set to “”) after each call to AIStreamReadX.

Declaration (ActiveX):

long AIStreamReadX ( long localID,
long numScans,
long timeout,
BSTR FAR* voltages,
BSTR FAR* stateIOout,
long FAR* ljScanBacklog,
long FAR* overVoltage)

JavaScript errors detected

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

If this problem persists, please contact our support.