|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "T_TCommCapsV01Data.h" |
|
19 |
|
20 /*@{*/ |
|
21 _LIT(KStrNull, " "); |
|
22 |
|
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"); |
|
33 |
|
34 _LIT(KFldExpected, "expected"); |
|
35 |
|
36 _LIT(KLogError, "Error=%d"); |
|
37 /*@}*/ |
|
38 |
|
39 _LIT(KStrKCapsData5, "KCapsData5"); |
|
40 _LIT(KStrKCapsData6, "KCapsData6"); |
|
41 _LIT(KStrKCapsData7, "KCapsData7"); |
|
42 _LIT(KStrKCapsData8, "KCapsData8"); |
|
43 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableDataBits[] = |
|
44 { |
|
45 // Enum as a descriptor Enum |
|
46 KStrKCapsData5, KCapsData5, |
|
47 KStrKCapsData6, KCapsData6, |
|
48 KStrKCapsData7, KCapsData7, |
|
49 KStrKCapsData8, KCapsData8, |
|
50 KStrNull, -1 |
|
51 }; |
|
52 |
|
53 _LIT(KStrKCapsHasFifo, "KCapsHasFifo"); |
|
54 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableFifo[] = |
|
55 { |
|
56 // Enum as a descriptor Enum |
|
57 KStrKCapsHasFifo, KCapsHasFifo, |
|
58 KStrNull, -1 |
|
59 }; |
|
60 |
|
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[] = |
|
74 { |
|
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, |
|
88 KStrNull, -1 |
|
89 }; |
|
90 |
|
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[] = |
|
97 { |
|
98 // Enum as a descriptor Enum |
|
99 KStrKCapsParityNone, KCapsParityNone, |
|
100 KStrKCapsParityEven, KCapsParityEven, |
|
101 KStrKCapsParityOdd, KCapsParityOdd, |
|
102 KStrKCapsParityMark, KCapsParityMark, |
|
103 KStrKCapsParitySpace, KCapsParitySpace, |
|
104 KStrNull, -1 |
|
105 }; |
|
106 |
|
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[] = |
|
135 { |
|
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, |
|
164 KStrNull, -1 |
|
165 }; |
|
166 |
|
167 _LIT(KStrKCapsSIR115kbps, "KCapsSIR115kbps"); |
|
168 _LIT(KStrKCapsSIR2400bpsOnly, "KCapsSIR2400bpsOnly"); |
|
169 _LIT(KStrKCapsSIR4Mbs, "KCapsSIR4Mbs"); |
|
170 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableSir[] = |
|
171 { |
|
172 // Enum as a descriptor Enum |
|
173 KStrKCapsSIR115kbps, KCapsSIR115kbps, |
|
174 KStrKCapsSIR2400bpsOnly, KCapsSIR2400bpsOnly, |
|
175 KStrKCapsSIR4Mbs, KCapsSIR4Mbs, |
|
176 KStrNull, -1 |
|
177 }; |
|
178 |
|
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[] = |
|
186 { |
|
187 // Enum as a descriptor Enum |
|
188 KStrKCapsSignalCTSSupported, KCapsSignalCTSSupported, |
|
189 KStrKCapsSignalDSRSupported, KCapsSignalDSRSupported, |
|
190 KStrKCapsSignalDCDSupported, KCapsSignalDCDSupported, |
|
191 KStrKCapsSignalRNGSupported, KCapsSignalRNGSupported, |
|
192 KStrKCapsSignalRTSSupported, KCapsSignalRTSSupported, |
|
193 KStrKCapsSignalDTRSupported, KCapsSignalDTRSupported, |
|
194 KStrNull, -1 |
|
195 }; |
|
196 |
|
197 _LIT(KStrKCapsStop1, "KCapsStop1"); |
|
198 _LIT(KStrKCapsStop2, "KCapsStop2"); |
|
199 const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableStopBits[] = |
|
200 { |
|
201 // Enum as a descriptor Enum |
|
202 KStrKCapsStop1, KCapsStop1, |
|
203 KStrKCapsStop2, KCapsStop2, |
|
204 KStrNull, -1 |
|
205 }; |
|
206 |
|
207 ////////////////////////////////////////////////////////////////////// |
|
208 // Construction/Destruction |
|
209 ////////////////////////////////////////////////////////////////////// |
|
210 |
|
211 CT_TCommCapsV01Data::CT_TCommCapsV01Data() |
|
212 : CDataWrapperBase() |
|
213 , iCommCaps(NULL) |
|
214 { |
|
215 } |
|
216 |
|
217 CT_TCommCapsV01Data::~CT_TCommCapsV01Data() |
|
218 /** |
|
219 * Public destructor |
|
220 */ |
|
221 { |
|
222 DestroyData(); |
|
223 } |
|
224 |
|
225 void CT_TCommCapsV01Data::DestroyData() |
|
226 { |
|
227 delete iCommCaps; |
|
228 iCommCaps=NULL; |
|
229 } |
|
230 |
|
231 TDes8* CT_TCommCapsV01Data::Descriptor() |
|
232 /** |
|
233 * Return a pointer to the buffer |
|
234 * |
|
235 * @return pointer to the buffer |
|
236 */ |
|
237 { |
|
238 return iCommCaps; |
|
239 } |
|
240 |
|
241 TAny* CT_TCommCapsV01Data::GetObject() |
|
242 /** |
|
243 * Return a pointer to the object that the data wraps |
|
244 * |
|
245 * @return pointer to the object that the data wraps |
|
246 */ |
|
247 { |
|
248 return iCommCaps; |
|
249 } |
|
250 |
|
251 TBool CT_TCommCapsV01Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
252 /** |
|
253 * Process a command read from the ini file |
|
254 * |
|
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 |
|
258 * |
|
259 * @return ETrue if the command is processed |
|
260 * |
|
261 * @leave System wide error |
|
262 */ |
|
263 { |
|
264 TBool ret=ETrue; |
|
265 TInt err=KErrNone; |
|
266 |
|
267 if ( aCommand==KCmdConstructor ) |
|
268 { |
|
269 err=DoCmdConstructor(); |
|
270 } |
|
271 else if ( aCommand==KCmdDestructor ) |
|
272 { |
|
273 DoCmdDestructor(); |
|
274 } |
|
275 else if ( aCommand==KCmdiDataBits ) |
|
276 { |
|
277 DoCmdiDataBits(aSection); |
|
278 } |
|
279 else if ( aCommand==KCmdiFifo ) |
|
280 { |
|
281 DoCmdiFifo(aSection); |
|
282 } |
|
283 else if ( aCommand==KCmdiHandshake ) |
|
284 { |
|
285 DoCmdiHandshake(aSection); |
|
286 } |
|
287 else if ( aCommand==KCmdiParity ) |
|
288 { |
|
289 DoCmdiParity(aSection); |
|
290 } |
|
291 else if ( aCommand==KCmdiRate ) |
|
292 { |
|
293 DoCmdiRate(aSection); |
|
294 } |
|
295 else if ( aCommand==KCmdiSIR ) |
|
296 { |
|
297 DoCmdiSIR(aSection); |
|
298 } |
|
299 else if ( aCommand==KCmdiSignals ) |
|
300 { |
|
301 DoCmdiSignals(aSection); |
|
302 } |
|
303 else if ( aCommand==KCmdiStopBits ) |
|
304 { |
|
305 DoCmdiStopBits(aSection); |
|
306 } |
|
307 else |
|
308 { |
|
309 ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
310 } |
|
311 |
|
312 if ( err!=KErrNone ) |
|
313 { |
|
314 ERR_PRINTF2(KLogError, err); |
|
315 SetError(err); |
|
316 } |
|
317 |
|
318 return ret; |
|
319 } |
|
320 |
|
321 TCommCapsV01& CT_TCommCapsV01Data::GetCommCapsV01() |
|
322 { |
|
323 return (*iCommCaps)(); |
|
324 } |
|
325 |
|
326 TInt CT_TCommCapsV01Data::DoCmdConstructor() |
|
327 { |
|
328 DestroyData(); |
|
329 TRAPD(err, iCommCaps=new (ELeave) TCommCaps()); |
|
330 iCommCaps->FillZ(); |
|
331 return err; |
|
332 } |
|
333 |
|
334 void CT_TCommCapsV01Data::DoCmdDestructor() |
|
335 { |
|
336 DestroyData(); |
|
337 } |
|
338 |
|
339 void CT_TCommCapsV01Data::DoCmdiDataBits(const TDesC& aSection) |
|
340 { |
|
341 TUint actual=GetCommCapsV01().iDataBits; |
|
342 INFO_PRINTF2(_L("iDataBits : 0x%X"), actual); |
|
343 |
|
344 TUint expected; |
|
345 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableDataBits, expected) ) |
|
346 { |
|
347 if ( expected!=actual ) |
|
348 { |
|
349 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
350 SetBlockResult(EFail); |
|
351 } |
|
352 } |
|
353 } |
|
354 |
|
355 void CT_TCommCapsV01Data::DoCmdiFifo(const TDesC& aSection) |
|
356 { |
|
357 TUint actual=GetCommCapsV01().iFifo; |
|
358 INFO_PRINTF2(_L("iFifo : 0x%X"), actual); |
|
359 |
|
360 TUint expected; |
|
361 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableFifo, expected) ) |
|
362 { |
|
363 if ( expected!=actual ) |
|
364 { |
|
365 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
366 SetBlockResult(EFail); |
|
367 } |
|
368 } |
|
369 } |
|
370 |
|
371 void CT_TCommCapsV01Data::DoCmdiHandshake(const TDesC& aSection) |
|
372 { |
|
373 TUint actual=GetCommCapsV01().iHandshake; |
|
374 INFO_PRINTF2(_L("iHandshake : 0x%X"), actual); |
|
375 |
|
376 TUint expected; |
|
377 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableHandshake, expected) ) |
|
378 { |
|
379 if ( expected!=actual ) |
|
380 { |
|
381 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
382 SetBlockResult(EFail); |
|
383 } |
|
384 } |
|
385 } |
|
386 |
|
387 void CT_TCommCapsV01Data::DoCmdiParity(const TDesC& aSection) |
|
388 { |
|
389 TUint actual=GetCommCapsV01().iParity; |
|
390 INFO_PRINTF2(_L("iParity : 0x%X"), actual); |
|
391 |
|
392 TUint expected; |
|
393 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableParity, expected) ) |
|
394 { |
|
395 if ( expected!=actual ) |
|
396 { |
|
397 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
398 SetBlockResult(EFail); |
|
399 } |
|
400 } |
|
401 } |
|
402 |
|
403 void CT_TCommCapsV01Data::DoCmdiRate(const TDesC& aSection) |
|
404 { |
|
405 TUint actual=GetCommCapsV01().iRate; |
|
406 INFO_PRINTF2(_L("iRate : 0x%X"), actual); |
|
407 |
|
408 TUint expected; |
|
409 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableRate, expected) ) |
|
410 { |
|
411 if ( expected!=actual ) |
|
412 { |
|
413 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
414 SetBlockResult(EFail); |
|
415 } |
|
416 } |
|
417 } |
|
418 |
|
419 void CT_TCommCapsV01Data::DoCmdiSIR(const TDesC& aSection) |
|
420 { |
|
421 TUint actual=GetCommCapsV01().iSIR; |
|
422 INFO_PRINTF2(_L("iSIR : 0x%X"), actual); |
|
423 |
|
424 TUint expected; |
|
425 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableSir, expected) ) |
|
426 { |
|
427 if ( expected!=actual ) |
|
428 { |
|
429 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
430 SetBlockResult(EFail); |
|
431 } |
|
432 } |
|
433 } |
|
434 |
|
435 void CT_TCommCapsV01Data::DoCmdiSignals(const TDesC& aSection) |
|
436 { |
|
437 TUint actual=GetCommCapsV01().iSignals; |
|
438 INFO_PRINTF2(_L("iSignals : 0x%X"), actual); |
|
439 |
|
440 TUint expected; |
|
441 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableSignals, expected) ) |
|
442 { |
|
443 if ( expected!=actual ) |
|
444 { |
|
445 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
446 SetBlockResult(EFail); |
|
447 } |
|
448 } |
|
449 } |
|
450 |
|
451 void CT_TCommCapsV01Data::DoCmdiStopBits(const TDesC& aSection) |
|
452 { |
|
453 TUint actual=GetCommCapsV01().iStopBits; |
|
454 INFO_PRINTF2(_L("iStopBits : 0x%X"), actual); |
|
455 |
|
456 TUint expected; |
|
457 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableStopBits, expected) ) |
|
458 { |
|
459 if ( expected!=actual ) |
|
460 { |
|
461 ERR_PRINTF1(_L("Expected Value does not match actual")); |
|
462 SetBlockResult(EFail); |
|
463 } |
|
464 } |
|
465 } |