How to Configure a Port: Tutorial
This tutorial shows the basic steps to perform any serial port configuration through the RComm API.
Load the CSY and open a port.
Get the capabilities of the port by calling RComm::Caps()
- 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.
Create an object of type TCommConfigV01.
Call RComm::Config() with the aConfig parameter set to the TCommConfigV01 object to get the port configuration.
Set the fields that must be changed in the TCommConfigV01 object. For example, set the iSIREnable flag to enable Infrared.
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));
}
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.