« Close

Datasheets and User Guides

App Notes

Software & Driver


5.2 - Streaming: LJM_eStreamRead gives error 1301 (LJME_LJM_BUFFER_FULL) or many -9999 values in aData. What can I try?

Streaming: LJM_eStreamRead gives error 1301 (LJME_LJM_BUFFER_FULL) or many -9999 values in aData. What can I try?

When the program running LJM code is unable to keep up with transferring stream data from the device to the computer, LJM_eStreamRead will return error 1301 (LJME_LJM_BUFFER_FULL) and/or stream data will contain many -9999 (LJM_DUMMY_VALUE) values. Here's what to do.


  • Use a ScansPerRead that is relatively large (one half of the ScanRate is a good place to start)
  • Try an Ethernet connection if possible
  • Call LJM_eStreamRead as quickly as possible
  • Use an additional thread or process
  • Increase the buffer sizes
  • Free up processing power by ending unneeded processes
  • Use plain C/C++
  • Increase your program's priority level
  • Disable the LJM debug log

In more detail:

ScansPerRead: The larger the number of ScansPerRead you set up in LJM_eStreamStart, the less overhead there will be. Increasing ScansPerRead will see larger improvements up until the maximum samples per packet is reached, and smaller improvements after that. For the T7 connected over USB, the maximum samples per packet is 24. For the T7 over Ethernet, the maximum samples per packet is 512. For example, if you have 2 channels, a ScansPerRead of 12 will utilize the maximum samples per packet over USB. (24 samples per packet ÷ 2 samples per scan = 12 scans per packet)

Ethernet: Ethernet streaming usually ends up being more efficient for this reason, so if you are having problems with USB streaming, try switching to Ethernet streaming if you can. Please note that WiFi streaming is not as fast as Ethernet streaming.

Calling LJM_eStreamRead quickly: Sometimes there can be unexpectedly long delays between LJM_eStreamRead calls, such as during intense calculations. Make sure your program is calling LJM_eStreamRead as quickly as possible. It may be worth putting some timing code in your program to calculate whether LJM_eStreamRead is called at the right frequency. For example, if your scan rate is 100,000 Hz and your ScansPerRead is 50,000, you'll want LJM_eStreamRead to be called at 2 Hz. You could also try removing all parts of the stream read loop except for the call to LJM_eStreamRead, then work your way back towards full functionality.

Use an additional thread or process: Related to the need to the previous point to call LJM_eStreamRead as quickly possible, lengthy operations should be performed in a separate thread or process from the thread that calls LJM_eStreamRead. If work being done in the loop that calls LJM_eStreamRead is slow, such as in the case of displaying graphics, then LJM_eStreamRead will fall behind reading from stream. This may cause LJMScanBacklog to increase and eventually cause a LJME_LJM_BUFFER_FULL error. To prevent this, the data from aData may be passed to an alternate thread or process which will perform the lengthy operations.

Increase the buffer sizes: Both LJM and the streaming device have buffers that can run out of space.

  • To increase the device buffer: write a larger value to the device's STREAM_BUFFER_SIZE_BYTES register. As of this writing, the T7's default is 4096 and its maximum is 32768.
  • To increase LJM's stream buffer: write a larger value to "LJM_STREAM_BUFFER_MAX_NUM_SECONDS". LJM uses this config to calculate the buffer size according to the sample rate. As of this writing, the default is 20 seconds and the maximum is determined by the amount of memory your system has available.

Plain C/C++: Using C or C++ is the fastest way to use LJM. You may want to try running the stream_basic C example to see how it performs, adjusting stream parameters as needed.

Priority level:

  • Windows program priority can be set by using the start command (/realtime is the highest priority)
  • Linux and Mac OS X program priority can be set by using the nice command (-20 is the highest priority)

Disable the LJM debug log: Ensure that LJM's debug logging is turned of by setting LJM_DEBUG_LOG_MODE as 1 (LJM_DEBUG_LOG_MODE_NEVER) by using LJM_WriteLibraryConfigS—i.e. call LJM_WriteLibraryConfigS(LJM_DEBUG_LOG_MODE, LJM_DEBUG_LOG_MODE_NEVER). Note that the default LJM_DEBUG_LOG_MODE is LJM_DEBUG_LOG_MODE_NEVER, so this will not have an effect if you have not previously set the LJM_DEBUG_LOG_MODE.