How to Send Data: Tutorial

This tutorial describes how to send and receive data with the Serial Communications Server.

Context

This tutorial follows the tutorial How to Open a Port: TutorialHow to Open a Port: Tutorial.

Steps

  1. All data sent from the serial device is 8-bit even on a Unicode system. Create a TDesC8 Descriptor and fill the Descriptor with the data to send.
  2. Create a request object of type TRequestStatus.
  3. Call RComm::Write() and set the aDes parameter as a reference to the Descriptor, and set the aStatus parameter to the request object. The RComm API does not allow another request to be made until the first request has completed.
  4. The write request completes when the last character in the supplied buffer has been written to the serial hardware. There are three alternative ways the write request can complete:
    1. If the aTimeOut parameter was set with the RComm::Write() function then the request completes with KErrTimedOut if the Descriptor was not filled during the aTimeOut time.

    2. If the write request is in progress, the write request can be cancelled by calling WriteCancel().

    3. A port can be configured to automatically terminate data transfer requests early when various error conditions occur.