How to Wait for the Write Buffer to Empty: Tutorial

This tutorial shows how to wait for the device driver to transmit data when a write request has previously been terminated early.

The tutorial How to Terminate Write Requests Early shows how the RComm::Write API can return early.

To wait for the buffer to be empty, call RComm::Write() in one of two ways:

  • sending an empty descriptor:

    commPort.Write (requeststatus,outputBuffer);
  • sending a descriptor with an optional length parameter of zero:

    commPort.Write (requeststatus,outputBuffer,0);

The state of the KConfigWriteBufferedComplete bit has no effect when the above methods are used.

This is a useful feature that enables something like a file transfer of a series of blocks to be sent efficiently making use of early completion, while still being able to guarantee through the method above that all the data has actually cleared the transmitter at end of the transfer.