1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/e32/src/T_TCommCapsV01Data.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,465 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +#include "T_TCommCapsV01Data.h"
1.22 +
1.23 +/*@{*/
1.24 +_LIT(KStrNull, " ");
1.25 +
1.26 +_LIT(KCmdConstructor, "new");
1.27 +_LIT(KCmdDestructor, "~");
1.28 +_LIT(KCmdiDataBits, "iDataBits");
1.29 +_LIT(KCmdiFifo, "iFifo");
1.30 +_LIT(KCmdiHandshake, "iHandshake");
1.31 +_LIT(KCmdiParity, "iParity");
1.32 +_LIT(KCmdiRate, "iRate");
1.33 +_LIT(KCmdiSIR, "iSIR");
1.34 +_LIT(KCmdiSignals, "iSignals");
1.35 +_LIT(KCmdiStopBits, "iStopBits");
1.36 +
1.37 +_LIT(KFldExpected, "expected");
1.38 +
1.39 +_LIT(KLogError, "Error=%d");
1.40 +/*@}*/
1.41 +
1.42 +_LIT(KStrKCapsData5, "KCapsData5");
1.43 +_LIT(KStrKCapsData6, "KCapsData6");
1.44 +_LIT(KStrKCapsData7, "KCapsData7");
1.45 +_LIT(KStrKCapsData8, "KCapsData8");
1.46 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableDataBits[] =
1.47 + {
1.48 +// Enum as a descriptor Enum
1.49 + KStrKCapsData5, KCapsData5,
1.50 + KStrKCapsData6, KCapsData6,
1.51 + KStrKCapsData7, KCapsData7,
1.52 + KStrKCapsData8, KCapsData8,
1.53 + KStrNull, -1
1.54 + };
1.55 +
1.56 +_LIT(KStrKCapsHasFifo, "KCapsHasFifo");
1.57 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableFifo[] =
1.58 + {
1.59 +// Enum as a descriptor Enum
1.60 + KStrKCapsHasFifo, KCapsHasFifo,
1.61 + KStrNull, -1
1.62 + };
1.63 +
1.64 +_LIT(KStrKCapsObeyXoffSupported, "KCapsObeyXoffSupported");
1.65 +_LIT(KStrKCapsSendXoffSupported, "KCapsSendXoffSupported");
1.66 +_LIT(KStrKCapsObeyCTSSupported, "KCapsObeyCTSSupported");
1.67 +_LIT(KStrKCapsFailCTSSupported, "KCapsFailCTSSupported");
1.68 +_LIT(KStrKCapsObeyDSRSupported, "KCapsObeyDSRSupported");
1.69 +_LIT(KStrKCapsFailDSRSupported, "KCapsFailDSRSupported");
1.70 +_LIT(KStrKCapsObeyDCDSupported, "KCapsObeyDCDSupported");
1.71 +_LIT(KStrKCapsFailDCDSupported, "KCapsFailDCDSupported");
1.72 +_LIT(KStrKCapsFreeRTSSupported, "KCapsFreeRTSSupported");
1.73 +_LIT(KStrKCapsFreeDTRSupported, "KCapsFreeDTRSupported");
1.74 +_LIT(KStrKCapsObeyDTRSupported, "KCapsObeyDTRSupported");
1.75 +_LIT(KStrKCapsObeyRTSSupported, "KCapsObeyRTSSupported");
1.76 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableHandshake[] =
1.77 + {
1.78 +// Enum as a descriptor Enum
1.79 + KStrKCapsObeyXoffSupported, KCapsObeyXoffSupported,
1.80 + KStrKCapsSendXoffSupported, KCapsSendXoffSupported,
1.81 + KStrKCapsObeyCTSSupported, KCapsObeyCTSSupported,
1.82 + KStrKCapsFailCTSSupported, KCapsFailCTSSupported,
1.83 + KStrKCapsObeyDSRSupported, KCapsObeyDSRSupported,
1.84 + KStrKCapsFailDSRSupported, KCapsFailDSRSupported,
1.85 + KStrKCapsObeyDCDSupported, KCapsObeyDCDSupported,
1.86 + KStrKCapsFailDCDSupported, KCapsFailDCDSupported,
1.87 + KStrKCapsFreeRTSSupported, KCapsFreeRTSSupported,
1.88 + KStrKCapsFreeDTRSupported, KCapsFreeDTRSupported,
1.89 + KStrKCapsObeyDTRSupported, KCapsObeyDTRSupported,
1.90 + KStrKCapsObeyRTSSupported, KCapsObeyRTSSupported,
1.91 + KStrNull, -1
1.92 + };
1.93 +
1.94 +_LIT(KStrKCapsParityNone, "KCapsParityNone");
1.95 +_LIT(KStrKCapsParityEven, "KCapsParityEven");
1.96 +_LIT(KStrKCapsParityOdd, "KCapsParityOdd");
1.97 +_LIT(KStrKCapsParityMark, "KCapsParityMark");
1.98 +_LIT(KStrKCapsParitySpace, "KCapsParitySpace");
1.99 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableParity[] =
1.100 + {
1.101 +// Enum as a descriptor Enum
1.102 + KStrKCapsParityNone, KCapsParityNone,
1.103 + KStrKCapsParityEven, KCapsParityEven,
1.104 + KStrKCapsParityOdd, KCapsParityOdd,
1.105 + KStrKCapsParityMark, KCapsParityMark,
1.106 + KStrKCapsParitySpace, KCapsParitySpace,
1.107 + KStrNull, -1
1.108 + };
1.109 +
1.110 +_LIT(KStrKCapsBps50, "KCapsBps50");
1.111 +_LIT(KStrKCapsBps75, "KCapsBps75");
1.112 +_LIT(KStrKCapsBps110, "KCapsBps110");
1.113 +_LIT(KStrKCapsBps134, "KCapsBps134");
1.114 +_LIT(KStrKCapsBps150, "KCapsBps150");
1.115 +_LIT(KStrKCapsBps300, "KCapsBps300");
1.116 +_LIT(KStrKCapsBps600, "KCapsBps600");
1.117 +_LIT(KStrKCapsBps1200, "KCapsBps1200");
1.118 +_LIT(KStrKCapsBps1800, "KCapsBps1800");
1.119 +_LIT(KStrKCapsBps2000, "KCapsBps2000");
1.120 +_LIT(KStrKCapsBps2400, "KCapsBps2400");
1.121 +_LIT(KStrKCapsBps3600, "KCapsBps3600");
1.122 +_LIT(KStrKCapsBps4800, "KCapsBps4800");
1.123 +_LIT(KStrKCapsBps7200, "KCapsBps7200");
1.124 +_LIT(KStrKCapsBps9600, "KCapsBps9600");
1.125 +_LIT(KStrKCapsBps19200, "KCapsBps19200");
1.126 +_LIT(KStrKCapsBps38400, "KCapsBps38400");
1.127 +_LIT(KStrKCapsBps57600, "KCapsBps57600");
1.128 +_LIT(KStrKCapsBps115200, "KCapsBps115200");
1.129 +_LIT(KStrKCapsBps230400, "KCapsBps230400");
1.130 +_LIT(KStrKCapsBps460800, "KCapsBps460800");
1.131 +_LIT(KStrKCapsBps576000, "KCapsBps576000");
1.132 +_LIT(KStrKCapsBps1152000, "KCapsBps1152000");
1.133 +_LIT(KStrKCapsBps4000000, "KCapsBps4000000");
1.134 +_LIT(KStrKCapsBps921600, "KCapsBps921600");
1.135 +_LIT(KStrKCapsBpsAutobaud, "KCapsBpsAutobaud");
1.136 +_LIT(KStrKCapsBpsSpecial, "KCapsBpsSpecial");
1.137 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableRate[] =
1.138 + {
1.139 +// Enum as a descriptor Enum
1.140 + KStrKCapsBps50, KCapsBps50,
1.141 + KStrKCapsBps75, KCapsBps75,
1.142 + KStrKCapsBps110, KCapsBps110,
1.143 + KStrKCapsBps134, KCapsBps134,
1.144 + KStrKCapsBps150, KCapsBps150,
1.145 + KStrKCapsBps300, KCapsBps300,
1.146 + KStrKCapsBps600, KCapsBps600,
1.147 + KStrKCapsBps1200, KCapsBps1200,
1.148 + KStrKCapsBps1800, KCapsBps1800,
1.149 + KStrKCapsBps2000, KCapsBps2000,
1.150 + KStrKCapsBps2400, KCapsBps2400,
1.151 + KStrKCapsBps3600, KCapsBps3600,
1.152 + KStrKCapsBps4800, KCapsBps4800,
1.153 + KStrKCapsBps7200, KCapsBps7200,
1.154 + KStrKCapsBps9600, KCapsBps9600,
1.155 + KStrKCapsBps19200, KCapsBps19200,
1.156 + KStrKCapsBps38400, KCapsBps38400,
1.157 + KStrKCapsBps57600, KCapsBps57600,
1.158 + KStrKCapsBps115200, KCapsBps115200,
1.159 + KStrKCapsBps230400, KCapsBps230400,
1.160 + KStrKCapsBps460800, KCapsBps460800,
1.161 + KStrKCapsBps576000, KCapsBps576000,
1.162 + KStrKCapsBps1152000, KCapsBps1152000,
1.163 + KStrKCapsBps4000000, KCapsBps4000000,
1.164 + KStrKCapsBps921600, KCapsBps921600,
1.165 + KStrKCapsBpsAutobaud, KCapsBpsAutobaud,
1.166 + KStrKCapsBpsSpecial, KCapsBpsSpecial,
1.167 + KStrNull, -1
1.168 + };
1.169 +
1.170 +_LIT(KStrKCapsSIR115kbps, "KCapsSIR115kbps");
1.171 +_LIT(KStrKCapsSIR2400bpsOnly, "KCapsSIR2400bpsOnly");
1.172 +_LIT(KStrKCapsSIR4Mbs, "KCapsSIR4Mbs");
1.173 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableSir[] =
1.174 + {
1.175 +// Enum as a descriptor Enum
1.176 + KStrKCapsSIR115kbps, KCapsSIR115kbps,
1.177 + KStrKCapsSIR2400bpsOnly, KCapsSIR2400bpsOnly,
1.178 + KStrKCapsSIR4Mbs, KCapsSIR4Mbs,
1.179 + KStrNull, -1
1.180 + };
1.181 +
1.182 +_LIT(KStrKCapsSignalCTSSupported, "KCapsSignalCTSSupported");
1.183 +_LIT(KStrKCapsSignalDSRSupported, "KCapsSignalDSRSupported");
1.184 +_LIT(KStrKCapsSignalDCDSupported, "KCapsSignalDCDSupported");
1.185 +_LIT(KStrKCapsSignalRNGSupported, "KCapsSignalRNGSupported");
1.186 +_LIT(KStrKCapsSignalRTSSupported, "KCapsSignalRTSSupported");
1.187 +_LIT(KStrKCapsSignalDTRSupported, "KCapsSignalDTRSupported");
1.188 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableSignals[] =
1.189 + {
1.190 +// Enum as a descriptor Enum
1.191 + KStrKCapsSignalCTSSupported, KCapsSignalCTSSupported,
1.192 + KStrKCapsSignalDSRSupported, KCapsSignalDSRSupported,
1.193 + KStrKCapsSignalDCDSupported, KCapsSignalDCDSupported,
1.194 + KStrKCapsSignalRNGSupported, KCapsSignalRNGSupported,
1.195 + KStrKCapsSignalRTSSupported, KCapsSignalRTSSupported,
1.196 + KStrKCapsSignalDTRSupported, KCapsSignalDTRSupported,
1.197 + KStrNull, -1
1.198 + };
1.199 +
1.200 +_LIT(KStrKCapsStop1, "KCapsStop1");
1.201 +_LIT(KStrKCapsStop2, "KCapsStop2");
1.202 +const CDataWrapperBase::TEnumEntryTable CT_TCommCapsV01Data::iEnumTableStopBits[] =
1.203 + {
1.204 +// Enum as a descriptor Enum
1.205 + KStrKCapsStop1, KCapsStop1,
1.206 + KStrKCapsStop2, KCapsStop2,
1.207 + KStrNull, -1
1.208 + };
1.209 +
1.210 +//////////////////////////////////////////////////////////////////////
1.211 +// Construction/Destruction
1.212 +//////////////////////////////////////////////////////////////////////
1.213 +
1.214 +CT_TCommCapsV01Data::CT_TCommCapsV01Data()
1.215 +: CDataWrapperBase()
1.216 +, iCommCaps(NULL)
1.217 + {
1.218 + }
1.219 +
1.220 +CT_TCommCapsV01Data::~CT_TCommCapsV01Data()
1.221 +/**
1.222 + * Public destructor
1.223 + */
1.224 + {
1.225 + DestroyData();
1.226 + }
1.227 +
1.228 +void CT_TCommCapsV01Data::DestroyData()
1.229 + {
1.230 + delete iCommCaps;
1.231 + iCommCaps=NULL;
1.232 + }
1.233 +
1.234 +TDes8* CT_TCommCapsV01Data::Descriptor()
1.235 +/**
1.236 + * Return a pointer to the buffer
1.237 + *
1.238 + * @return pointer to the buffer
1.239 + */
1.240 + {
1.241 + return iCommCaps;
1.242 + }
1.243 +
1.244 +TAny* CT_TCommCapsV01Data::GetObject()
1.245 +/**
1.246 + * Return a pointer to the object that the data wraps
1.247 + *
1.248 + * @return pointer to the object that the data wraps
1.249 + */
1.250 + {
1.251 + return iCommCaps;
1.252 + }
1.253 +
1.254 +TBool CT_TCommCapsV01Data::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.255 +/**
1.256 + * Process a command read from the ini file
1.257 + *
1.258 + * @param aCommand The command to process
1.259 + * @param aSection The section in the ini containing data for the command
1.260 + * @param aAsyncErrorIndex Command index for async calls to return errors to
1.261 + *
1.262 + * @return ETrue if the command is processed
1.263 + *
1.264 + * @leave System wide error
1.265 + */
1.266 + {
1.267 + TBool ret=ETrue;
1.268 + TInt err=KErrNone;
1.269 +
1.270 + if ( aCommand==KCmdConstructor )
1.271 + {
1.272 + err=DoCmdConstructor();
1.273 + }
1.274 + else if ( aCommand==KCmdDestructor )
1.275 + {
1.276 + DoCmdDestructor();
1.277 + }
1.278 + else if ( aCommand==KCmdiDataBits )
1.279 + {
1.280 + DoCmdiDataBits(aSection);
1.281 + }
1.282 + else if ( aCommand==KCmdiFifo )
1.283 + {
1.284 + DoCmdiFifo(aSection);
1.285 + }
1.286 + else if ( aCommand==KCmdiHandshake )
1.287 + {
1.288 + DoCmdiHandshake(aSection);
1.289 + }
1.290 + else if ( aCommand==KCmdiParity )
1.291 + {
1.292 + DoCmdiParity(aSection);
1.293 + }
1.294 + else if ( aCommand==KCmdiRate )
1.295 + {
1.296 + DoCmdiRate(aSection);
1.297 + }
1.298 + else if ( aCommand==KCmdiSIR )
1.299 + {
1.300 + DoCmdiSIR(aSection);
1.301 + }
1.302 + else if ( aCommand==KCmdiSignals )
1.303 + {
1.304 + DoCmdiSignals(aSection);
1.305 + }
1.306 + else if ( aCommand==KCmdiStopBits )
1.307 + {
1.308 + DoCmdiStopBits(aSection);
1.309 + }
1.310 + else
1.311 + {
1.312 + ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
1.313 + }
1.314 +
1.315 + if ( err!=KErrNone )
1.316 + {
1.317 + ERR_PRINTF2(KLogError, err);
1.318 + SetError(err);
1.319 + }
1.320 +
1.321 + return ret;
1.322 + }
1.323 +
1.324 +TCommCapsV01& CT_TCommCapsV01Data::GetCommCapsV01()
1.325 + {
1.326 + return (*iCommCaps)();
1.327 + }
1.328 +
1.329 +TInt CT_TCommCapsV01Data::DoCmdConstructor()
1.330 + {
1.331 + DestroyData();
1.332 + TRAPD(err, iCommCaps=new (ELeave) TCommCaps());
1.333 + iCommCaps->FillZ();
1.334 + return err;
1.335 + }
1.336 +
1.337 +void CT_TCommCapsV01Data::DoCmdDestructor()
1.338 + {
1.339 + DestroyData();
1.340 + }
1.341 +
1.342 +void CT_TCommCapsV01Data::DoCmdiDataBits(const TDesC& aSection)
1.343 + {
1.344 + TUint actual=GetCommCapsV01().iDataBits;
1.345 + INFO_PRINTF2(_L("iDataBits : 0x%X"), actual);
1.346 +
1.347 + TUint expected;
1.348 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableDataBits, expected) )
1.349 + {
1.350 + if ( expected!=actual )
1.351 + {
1.352 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.353 + SetBlockResult(EFail);
1.354 + }
1.355 + }
1.356 + }
1.357 +
1.358 +void CT_TCommCapsV01Data::DoCmdiFifo(const TDesC& aSection)
1.359 + {
1.360 + TUint actual=GetCommCapsV01().iFifo;
1.361 + INFO_PRINTF2(_L("iFifo : 0x%X"), actual);
1.362 +
1.363 + TUint expected;
1.364 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableFifo, expected) )
1.365 + {
1.366 + if ( expected!=actual )
1.367 + {
1.368 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.369 + SetBlockResult(EFail);
1.370 + }
1.371 + }
1.372 + }
1.373 +
1.374 +void CT_TCommCapsV01Data::DoCmdiHandshake(const TDesC& aSection)
1.375 + {
1.376 + TUint actual=GetCommCapsV01().iHandshake;
1.377 + INFO_PRINTF2(_L("iHandshake : 0x%X"), actual);
1.378 +
1.379 + TUint expected;
1.380 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableHandshake, expected) )
1.381 + {
1.382 + if ( expected!=actual )
1.383 + {
1.384 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.385 + SetBlockResult(EFail);
1.386 + }
1.387 + }
1.388 + }
1.389 +
1.390 +void CT_TCommCapsV01Data::DoCmdiParity(const TDesC& aSection)
1.391 + {
1.392 + TUint actual=GetCommCapsV01().iParity;
1.393 + INFO_PRINTF2(_L("iParity : 0x%X"), actual);
1.394 +
1.395 + TUint expected;
1.396 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableParity, expected) )
1.397 + {
1.398 + if ( expected!=actual )
1.399 + {
1.400 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.401 + SetBlockResult(EFail);
1.402 + }
1.403 + }
1.404 + }
1.405 +
1.406 +void CT_TCommCapsV01Data::DoCmdiRate(const TDesC& aSection)
1.407 + {
1.408 + TUint actual=GetCommCapsV01().iRate;
1.409 + INFO_PRINTF2(_L("iRate : 0x%X"), actual);
1.410 +
1.411 + TUint expected;
1.412 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableRate, expected) )
1.413 + {
1.414 + if ( expected!=actual )
1.415 + {
1.416 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.417 + SetBlockResult(EFail);
1.418 + }
1.419 + }
1.420 + }
1.421 +
1.422 +void CT_TCommCapsV01Data::DoCmdiSIR(const TDesC& aSection)
1.423 + {
1.424 + TUint actual=GetCommCapsV01().iSIR;
1.425 + INFO_PRINTF2(_L("iSIR : 0x%X"), actual);
1.426 +
1.427 + TUint expected;
1.428 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableSir, expected) )
1.429 + {
1.430 + if ( expected!=actual )
1.431 + {
1.432 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.433 + SetBlockResult(EFail);
1.434 + }
1.435 + }
1.436 + }
1.437 +
1.438 +void CT_TCommCapsV01Data::DoCmdiSignals(const TDesC& aSection)
1.439 + {
1.440 + TUint actual=GetCommCapsV01().iSignals;
1.441 + INFO_PRINTF2(_L("iSignals : 0x%X"), actual);
1.442 +
1.443 + TUint expected;
1.444 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableSignals, expected) )
1.445 + {
1.446 + if ( expected!=actual )
1.447 + {
1.448 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.449 + SetBlockResult(EFail);
1.450 + }
1.451 + }
1.452 + }
1.453 +
1.454 +void CT_TCommCapsV01Data::DoCmdiStopBits(const TDesC& aSection)
1.455 + {
1.456 + TUint actual=GetCommCapsV01().iStopBits;
1.457 + INFO_PRINTF2(_L("iStopBits : 0x%X"), actual);
1.458 +
1.459 + TUint expected;
1.460 + if ( GetOrFromConfig(aSection, KFldExpected(), iEnumTableStopBits, expected) )
1.461 + {
1.462 + if ( expected!=actual )
1.463 + {
1.464 + ERR_PRINTF1(_L("Expected Value does not match actual"));
1.465 + SetBlockResult(EFail);
1.466 + }
1.467 + }
1.468 + }