Main Content


Receive data through communication channel



errFlg = rtIOStreamRecv(streamID, dest, size, receivedDataSize) receives data through a communication channel.


Send and Receive Data from Processor

This code from rtiostreamtest.c shows how to send and receive data from a target processor.

static void blockingIO(int send, unsigned long numMemUnits)
    size_t sizeToTransfer = (size_t) numMemUnits; 
    size_t sizeTransferred;
    IOUnit_T * ioPtr = (IOUnit_T *) &buff[0];
    int status;

    if (numMemUnits > BUFFER_SIZE)
        AckCode = stat_notEnoughSpace;
        AckArg0 = BUFFER_SIZE;

   /* map to bytes */
   sizeToTransfer *= MEM_UNIT_BYTES;

   while (sizeToTransfer > 0) {
      sizeTransferred = 0;
      /* Do the low level call */
      status = send ?
         rtIOStreamSend(streamID, ioPtr, sizeToTransfer, &sizeTransferred) :
         rtIOStreamRecv(streamID, ioPtr, sizeToTransfer, &sizeTransferred);

      if (status != RTIOSTREAM_NO_ERROR) {
         if (AckCode == stat_OK) {
            AckCode = stat_RTIOSTREAM_ERROR;
            AckArg0 = data_counter;
      else {
         sizeToTransfer -= sizeTransferred;
         ioPtr += sizeTransferred;

Input Arguments

collapse all

Handle to the stream returned by a previous call to rtIOStreamOpen.

Pointer to the start of the buffer for received data.

Size of data to copy into the destination buffer. For byte-addressable architectures, size is measured in bytes. Some DSP architectures are not byte-addressable. In these cases, size is measured in number of WORDs, where sizeof(WORD) == 1.

Number of units of data received and copied into the buffer dest. If no data is copied, value is zero.

Output Arguments

collapse all

If the function runs without errors, it returns zero. Otherwise, it returns -1.

The rtiostream.h file defines these macros:


Version History

Introduced in R2009a