Cart Contact NSDSP Home

nsdsp_session_fetch_data

This function retrieves the data from NSDSP. Unlike nsdsp_session_fetch_data_nb, if the data is not immediately available, it waits until the requested amount of data is available.

Syntax

int nsdsp_session_fetch_data(
        nsdsp_session_t   session,
        void*             data,
        unsigned int      size
);

Parameters

session - a reference to the Session Object

data - the buffer to be filled in with data

size - the size of the data requested in bytes

Return

The function returns non-zero if the data has been successfully retrieved, or zero in case of timeout.

Example

This example shows how to organize a pipeline to receive SPI data.

#define MAX_CHUNK 0x8000

int ReceiveSPIData(nsdsp_session_t Session, char* Buffer, int Length) {
  int Chunk;
  int Outstanding;
  int Received;

  Outstanding = 0;
  while (Length) {
    Chunk = MAX_CHUNK;
    if (Chunk > Length) Chunk = Length;
    // Transmit read commands to the NSDSP programmer
    if (!nsdsp_session_receive_spi(Session,Chunk)) return 0;
    Outstanding += Chunk;
    Length -= Chunk;

    // Receive only the data that has already arrived
    Received = nsdsp_session_fetch_data_nb(Session,Buffer,Outstanding);
    Outstanding -= Received;
    Buffer += Received;
  }

  // Make sure all the commands are transferred to the NSDSP programmer
  if (!nsdsp_session_flush(Session)) return 0;

  if (Outstanding == 0) return 1;

  // Wait until the rest of the data arrives and fetch it
  return nsdsp_session_fetch_data(Session,Buffer,Outstanding);
}

 

Supported session types: UART,SPI

Minimum library version - 163

Northern Software Home NSDSP Contact Us Purchase/View Cart

© 2007-2025 Northern Software Inc. All Rights Reserved.