How to Detect Infrared Capability and Enable Infrared Mode: Tutorial

The Serial Communications Server API includes functionality to detect and configure an Infrared port.


These steps show the functionality of the Serial Communications Server API for Infrared. At the end of these steps, the port is set to Infrared mode. A port set to Infrared mode may still require further configuration specific to the Infrared driver. This further configuration is not included in this tutorial.


  1. Load the CSY and open a port.

  2. Get the capabilities of the port by calling RComm::Caps()

  3. Get the Infrared capabilities by checking the bits in TCommCaps.iSIR with the three bitmasks KCapsSIR115kbps, KCapsSIR2400bpsOnly, and KCapsSIR4Mbps.

    If any of the bitmasks show the bit as set, then the port has Infrared capability. The infra-red characteristic of the port can be determined from the value TCommCapsV01.iSIRSettings.
  4. To use the port as an Infrared port, follow these steps:

    1. Create an object of type TCommConfigV01.
    2. Call RComm::Config() with the aConfig parameter set to the TCommConfigV01 object to get the port configuration.
    3. Set the iSIREnable flag in the TCommConfigV01 object.
    4. Call RComm::Config() with the TCommConfigV01 object as the aConfig parameter. The port is now set to Infrared mode.


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));

Related concepts

Related tasks