Прием данных через канал связи
Этот код от rtiostreamtest.c
показывает, как отправлять и получать данные от целевого процессора.
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; return; } #ifdef HOST_WORD_ADDRESSABLE_TESTING /* map to bytes */ sizeToTransfer *= MEM_UNIT_BYTES; #endif 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; } return; } else { sizeToTransfer -= sizeTransferred; ioPtr += sizeTransferred; } } }
rtiostream_wrapper
| rtIOStreamClose
| rtIOStreamOpen
| rtIOStreamSend