How to Terminate Read Requests Early: Tutorial

This tutorial explains how to terminate a read request. topic.


This tutorial assumes a knowledge of the How to transfer data: Tutorial topic.

An application that must respond quickly can set termination charactes that are expected in the data. The read requests complete if any termination characters appear in the data.

If an application needs to respond quickly to the content of the data that is received, the application can set termination characters. If any termination characters are set, the Serial Communications Server inspects the data during a read request. If the Serial Communications Server detects a termination character during a read request, the Serial Communicatoins Server completes the request with the data.

For example, an application that is reading lines of text can set the termination character to the line end character.


  1. Create an object of type TCommConfig.
  2. Call RComm::Config() with the aConfig parameter set to the TCommConfig object.

    The TCommConfig object now contains the port settings.
  3. Set the iTerminator array in the TCommconfig object to the terminator characters. The iTerminator array can contain four characters. If less than four characters are required, set the characters from index 0 of the array.
  4. Set the iTerminatorCount field in the TCommconfig object to the number of characters set in the iTerminator array.
  5. Call RComm::SetConfig() with the aConfig parameter set to the TCommConfig object.


TCommConfig portSettings;
commPort.Config (portSettings);
portSettings ().iTerminator[0] = 10;     // LF char
portSettings ().iTerminatorCount = 1;    // so that we terminate a read when each line feed arrives
User::LeaveIfError (commPort.SetConfig(portSettings));