|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-922442FC-D9E0-53BD-B8AD-011A724C96FF" xml:lang="en"><title>How |
|
13 to Detect Infrared Capability and Enable Infrared Mode: Tutorial</title><shortdesc>The Serial Communications Server API includes functionality to |
|
14 detect and configure an Infrared port. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
15 <context><p>These steps show the functionality of the Serial Communications |
|
16 Server API for Infrared. At the end of these steps, the port is set to Infrared |
|
17 mode. A port set to Infrared mode may still require further configuration |
|
18 specific to the Infrared driver. This further configuration is not included |
|
19 in this tutorial. </p> </context> |
|
20 <steps id="GUID-44197D73-A8BF-5662-B3BC-341766A7159B"> |
|
21 <step id="GUID-F614BCBB-696E-50F0-8C99-32D8AB7FC306"><cmd>Load the CSY and |
|
22 open a port.</cmd> |
|
23 </step> |
|
24 <step id="GUID-0745F9D1-81E5-5331-B577-4D959B43635B"><cmd>Get the capabilities |
|
25 of the port by calling <xref href="GUID-3B4E8ED5-72F7-3E51-B188-3C1045526DDF.dita#GUID-3B4E8ED5-72F7-3E51-B188-3C1045526DDF/GUID-4A6ECC68-EBC7-3B6C-94AE-9272669F6FF2"><apiname>RComm::Caps()</apiname></xref></cmd> |
|
26 </step> |
|
27 <step id="GUID-8911D514-9E2B-55CC-BD74-77BAF1A13F9C"><cmd>Get the Infrared |
|
28 capabilities by checking the bits in <xref href="GUID-A0BE41DB-1B73-3029-8B84-547D771257EA.dita"><apiname>TCommCaps.iSIR</apiname></xref> with |
|
29 the three bitmasks <xref href="GUID-E3455500-9903-3B8F-B702-E419BDE5DB4C.dita"><apiname>KCapsSIR115kbps</apiname></xref>, <xref href="GUID-BC1F7C67-E41E-3892-A9C4-3E752DF2AACB.dita"><apiname>KCapsSIR2400bpsOnly</apiname></xref>, |
|
30 and <xref href="GUID-87867BAD-C91E-388B-A3DE-69AB9598C0EF.dita"><apiname>KCapsSIR4Mbps</apiname></xref>. </cmd> |
|
31 <info>If any of the bitmasks show the bit as set, then the port has Infrared |
|
32 capability. </info> |
|
33 <info>The infra-red characteristic of the port can be determined from the |
|
34 value <xref href="GUID-4B2001D0-DE8A-3A90-8AF5-6485FA5FE70A.dita"><apiname>TCommCapsV01.iSIRSettings</apiname></xref>. </info> |
|
35 </step> |
|
36 <step id="GUID-CA055EB0-A8E5-5F5C-AD91-44F72CAA638C"><cmd>To use the port |
|
37 as an Infrared port, follow these steps: </cmd> |
|
38 <substeps id="GUID-F8BE2BA0-7DB1-5813-B291-92B0D640EA9D"> |
|
39 <substep id="GUID-8E02B974-1608-5AB9-808C-89281771712F"><cmd/> |
|
40 <info>Create an object of type <xref href="GUID-FA42F645-D2A8-384B-9FE6-6495EACFA479.dita"><apiname>TCommConfigV01</apiname></xref>. </info> |
|
41 </substep> |
|
42 <substep id="GUID-7596BE64-26E6-5F05-A113-CE9F54C66A8E"><cmd/> |
|
43 <info>Call <xref href="GUID-3B4E8ED5-72F7-3E51-B188-3C1045526DDF.dita#GUID-3B4E8ED5-72F7-3E51-B188-3C1045526DDF/GUID-4C38E1D8-EC81-36A3-BAA2-4D4FFECFD995"><apiname>RComm::Config()</apiname></xref> with the <codeph>aConfig</codeph> parameter |
|
44 set to the <codeph>TCommConfigV01</codeph> object to get the port configuration. </info> |
|
45 </substep> |
|
46 <substep id="GUID-17F5B58E-5B10-519C-A6FA-A57BBE6B9FB1"><cmd/> |
|
47 <info>Set the <xref href="GUID-4EDA16F3-40B1-3C8A-BD00-C04FF81053BB.dita"><apiname>iSIREnable</apiname></xref> flag in the <codeph>TCommConfigV01</codeph> object. </info> |
|
48 </substep> |
|
49 <substep id="GUID-C2ADDCD3-8B01-5E21-948C-E383D4CB4528"><cmd/> |
|
50 <info>Call <xref href="GUID-3B4E8ED5-72F7-3E51-B188-3C1045526DDF.dita#GUID-3B4E8ED5-72F7-3E51-B188-3C1045526DDF/GUID-4C38E1D8-EC81-36A3-BAA2-4D4FFECFD995"><apiname>RComm::Config()</apiname></xref> with the <codeph>TCommConfigV01</codeph> object |
|
51 as the <codeph>aConfig</codeph> parameter. </info> |
|
52 <info>The port is now set to Infrared mode. To use Infrared, the Infrared |
|
53 protocol must be understood so refer to the Infrared plugin section <xref href="GUID-D8E59924-4E17-56AE-8F6B-07749A2FF0B8.dita">IrDA Serial</xref>. </info> |
|
54 </substep> |
|
55 </substeps> |
|
56 </step> |
|
57 </steps> |
|
58 <example><title>Example</title> <codeblock id="GUID-F5B75720-86C3-5956-9238-255D46A2C013" xml:space="preserve">TCommCaps ourCapabilities; |
|
59 User::LeaveIfError(commPort.Caps (ourCapabilities)); |
|
60 |
|
61 if ((ourCapabilities ().iSIR & KCapsSIR115kbps) || |
|
62 (ourCapabilities ().iSIR & KCapsSIR2400bpsOnly) || |
|
63 (ourCapabilities ().iSIR & KCapsSIR4Mbps)) |
|
64 { |
|
65 // IR is supported, so enable it |
|
66 TCommConfig portSettings; |
|
67 User::LeaveIfError(commPort.Config (portSettings)); |
|
68 |
|
69 portSettings ().iSIREnable = ESIREnable; |
|
70 User::LeaveIfError (commPort.SetConfig (portSettings)); |
|
71 }</codeblock> </example> |
|
72 </taskbody><related-links> |
|
73 <link href="GUID-D8E59924-4E17-56AE-8F6B-07749A2FF0B8.dita"><linktext>IrDA Serial</linktext> |
|
74 </link> |
|
75 <link href="GUID-35D49549-1F4D-583F-A45D-9B557A207DD2.dita"><linktext>GlassTerm |
|
76 - glass teletype terminal</linktext></link> |
|
77 <link href="GUID-397239F9-7EE8-52CF-9B37-328AE307BAA0.dita"><linktext>How to |
|
78 Open a Port with the IrDA Protocol Module: Tutorial</linktext> |
|
79 </link> |
|
80 </related-links></task> |