First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "T_TCommCapsV01Data.h"
23 _LIT(KCmdConstructor, "new");
24 _LIT(KCmdDestructor, "~");
25 _LIT(KCmdiDataBits, "iDataBits");
26 _LIT(KCmdiFifo, "iFifo");
27 _LIT(KCmdiHandshake, "iHandshake");
28 _LIT(KCmdiParity, "iParity");
29 _LIT(KCmdiRate, "iRate");
30 _LIT(KCmdiSIR, "iSIR");
31 _LIT(KCmdiSignals, "iSignals");
32 _LIT(KCmdiStopBits, "iStopBits");
34 _LIT(KFldExpected, "expected");
36 _LIT(KLogError, "Error=%d");
39 _LIT(KStrKCapsData5, "KCapsData5");
40 _LIT(KStrKCapsData6, "KCapsData6");
41 _LIT(KStrKCapsData7, "KCapsData7");
42 _LIT(KStrKCapsData8, "KCapsData8");
43 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableDataBits[] =
45 // Enum as a descriptor Enum
46 KStrKCapsData5, KCapsData5,
47 KStrKCapsData6, KCapsData6,
48 KStrKCapsData7, KCapsData7,
49 KStrKCapsData8, KCapsData8,
53 _LIT(KStrKCapsHasFifo, "KCapsHasFifo");
54 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableFifo[] =
56 // Enum as a descriptor Enum
57 KStrKCapsHasFifo, KCapsHasFifo,
61 _LIT(KStrKCapsObeyXoffSupported, "KCapsObeyXoffSupported");
62 _LIT(KStrKCapsSendXoffSupported, "KCapsSendXoffSupported");
63 _LIT(KStrKCapsObeyCTSSupported, "KCapsObeyCTSSupported");
64 _LIT(KStrKCapsFailCTSSupported, "KCapsFailCTSSupported");
65 _LIT(KStrKCapsObeyDSRSupported, "KCapsObeyDSRSupported");
66 _LIT(KStrKCapsFailDSRSupported, "KCapsFailDSRSupported");
67 _LIT(KStrKCapsObeyDCDSupported, "KCapsObeyDCDSupported");
68 _LIT(KStrKCapsFailDCDSupported, "KCapsFailDCDSupported");
69 _LIT(KStrKCapsFreeRTSSupported, "KCapsFreeRTSSupported");
70 _LIT(KStrKCapsFreeDTRSupported, "KCapsFreeDTRSupported");
71 _LIT(KStrKCapsObeyDTRSupported, "KCapsObeyDTRSupported");
72 _LIT(KStrKCapsObeyRTSSupported, "KCapsObeyRTSSupported");
73 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableHandshake[] =
75 // Enum as a descriptor Enum
76 KStrKCapsObeyXoffSupported, KCapsObeyXoffSupported,
77 KStrKCapsSendXoffSupported, KCapsSendXoffSupported,
78 KStrKCapsObeyCTSSupported, KCapsObeyCTSSupported,
79 KStrKCapsFailCTSSupported, KCapsFailCTSSupported,
80 KStrKCapsObeyDSRSupported, KCapsObeyDSRSupported,
81 KStrKCapsFailDSRSupported, KCapsFailDSRSupported,
82 KStrKCapsObeyDCDSupported, KCapsObeyDCDSupported,
83 KStrKCapsFailDCDSupported, KCapsFailDCDSupported,
84 KStrKCapsFreeRTSSupported, KCapsFreeRTSSupported,
85 KStrKCapsFreeDTRSupported, KCapsFreeDTRSupported,
86 KStrKCapsObeyDTRSupported, KCapsObeyDTRSupported,
87 KStrKCapsObeyRTSSupported, KCapsObeyRTSSupported,
91 _LIT(KStrKCapsParityNone, "KCapsParityNone");
92 _LIT(KStrKCapsParityEven, "KCapsParityEven");
93 _LIT(KStrKCapsParityOdd, "KCapsParityOdd");
94 _LIT(KStrKCapsParityMark, "KCapsParityMark");
95 _LIT(KStrKCapsParitySpace, "KCapsParitySpace");
96 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableParity[] =
98 // Enum as a descriptor Enum
99 KStrKCapsParityNone, KCapsParityNone,
100 KStrKCapsParityEven, KCapsParityEven,
101 KStrKCapsParityOdd, KCapsParityOdd,
102 KStrKCapsParityMark, KCapsParityMark,
103 KStrKCapsParitySpace, KCapsParitySpace,
107 _LIT(KStrKCapsBps50, "KCapsBps50");
108 _LIT(KStrKCapsBps75, "KCapsBps75");
109 _LIT(KStrKCapsBps110, "KCapsBps110");
110 _LIT(KStrKCapsBps134, "KCapsBps134");
111 _LIT(KStrKCapsBps150, "KCapsBps150");
112 _LIT(KStrKCapsBps300, "KCapsBps300");
113 _LIT(KStrKCapsBps600, "KCapsBps600");
114 _LIT(KStrKCapsBps1200, "KCapsBps1200");
115 _LIT(KStrKCapsBps1800, "KCapsBps1800");
116 _LIT(KStrKCapsBps2000, "KCapsBps2000");
117 _LIT(KStrKCapsBps2400, "KCapsBps2400");
118 _LIT(KStrKCapsBps3600, "KCapsBps3600");
119 _LIT(KStrKCapsBps4800, "KCapsBps4800");
120 _LIT(KStrKCapsBps7200, "KCapsBps7200");
121 _LIT(KStrKCapsBps9600, "KCapsBps9600");
122 _LIT(KStrKCapsBps19200, "KCapsBps19200");
123 _LIT(KStrKCapsBps38400, "KCapsBps38400");
124 _LIT(KStrKCapsBps57600, "KCapsBps57600");
125 _LIT(KStrKCapsBps115200, "KCapsBps115200");
126 _LIT(KStrKCapsBps230400, "KCapsBps230400");
127 _LIT(KStrKCapsBps460800, "KCapsBps460800");
128 _LIT(KStrKCapsBps576000, "KCapsBps576000");
129 _LIT(KStrKCapsBps1152000, "KCapsBps1152000");
130 _LIT(KStrKCapsBps4000000, "KCapsBps4000000");
131 _LIT(KStrKCapsBps921600, "KCapsBps921600");
132 _LIT(KStrKCapsBpsAutobaud, "KCapsBpsAutobaud");
133 _LIT(KStrKCapsBpsSpecial, "KCapsBpsSpecial");
134 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableRate[] =
136 // Enum as a descriptor Enum
137 KStrKCapsBps50, KCapsBps50,
138 KStrKCapsBps75, KCapsBps75,
139 KStrKCapsBps110, KCapsBps110,
140 KStrKCapsBps134, KCapsBps134,
141 KStrKCapsBps150, KCapsBps150,
142 KStrKCapsBps300, KCapsBps300,
143 KStrKCapsBps600, KCapsBps600,
144 KStrKCapsBps1200, KCapsBps1200,
145 KStrKCapsBps1800, KCapsBps1800,
146 KStrKCapsBps2000, KCapsBps2000,
147 KStrKCapsBps2400, KCapsBps2400,
148 KStrKCapsBps3600, KCapsBps3600,
149 KStrKCapsBps4800, KCapsBps4800,
150 KStrKCapsBps7200, KCapsBps7200,
151 KStrKCapsBps9600, KCapsBps9600,
152 KStrKCapsBps19200, KCapsBps19200,
153 KStrKCapsBps38400, KCapsBps38400,
154 KStrKCapsBps57600, KCapsBps57600,
155 KStrKCapsBps115200, KCapsBps115200,
156 KStrKCapsBps230400, KCapsBps230400,
157 KStrKCapsBps460800, KCapsBps460800,
158 KStrKCapsBps576000, KCapsBps576000,
159 KStrKCapsBps1152000, KCapsBps1152000,
160 KStrKCapsBps4000000, KCapsBps4000000,
161 KStrKCapsBps921600, KCapsBps921600,
162 KStrKCapsBpsAutobaud, KCapsBpsAutobaud,
163 KStrKCapsBpsSpecial, KCapsBpsSpecial,
167 _LIT(KStrKCapsSIR115kbps, "KCapsSIR115kbps");
168 _LIT(KStrKCapsSIR2400bpsOnly, "KCapsSIR2400bpsOnly");
169 _LIT(KStrKCapsSIR4Mbs, "KCapsSIR4Mbs");
170 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableSir[] =
172 // Enum as a descriptor Enum
173 KStrKCapsSIR115kbps, KCapsSIR115kbps,
174 KStrKCapsSIR2400bpsOnly, KCapsSIR2400bpsOnly,
175 KStrKCapsSIR4Mbs, KCapsSIR4Mbs,
179 _LIT(KStrKCapsSignalCTSSupported, "KCapsSignalCTSSupported");
180 _LIT(KStrKCapsSignalDSRSupported, "KCapsSignalDSRSupported");
181 _LIT(KStrKCapsSignalDCDSupported, "KCapsSignalDCDSupported");
182 _LIT(KStrKCapsSignalRNGSupported, "KCapsSignalRNGSupported");
183 _LIT(KStrKCapsSignalRTSSupported, "KCapsSignalRTSSupported");
184 _LIT(KStrKCapsSignalDTRSupported, "KCapsSignalDTRSupported");
185 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableSignals[] =
187 // Enum as a descriptor Enum
188 KStrKCapsSignalCTSSupported, KCapsSignalCTSSupported,
189 KStrKCapsSignalDSRSupported, KCapsSignalDSRSupported,
190 KStrKCapsSignalDCDSupported, KCapsSignalDCDSupported,
191 KStrKCapsSignalRNGSupported, KCapsSignalRNGSupported,
192 KStrKCapsSignalRTSSupported, KCapsSignalRTSSupported,
193 KStrKCapsSignalDTRSupported, KCapsSignalDTRSupported,
197 _LIT(KStrKCapsStop1, "KCapsStop1");
198 _LIT(KStrKCapsStop2, "KCapsStop2");
199 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableStopBits[] =
201 // Enum as a descriptor Enum
202 KStrKCapsStop1, KCapsStop1,
203 KStrKCapsStop2, KCapsStop2,
207 //////////////////////////////////////////////////////////////////////
208 // Construction/Destruction
209 //////////////////////////////////////////////////////////////////////
211 CT_TCommCapsV01Data::CT_TCommCapsV01Data()
217 CT_TCommCapsV01Data::~CT_TCommCapsV01Data()
225 void CT_TCommCapsV01Data::DestroyData()
231 TDes8* CT_TCommCapsV01Data::Descriptor()
233 * Return a pointer to the buffer
235 * @return pointer to the buffer
241 TAny* CT_TCommCapsV01Data::GetObject()
243 * Return a pointer to the object that the data wraps
245 * @return pointer to the object that the data wraps
251 TBool CT_TCommCapsV01Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
253 * Process a command read from the ini file
255 * @param aCommand The command to process
256 * @param aSection The section in the ini containing data for the command
257 * @param aAsyncErrorIndex Command index for async calls to return errors to
259 * @return ETrue if the command is processed
261 * @leave System wide error
267 if ( aCommand==KCmdConstructor )
269 err=DoCmdConstructor();
271 else if ( aCommand==KCmdDestructor )
275 else if ( aCommand==KCmdiDataBits )
277 DoCmdiDataBits(aSection);
279 else if ( aCommand==KCmdiFifo )
281 DoCmdiFifo(aSection);
283 else if ( aCommand==KCmdiHandshake )
285 DoCmdiHandshake(aSection);
287 else if ( aCommand==KCmdiParity )
289 DoCmdiParity(aSection);
291 else if ( aCommand==KCmdiRate )
293 DoCmdiRate(aSection);
295 else if ( aCommand==KCmdiSIR )
299 else if ( aCommand==KCmdiSignals )
301 DoCmdiSignals(aSection);
303 else if ( aCommand==KCmdiStopBits )
305 DoCmdiStopBits(aSection);
309 ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
314 ERR_PRINTF2(KLogError, err);
321 TCommCapsV01& CT_TCommCapsV01Data::GetCommCapsV01()
323 return (*iCommCaps)();
326 TInt CT_TCommCapsV01Data::DoCmdConstructor()
329 TRAPD(err, iCommCaps=new (ELeave) TCommCaps());
334 void CT_TCommCapsV01Data::DoCmdDestructor()
339 void CT_TCommCapsV01Data::DoCmdiDataBits(const TDesC& aSection)
341 TUint actual=GetCommCapsV01().iDataBits;
342 INFO_PRINTF2(_L("iDataBits : 0x%X"), actual);
345 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableDataBits, expected) )
347 if ( expected!=actual )
349 ERR_PRINTF1(_L("Expected Value does not match actual"));
350 SetBlockResult(EFail);
355 void CT_TCommCapsV01Data::DoCmdiFifo(const TDesC& aSection)
357 TUint actual=GetCommCapsV01().iFifo;
358 INFO_PRINTF2(_L("iFifo : 0x%X"), actual);
361 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableFifo, expected) )
363 if ( expected!=actual )
365 ERR_PRINTF1(_L("Expected Value does not match actual"));
366 SetBlockResult(EFail);
371 void CT_TCommCapsV01Data::DoCmdiHandshake(const TDesC& aSection)
373 TUint actual=GetCommCapsV01().iHandshake;
374 INFO_PRINTF2(_L("iHandshake : 0x%X"), actual);
377 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableHandshake, expected) )
379 if ( expected!=actual )
381 ERR_PRINTF1(_L("Expected Value does not match actual"));
382 SetBlockResult(EFail);
387 void CT_TCommCapsV01Data::DoCmdiParity(const TDesC& aSection)
389 TUint actual=GetCommCapsV01().iParity;
390 INFO_PRINTF2(_L("iParity : 0x%X"), actual);
393 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableParity, expected) )
395 if ( expected!=actual )
397 ERR_PRINTF1(_L("Expected Value does not match actual"));
398 SetBlockResult(EFail);
403 void CT_TCommCapsV01Data::DoCmdiRate(const TDesC& aSection)
405 TUint actual=GetCommCapsV01().iRate;
406 INFO_PRINTF2(_L("iRate : 0x%X"), actual);
409 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableRate, expected) )
411 if ( expected!=actual )
413 ERR_PRINTF1(_L("Expected Value does not match actual"));
414 SetBlockResult(EFail);
419 void CT_TCommCapsV01Data::DoCmdiSIR(const TDesC& aSection)
421 TUint actual=GetCommCapsV01().iSIR;
422 INFO_PRINTF2(_L("iSIR : 0x%X"), actual);
425 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableSir, expected) )
427 if ( expected!=actual )
429 ERR_PRINTF1(_L("Expected Value does not match actual"));
430 SetBlockResult(EFail);
435 void CT_TCommCapsV01Data::DoCmdiSignals(const TDesC& aSection)
437 TUint actual=GetCommCapsV01().iSignals;
438 INFO_PRINTF2(_L("iSignals : 0x%X"), actual);
441 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableSignals, expected) )
443 if ( expected!=actual )
445 ERR_PRINTF1(_L("Expected Value does not match actual"));
446 SetBlockResult(EFail);
451 void CT_TCommCapsV01Data::DoCmdiStopBits(const TDesC& aSection)
453 TUint actual=GetCommCapsV01().iStopBits;
454 INFO_PRINTF2(_L("iStopBits : 0x%X"), actual);
457 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableStopBits, expected) )
459 if ( expected!=actual )
461 ERR_PRINTF1(_L("Expected Value does not match actual"));
462 SetBlockResult(EFail);