Update contrib.
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_TCommConfigV01Data.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(KCmdiParityError, "iParityError");
30 _LIT(KCmdiParityErrorChar, "iParityErrorChar");
31 _LIT(KCmdiRate, "iRate");
32 _LIT(KCmdiSIREnable, "iSIREnable");
33 _LIT(KCmdiSIRSettings, "iSIRSettings");
34 _LIT(KCmdiSpecialRate, "iSpecialRate");
35 _LIT(KCmdiStopBits, "iStopBits");
36 _LIT(KCmdiTerminator, "iTerminator");
37 _LIT(KCmdiTerminatorCount, "iTerminatorCount");
38 _LIT(KCmdiXoffChar, "iXoffChar");
39 _LIT(KCmdiXonChar, "iXonChar");
41 _LIT(KFldExpected, "expected");
42 _LIT(KFldExpectedIndex, "expected%d");
43 _LIT(KFldValue, "value");
44 _LIT(KFldValueIndex, "value%d");
46 _LIT(KLogError, "Error=%d");
47 _LIT(KLogErrorExpectedValue, "Expected Value does not match actual");
50 _LIT(KStrEData5, "EData5");
51 _LIT(KStrEData6, "EData6");
52 _LIT(KStrEData7, "EData7");
53 _LIT(KStrEData8, "EData8");
54 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableDataBits[] =
56 // Enum as a descriptor Enum
64 _LIT(KStrEFifoEnable, "EFifoEnable");
65 _LIT(KStrEFifoDisable, "KStrEFifoDisable");
66 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableFifo[] =
68 // Enum as a descriptor Enum
69 KStrEFifoEnable, EFifoEnable,
70 KStrEFifoDisable, EFifoDisable,
74 _LIT(KStrKConfigObeyXoff, "KConfigObeyXoff");
75 _LIT(KStrKConfigSendXoff, "KConfigSendXoff");
76 _LIT(KStrKConfigObeyCTS, "KConfigObeyCTS");
77 _LIT(KStrKConfigFailCTS, "KConfigFailCTS");
78 _LIT(KStrKConfigObeyDSR, "KConfigObeyDSR");
79 _LIT(KStrKConfigFailDSR, "KConfigFailDSR");
80 _LIT(KStrKConfigObeyDCD, "KConfigObeyDCD");
81 _LIT(KStrKConfigFailDCD, "KConfigFailDCD");
82 _LIT(KStrKConfigFreeRTS, "KConfigFreeRTS");
83 _LIT(KStrKConfigFreeDTR, "KConfigFreeDTR");
84 _LIT(KStrKConfigObeyDTR, "KConfigObeyDTR");
85 _LIT(KStrKConfigFailDTR, "KConfigFailDTR");
86 _LIT(KStrKConfigObeyRTS, "KConfigObeyRTS");
87 _LIT(KStrKConfigFailRTS, "KConfigFailRTS");
88 _LIT(KStrKConfigFreeDSR, "KConfigFreeDSR");
89 _LIT(KStrKConfigFreeCTS, "KConfigFreeCTS");
90 _LIT(KStrKConfigFreeDCD, "KConfigFreeDCD");
91 _LIT(KStrKConfigFreeRI, "KConfigFreeRI");
92 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableHandshake[] =
94 // Enum as a descriptor Enum
95 KStrKConfigObeyXoff, KConfigObeyXoff,
96 KStrKConfigSendXoff, KConfigSendXoff,
97 KStrKConfigObeyCTS, KConfigObeyCTS,
98 KStrKConfigFailCTS, KConfigFailCTS,
99 KStrKConfigObeyDSR, KConfigObeyDSR,
100 KStrKConfigFailDSR, KConfigFailDSR,
101 KStrKConfigObeyDCD, KConfigObeyDCD,
102 KStrKConfigFailDCD, KConfigFailDCD,
103 KStrKConfigFreeRTS, KConfigFreeRTS,
104 KStrKConfigFreeDTR, KConfigFreeDTR,
105 KStrKConfigObeyDTR, KConfigObeyDTR,
106 KStrKConfigFailDTR, KConfigFailDTR,
107 KStrKConfigObeyRTS, KConfigObeyRTS,
108 KStrKConfigFailRTS, KConfigFailRTS,
109 KStrKConfigFreeDSR, KConfigFreeDSR,
110 KStrKConfigFreeCTS, KConfigFreeCTS,
111 KStrKConfigFreeDCD, KConfigFreeDCD,
112 KStrKConfigFreeRI, KConfigFreeRI,
116 _LIT(KStrEParityNone, "EParityNone");
117 _LIT(KStrEParityEven, "EParityEven");
118 _LIT(KStrEParityOdd, "EParityOdd");
119 _LIT(KStrEParityMark, "EParityMark");
120 _LIT(KStrEParitySpace, "EParitySpace");
121 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableParity[] =
123 // Enum as a descriptor Enum
124 KStrEParityNone, EParityNone,
125 KStrEParityEven, EParityEven,
126 KStrEParityOdd, EParityOdd,
127 KStrEParityMark, EParityMark,
128 KStrEParitySpace, EParitySpace,
132 _LIT(KStrKConfigParityErrorFail, "KConfigParityErrorFail");
133 _LIT(KStrKConfigParityErrorIgnore, "KConfigParityErrorIgnore");
134 _LIT(KStrKConfigParityErrorReplaceChar, "KConfigParityErrorReplaceChar");
135 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableParityError[] =
137 // Enum as a descriptor Enum
138 KStrKConfigParityErrorFail, KConfigParityErrorFail,
139 KStrKConfigParityErrorIgnore, KConfigParityErrorIgnore,
140 KStrKConfigParityErrorReplaceChar, KConfigParityErrorReplaceChar,
144 _LIT(KStrEBps50, "EBps50");
145 _LIT(KStrEBps75, "EBps75");
146 _LIT(KStrEBps110, "EBps110");
147 _LIT(KStrEBps134, "EBps134");
148 _LIT(KStrEBps150, "EBps150");
149 _LIT(KStrEBps300, "EBps300");
150 _LIT(KStrEBps600, "EBps600");
151 _LIT(KStrEBps1200, "EBps1200");
152 _LIT(KStrEBps1800, "EBps1800");
153 _LIT(KStrEBps2000, "EBps2000");
154 _LIT(KStrEBps2400, "EBps2400");
155 _LIT(KStrEBps3600, "EBps3600");
156 _LIT(KStrEBps4800, "EBps4800");
157 _LIT(KStrEBps7200, "EBps7200");
158 _LIT(KStrEBps9600, "EBps9600");
159 _LIT(KStrEBps19200, "EBps19200");
160 _LIT(KStrEBps38400, "EBps38400");
161 _LIT(KStrEBps57600, "EBps57600");
162 _LIT(KStrEBps115200, "EBps115200");
163 _LIT(KStrEBps230400, "EBps230400");
164 _LIT(KStrEBps460800, "EBps460800");
165 _LIT(KStrEBps576000, "EBps576000");
166 _LIT(KStrEBps1152000, "EBps1152000");
167 _LIT(KStrEBps4000000, "EBps4000000");
168 _LIT(KStrEBps921600, "EBps921600");
169 _LIT(KStrEBpsAutobaud, "EBpsAutobaud");
170 _LIT(KStrEBpsSpecial, "EBpsSpecial");
171 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableRate[] =
173 // Enum as a descriptor Enum
176 KStrEBps110, EBps110,
177 KStrEBps134, EBps134,
178 KStrEBps150, EBps150,
179 KStrEBps300, EBps300,
180 KStrEBps600, EBps600,
181 KStrEBps1200, EBps1200,
182 KStrEBps1800, EBps1800,
183 KStrEBps2000, EBps2000,
184 KStrEBps2400, EBps2400,
185 KStrEBps3600, EBps3600,
186 KStrEBps4800, EBps4800,
187 KStrEBps7200, EBps7200,
188 KStrEBps9600, EBps9600,
189 KStrEBps19200, EBps19200,
190 KStrEBps38400, EBps38400,
191 KStrEBps57600, EBps57600,
192 KStrEBps115200, EBps115200,
193 KStrEBps230400, EBps230400,
194 KStrEBps460800, EBps460800,
195 KStrEBps576000, EBps576000,
196 KStrEBps1152000, EBps1152000,
197 KStrEBps4000000, EBps4000000,
198 KStrEBps921600, EBps921600,
199 KStrEBpsAutobaud, EBpsAutobaud,
200 KStrEBpsSpecial, EBpsSpecial,
204 _LIT(KStrESIREnable, "ESIREnable");
205 _LIT(KStrESIRDisable, "ESIRDisable");
206 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableSir[] =
208 // Enum as a descriptor Enum
209 KStrESIREnable, ESIREnable,
210 KStrESIRDisable, ESIRDisable,
214 _LIT(KStrKConfigSIRPulseWidthMaximum, "KConfigSIRPulseWidthMaximum");
215 _LIT(KStrKConfigSIRPulseWidthMinimum, "KConfigSIRPulseWidthMinimum");
216 _LIT(KStrKConfigSIRShutDown, "KConfigSIRShutDown");
217 _LIT(KStrKConfigSIRMinimumRange, "KConfigSIRMinimumRange");
218 _LIT(KStrKConfigSIRMediumRange, "KConfigSIRMediumRange");
219 _LIT(KStrKConfigSIRMaximumRange, "KConfigSIRMaximumRange");
220 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableSirSetting[] =
222 // Enum as a descriptor Enum
223 KStrKConfigSIRPulseWidthMaximum, KConfigSIRPulseWidthMaximum,
224 KStrKConfigSIRPulseWidthMinimum, KConfigSIRPulseWidthMinimum,
225 KStrKConfigSIRShutDown, KConfigSIRShutDown,
226 KStrKConfigSIRMinimumRange, KConfigSIRMinimumRange,
227 KStrKConfigSIRMediumRange, KConfigSIRMediumRange,
228 KStrKConfigSIRMaximumRange, KConfigSIRMaximumRange,
232 _LIT(KStrEStop1, "EStop1");
233 _LIT(KStrEStop2, "EStop2");
234 const CDataWrapperBase::TEnumEntryTable CT_TCommConfigV01Data::iEnumTableStopBits[] =
236 // Enum as a descriptor Enum
242 //////////////////////////////////////////////////////////////////////
243 // Construction/Destruction
244 //////////////////////////////////////////////////////////////////////
246 CT_TCommConfigV01Data::CT_TCommConfigV01Data()
252 CT_TCommConfigV01Data::~CT_TCommConfigV01Data()
260 void CT_TCommConfigV01Data::DestroyData()
266 TDes8* CT_TCommConfigV01Data::Descriptor()
268 * Return a pointer to the buffer
270 * @return pointer to the buffer
276 TAny* CT_TCommConfigV01Data::GetObject()
278 * Return a pointer to the object that the data wraps
280 * @return pointer to the object that the data wraps
286 TBool CT_TCommConfigV01Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
288 * Process a command read from the ini file
290 * @param aCommand The command to process
291 * @param aSection The section in the ini containing data for the command
292 * @param aAsyncErrorIndex Command index for async calls to return errors to
294 * @return ETrue if the command is processed
296 * @leave System wide error
302 if ( aCommand==KCmdConstructor )
304 err=DoCmdConstructor();
306 else if ( aCommand==KCmdDestructor )
310 else if ( aCommand==KCmdiDataBits )
312 DoCmdiDataBits(aSection);
314 else if ( aCommand==KCmdiFifo )
316 DoCmdiFifo(aSection);
318 else if ( aCommand==KCmdiHandshake )
320 DoCmdiHandshake(aSection);
322 else if ( aCommand==KCmdiParity )
324 DoCmdiParity(aSection);
326 else if ( aCommand==KCmdiParityError )
328 DoCmdiParityError(aSection);
330 else if ( aCommand==KCmdiParityErrorChar )
332 DoCmdiParityErrorChar(aSection);
334 else if ( aCommand==KCmdiRate )
336 DoCmdiRate(aSection);
338 else if ( aCommand==KCmdiSIREnable )
340 DoCmdiSIREnable(aSection);
342 else if ( aCommand==KCmdiSIRSettings )
344 DoCmdiSIRSettings(aSection);
346 else if ( aCommand==KCmdiSpecialRate )
348 DoCmdiSpecialRate(aSection);
350 else if ( aCommand==KCmdiStopBits )
352 DoCmdiStopBits(aSection);
354 else if ( aCommand==KCmdiTerminator )
356 DoCmdiTerminator(aSection);
358 else if ( aCommand==KCmdiTerminatorCount )
360 DoCmdiTerminatorCount(aSection);
362 else if ( aCommand==KCmdiXoffChar )
364 DoCmdiXoffChar(aSection);
366 else if ( aCommand==KCmdiXonChar )
368 DoCmdiXonChar(aSection);
372 ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
377 ERR_PRINTF2(KLogError, err);
384 TCommConfigV01& CT_TCommConfigV01Data::GetCommConfigV01()
386 return (*iCommConfig)();
389 TInt CT_TCommConfigV01Data::DoCmdConstructor()
392 TRAPD(err, iCommConfig=new (ELeave) TCommConfig());
393 iCommConfig->FillZ();
397 void CT_TCommConfigV01Data::DoCmdDestructor()
402 void CT_TCommConfigV01Data::DoCmdiDataBits(const TDesC& aSection)
404 TDataBits actual=GetCommConfigV01().iDataBits;
405 INFO_PRINTF2(_L("iDataBits : %d"), actual);
408 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableDataBits, expected) )
410 if ( expected!=actual )
412 ERR_PRINTF1(KLogErrorExpectedValue);
413 SetBlockResult(EFail);
418 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableDataBits, value) )
420 GetCommConfigV01().iDataBits=(TDataBits)value;
424 void CT_TCommConfigV01Data::DoCmdiFifo(const TDesC& aSection)
426 TFifo actual=(TFifo)GetCommConfigV01().iFifo;
427 INFO_PRINTF2(_L("iFifo : %d"), actual);
430 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableFifo, expected) )
432 if ( expected!=actual )
434 ERR_PRINTF1(KLogErrorExpectedValue);
435 SetBlockResult(EFail);
440 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableFifo, value) )
442 GetCommConfigV01().iFifo=(TUint)value;
446 void CT_TCommConfigV01Data::DoCmdiHandshake(const TDesC& aSection)
448 TUint actual=GetCommConfigV01().iHandshake;
449 INFO_PRINTF2(_L("iHandshake : %d"), actual);
452 if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableHandshake, expected) )
454 if ( expected!=actual )
456 ERR_PRINTF1(KLogErrorExpectedValue);
457 SetBlockResult(EFail);
462 if ( GetOrFromConfig(aSection, KFldValue(), iEnumTableHandshake, value) )
464 GetCommConfigV01().iHandshake=value;
468 void CT_TCommConfigV01Data::DoCmdiParity(const TDesC& aSection)
470 TParity actual=GetCommConfigV01().iParity;
471 INFO_PRINTF2(_L("iParity : %d"), actual);
474 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableParity, expected) )
476 if ( expected!=actual )
478 ERR_PRINTF1(KLogErrorExpectedValue);
479 SetBlockResult(EFail);
484 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableParity, value) )
486 GetCommConfigV01().iParity=(TParity)value;
490 void CT_TCommConfigV01Data::DoCmdiParityError(const TDesC& aSection)
492 TUint actual=GetCommConfigV01().iParityError;
493 INFO_PRINTF2(_L("iParityError : %d"), actual);
496 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableParityError, expected) )
498 if ( expected!=(TInt)actual )
500 ERR_PRINTF1(KLogErrorExpectedValue);
501 SetBlockResult(EFail);
506 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableParityError, value) )
508 GetCommConfigV01().iParityError=(TUint)value;
512 void CT_TCommConfigV01Data::DoCmdiParityErrorChar(const TDesC& aSection)
514 TText8 actual=GetCommConfigV01().iParityErrorChar;
515 INFO_PRINTF2(_L("iParityErrorChar : 0x%x"), (TUint)actual);
518 if ( GetHexFromConfig(aSection, KFldExpected(), expected) )
520 if ( expected!=(TInt)actual )
522 ERR_PRINTF1(KLogErrorExpectedValue);
523 SetBlockResult(EFail);
528 if ( GetHexFromConfig(aSection, KFldValue(), value) )
530 GetCommConfigV01().iParityErrorChar=(TText8)value;
534 void CT_TCommConfigV01Data::DoCmdiRate(const TDesC& aSection)
536 TBps actual=GetCommConfigV01().iRate;
537 INFO_PRINTF2(_L("iRate : %d"), actual);
540 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableRate, expected) )
542 if ( expected!=(TInt)actual )
544 ERR_PRINTF1(KLogErrorExpectedValue);
545 SetBlockResult(EFail);
550 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableRate, value) )
552 GetCommConfigV01().iRate=(TBps)value;
556 void CT_TCommConfigV01Data::DoCmdiSIREnable(const TDesC& aSection)
558 TSir actual=GetCommConfigV01().iSIREnable;
559 INFO_PRINTF2(_L("iSIREnable : %d"), actual);
562 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableSir, expected) )
564 if ( expected!=(TInt)actual )
566 ERR_PRINTF1(KLogErrorExpectedValue);
567 SetBlockResult(EFail);
572 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableSir, value) )
574 GetCommConfigV01().iSIREnable=(TSir)value;
578 void CT_TCommConfigV01Data::DoCmdiSIRSettings(const TDesC& aSection)
580 TUint actual=GetCommConfigV01().iSIRSettings;
581 INFO_PRINTF2(_L("iSIRSettings : %d"), actual);
584 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableSirSetting, expected) )
586 if ( expected!=(TInt)actual )
588 ERR_PRINTF1(KLogErrorExpectedValue);
589 SetBlockResult(EFail);
594 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableSirSetting, value) )
596 GetCommConfigV01().iSIRSettings=(TUint)value;
600 void CT_TCommConfigV01Data::DoCmdiSpecialRate(const TDesC& aSection)
602 TInt actual=GetCommConfigV01().iSpecialRate;
603 INFO_PRINTF2(_L("iSpecialRate : %d"), actual);
606 if ( GetIntFromConfig(aSection, KFldExpected(), expected) )
608 if ( expected!=actual )
610 ERR_PRINTF1(KLogErrorExpectedValue);
611 SetBlockResult(EFail);
616 if ( GetIntFromConfig(aSection, KFldValue(), value) )
618 GetCommConfigV01().iSpecialRate=value;
622 void CT_TCommConfigV01Data::DoCmdiStopBits(const TDesC& aSection)
624 TStopBits actual=GetCommConfigV01().iStopBits;
625 INFO_PRINTF2(_L("iStopBits : %d"), actual);
628 if ( GetEnumFromConfig(aSection, KFldExpected(), iEnumTableStopBits, expected) )
630 if ( expected!=actual )
632 ERR_PRINTF1(KLogErrorExpectedValue);
633 SetBlockResult(EFail);
638 if ( GetEnumFromConfig(aSection, KFldValue(), iEnumTableStopBits, value) )
640 GetCommConfigV01().iStopBits=(TStopBits)value;
644 void CT_TCommConfigV01Data::DoCmdiTerminator(const TDesC& aSection)
646 TBuf<KMaxTestExecuteCommandLength> tempStore;
648 for ( TInt index=0; index<KConfigMaxTerminators; ++index )
650 TText8 actual=GetCommConfigV01().iTerminator[index];
651 INFO_PRINTF3(_L("iTerminator[%d] : 0x%x"), index, (TUint)actual);
653 tempStore.Format(KFldExpectedIndex(), index);
655 if ( GetHexFromConfig(aSection, tempStore, expected) )
657 if ( expected!=(TInt)actual )
659 ERR_PRINTF1(KLogErrorExpectedValue);
660 SetBlockResult(EFail);
664 tempStore.Format(KFldValueIndex(), index);
666 if ( GetHexFromConfig(aSection, tempStore, value) )
668 GetCommConfigV01().iTerminator[index]=(TText8)value;
673 void CT_TCommConfigV01Data::DoCmdiTerminatorCount(const TDesC& aSection)
675 TInt actual=GetCommConfigV01().iTerminatorCount;
676 INFO_PRINTF2(_L("iTerminatorCount : %d"), actual);
679 if ( GetIntFromConfig(aSection, KFldExpected(), expected) )
681 if ( expected!=actual )
683 ERR_PRINTF1(KLogErrorExpectedValue);
684 SetBlockResult(EFail);
689 if ( GetIntFromConfig(aSection, KFldValue(), value) )
691 GetCommConfigV01().iTerminatorCount=value;
695 void CT_TCommConfigV01Data::DoCmdiXoffChar(const TDesC& aSection)
697 TText8 actual=GetCommConfigV01().iXoffChar;
698 INFO_PRINTF2(_L("iXoffChar : 0x%x"), (TUint)actual);
701 if ( GetHexFromConfig(aSection, KFldExpected(), expected) )
703 if ( expected!=(TInt)actual )
705 ERR_PRINTF1(KLogErrorExpectedValue);
706 SetBlockResult(EFail);
711 if ( GetHexFromConfig(aSection, KFldValue(), value) )
713 GetCommConfigV01().iXoffChar=(TText8)value;
717 void CT_TCommConfigV01Data::DoCmdiXonChar(const TDesC& aSection)
719 TText8 actual=GetCommConfigV01().iXonChar;
720 INFO_PRINTF2(_L("iXonChar : 0x%x"), (TUint)actual);
723 if ( GetHexFromConfig(aSection, KFldExpected(), expected) )
725 if ( expected!=(TInt)actual )
727 ERR_PRINTF1(KLogErrorExpectedValue);
728 SetBlockResult(EFail);
733 if ( GetHexFromConfig(aSection, KFldValue(), value) )
735 GetCommConfigV01().iXonChar=(TText8)value;