How to Configure a Port: Tutorial

This tutorial shows the basic steps to perform any serial port configuration through the RComm API.


  1. Load the CSY and open a port.

  2. Get the capabilities of the port by calling RComm::Caps()
  3. The capabilities of the port are in the TCommCaps structure. For example, TCommCapsV01.iRate contains a bit field of the bit rates the port can manage. Note: A port may be able to manage bit rates higher than those contained in the TCommCapsV01.iRate bit field.

  4. Create an object of type TCommConfigV01 .

  5. Call RComm::Config() with the aConfig parameter set to the TCommConfigV01 object to get the port configuration.

  6. Set the fields that must be changed in the TCommConfigV01 object. For example, set the iSIREnable flag to enable Infrared.

  7. Call RComm::Config() with the TCommConfigV01 object as the aConfig parameter. The port is now configured.

Example

       
        
       
       TCommCaps ourCapabilities;
User::LeaveIfError(commPort.Caps (ourCapabilities));

 if ((ourCapabilities ().iSIR & KCapsSIR115kbps) ||
(ourCapabilities ().iSIR & KCapsSIR2400bpsOnly) ||
(ourCapabilities ().iSIR & KCapsSIR4Mbps))
{
   // IR is supported, so enable it
   TCommConfig portSettings;
   User::LeaveIfError(commPort.Config (portSettings));

   portSettings ().iSIREnable = ESIREnable;
   User::LeaveIfError (commPort.SetConfig (portSettings));
}