os/boardsupport/haitest/bspsvs/suite/e32/src/T_RDevUsbcClientData.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/e32/src/T_RDevUsbcClientData.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,984 @@
     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 +// This contains implementation for CT_RDevUsbcClientData class
    1.21 +
    1.22 +
    1.23 +
    1.24 +#include <f32file.h>
    1.25 +#include <d32usbc.h>
    1.26 +#include "T_RDevUsbcClientData.h" 
    1.27 +
    1.28 +
    1.29 +
    1.30 +/*@{*/
    1.31 +//LITs to identify the commands
    1.32 +_LIT(KCmdNewL,									"NewL");
    1.33 +_LIT(KCmdUtilityLoadLogicalDevice, 				"LoadLogicalDevice");
    1.34 +_LIT(KCmdOpen, 					    			"Open");
    1.35 +_LIT(KCmdDeviceCaps,							"DeviceCaps");
    1.36 +_LIT(KCmdUtilitySetEndPoint, 					"SetEndPoint");
    1.37 +_LIT(KCmdEndpointCaps,							"EndpointCaps");
    1.38 +_LIT(KCmdSetInterface, 							"SetInterface");
    1.39 +_LIT(KCmdGetDeviceDescriptorSize,				"GetDeviceDescriptorSize");
    1.40 +_LIT(KCmdGetDeviceDescriptor,					"GetDeviceDescriptor");
    1.41 +_LIT(KCmdSetDeviceDescriptor,					"SetDeviceDescriptor");
    1.42 +_LIT(KCmdDestructor,							"~");
    1.43 +/*@}*/
    1.44 +
    1.45 +
    1.46 +/*@{*/
    1.47 +//LITs to read from the ini file
    1.48 +_LIT(KMode, 									"mode");
    1.49 +_LIT(KDirection, 								"direction");
    1.50 +_LIT(KBufferingMask, 							"bandwidthBufferingMask");
    1.51 +_LIT(KSupportsConnect,							"supportsConnect");
    1.52 +_LIT(KSupportsSelfPowered, 						"supportsSelfPowered");
    1.53 +_LIT(KSupportsRemoteWakeup, 					"supportsRemoteWakeup");
    1.54 +_LIT(KUSBVersionLow, 							"USBVersionLow");
    1.55 +_LIT(KUSBVersionHigh,							"USBVersionHigh");
    1.56 +_LIT(KVendorIDLow, 								"VendorIDLow");
    1.57 +_LIT(KVendorIDHigh, 							"VendorIDHigh");
    1.58 +_LIT(KProductIDLow, 							"ProductIDLow");
    1.59 +_LIT(KProductIDHigh, 							"ProductIDHigh");
    1.60 +_LIT(KReleaseNumberLow, 						"ReleaseNumberLow");
    1.61 +_LIT(KReleaseNumberHigh, 						"ReleaseNumberHigh");
    1.62 +_LIT(KDriver, 									"driver");
    1.63 +_LIT(KEXPECTED, 								"expected");
    1.64 +/*@}*/
    1.65 +
    1.66 +/*@{*/
    1.67 +_LIT16(interfaceName, "USB interface");
    1.68 +/*@}*/
    1.69 +
    1.70 +/*@{*/
    1.71 +_LIT(KResourceDMA, 							"ResourceDMA");
    1.72 +_LIT(KResourceDoubleBuffering,				"ResourceDoubleBuffering");
    1.73 +/*@}*/
    1.74 +const CDataWrapperBase::TEnumEntryTable CT_RDevUsbcClientData::iEUsbcEndpointResource[] = 
    1.75 +	{ 
    1.76 +	{ KResourceDMA,					EUsbcEndpointResourceDMA },		// Requests the use of DMA =0
    1.77 +	{ KResourceDoubleBuffering,		EUsbcEndpointResourceDoubleBuffering },	//Requests the use of double FIFO buffering = 1	
    1.78 +	};
    1.79 +
    1.80 +/**
    1.81 + * Two phase constructor
    1.82 + *
    1.83 + * @leave	system wide error
    1.84 + */
    1.85 +CT_RDevUsbcClientData* CT_RDevUsbcClientData::NewL()
    1.86 +	{
    1.87 +	CT_RDevUsbcClientData*	ret=new (ELeave) CT_RDevUsbcClientData();
    1.88 +	CleanupStack::PushL(ret);
    1.89 +	ret->ConstructL();
    1.90 +	CleanupStack::Pop(ret);
    1.91 +	return ret;
    1.92 +	}
    1.93 +
    1.94 +/**
    1.95 + * Protected constructor. First phase construction
    1.96 + */
    1.97 +CT_RDevUsbcClientData::CT_RDevUsbcClientData()
    1.98 +	:
    1.99 +	iChannel(NULL),
   1.100 +	iInterface(NULL),
   1.101 +	iEndpointData(),
   1.102 +	iConfiguredEndpoints(0),
   1.103 +	iTxMaxPacketSize(0),
   1.104 +	iCaps(),
   1.105 +	iActiveCallback(NULL),
   1.106 +	iBuffer(NULL),
   1.107 +    iBuffer_verify(NULL),
   1.108 +    iDeviceDescriptorSize(0)
   1.109 +	{
   1.110 +	
   1.111 +	}
   1.112 +
   1.113 +/**
   1.114 + * Second phase construction
   1.115 + *
   1.116 + * @internalComponent
   1.117 + *
   1.118 + * @return	N/A
   1.119 + *
   1.120 + * @pre		None
   1.121 + * @post	None
   1.122 + *
   1.123 + * @leave	system wide error
   1.124 + */
   1.125 +void CT_RDevUsbcClientData::ConstructL()
   1.126 +	{
   1.127 +	iActiveCallback = CActiveCallback::NewL(*this);	
   1.128 +	}
   1.129 +
   1.130 +/**
   1.131 + * Public destructor
   1.132 + */
   1.133 +CT_RDevUsbcClientData::~CT_RDevUsbcClientData()
   1.134 +	{		
   1.135 +	// Empty arrays and delete objects
   1.136 +
   1.137 +	DestroyData();
   1.138 +
   1.139 +	if (iActiveCallback)
   1.140 +		{
   1.141 +		delete iActiveCallback;
   1.142 +		iActiveCallback = NULL;
   1.143 +		}
   1.144 +	}
   1.145 +
   1.146 +/**
   1.147 + *  RunL is called when an asynchronous call has completed
   1.148 + * 
   1.149 + *  @param aActive - a pointer to an active object
   1.150 + *  @param aIndex - Index of the asynchronous call
   1.151 + * 
   1.152 + */
   1.153 +void CT_RDevUsbcClientData::RunL(CActive* aActive, TInt aIndex)
   1.154 +	{
   1.155 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::RunL"));
   1.156 +	DecOutstanding(); // One of the async calls has completed 
   1.157 +	TBool straySignal = EFalse; 
   1.158 +		  
   1.159 +	if(aActive == iActiveCallback)
   1.160 +		{
   1.161 +		INFO_PRINTF1(_L("Asynchronous task has completed. RunL  called"));
   1.162 +		}		
   1.163 +	else
   1.164 +		{ 
   1.165 +		ERR_PRINTF1(_L("Stray RunL signal"));
   1.166 +		SetBlockResult(EFail);
   1.167 +		straySignal = ETrue;		
   1.168 +		}
   1.169 +	
   1.170 +	if( !straySignal ) 
   1.171 +		{ 
   1.172 +		TInt err = aActive->iStatus.Int(); 
   1.173 +		if( err != KErrNone ) 
   1.174 +			{ 
   1.175 +			ERR_PRINTF2(_L("RunL Error %d"), err); 
   1.176 +			SetAsyncError( aIndex, err );		
   1.177 +			} 
   1.178 +		else
   1.179 +			{ 
   1.180 +			INFO_PRINTF1(_L("RunL  completed successfully"));
   1.181 +			}
   1.182 +		}
   1.183 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::RunL"));
   1.184 +	}
   1.185 +
   1.186 +
   1.187 +/**
   1.188 + * Return a pointer to the object that the data wraps
   1.189 + *
   1.190 + * @return	pointer to the object that the data wraps
   1.191 + */
   1.192 +TAny* CT_RDevUsbcClientData::GetObject()
   1.193 +	{
   1.194 +	return iChannel;
   1.195 +	}
   1.196 +
   1.197 +/**
   1.198 + * Returns the wrapper.
   1.199 + * 
   1.200 + * @return pointer to the Wrapper class
   1.201 + */
   1.202 +
   1.203 +
   1.204 +
   1.205 +/**
   1.206 + * Process a command read from the ini file
   1.207 + *
   1.208 + * @param aCommand			The command to process
   1.209 + * @param aSection			The section in the ini containing data for the command
   1.210 + * @param aAsyncErrorIndex	Command index for async calls to return errors to
   1.211 + * @return					ETrue if the command is processed
   1.212 + * @leave					System wide error
   1.213 + */
   1.214 +TBool CT_RDevUsbcClientData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
   1.215 +	{
   1.216 +	TBool ret=ETrue;
   1.217 +		
   1.218 +	if(aCommand == KCmdNewL )
   1.219 +		{
   1.220 +		DoCmdNewL();
   1.221 +		}
   1.222 +	else if(aCommand == KCmdUtilityLoadLogicalDevice)
   1.223 +		{
   1.224 +		DoCmdUtilityLoadLogicalDevice(aSection);
   1.225 +		}
   1.226 +	else if(aCommand == KCmdOpen)
   1.227 +		{
   1.228 +		DoCmdOpen();
   1.229 +		}
   1.230 +	else if(aCommand == KCmdDeviceCaps)
   1.231 +		{
   1.232 +		DoCmdDeviceCaps(aSection);
   1.233 +		}	
   1.234 +	else if(aCommand == KCmdGetDeviceDescriptorSize)
   1.235 +		{
   1.236 +		DoCmdGetDeviceDescriptorSize(aSection);
   1.237 +		}
   1.238 +	else if(aCommand == KCmdGetDeviceDescriptor)
   1.239 +		{
   1.240 +		DoCmdGetDeviceDescriptor(aSection);
   1.241 +		}
   1.242 +	else if(aCommand == KCmdSetDeviceDescriptor)
   1.243 +		{
   1.244 +		DoCmdSetDeviceDescriptor(aSection);
   1.245 +		}
   1.246 +	else if(aCommand == KCmdUtilitySetEndPoint)
   1.247 +		{
   1.248 +		DoCmdUtilitySetEndPointL(aSection);
   1.249 +		}	
   1.250 +	else if(aCommand == KCmdEndpointCaps)
   1.251 +		{
   1.252 +		DoCmdEndpointCaps();
   1.253 +		}
   1.254 +	else if(aCommand == KCmdSetInterface)
   1.255 +		{
   1.256 +		DoCmdSetInterface(aSection);
   1.257 +		}	
   1.258 +	else if(aCommand == KCmdDestructor)
   1.259 +		{
   1.260 +		DoCmdDestructor();
   1.261 +		}
   1.262 +	else
   1.263 +		{
   1.264 +		ERR_PRINTF1(_L("Unknown command"));
   1.265 +		ret = EFalse;
   1.266 +		}
   1.267 +	
   1.268 +	return ret;
   1.269 +	}
   1.270 +
   1.271 +
   1.272 +
   1.273 +/**
   1.274 + * Creante an object of RDevUsbcClient
   1.275 + */
   1.276 +void  CT_RDevUsbcClientData::DoCmdNewL()
   1.277 +	{
   1.278 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdNewL"));
   1.279 +	DestroyData();
   1.280 +	iChannel = new (ELeave) RDevUsbcClient();
   1.281 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdNewL"));
   1.282 +	}
   1.283 +/**
   1.284 + * Loads Logical Device for USB.
   1.285 + */
   1.286 +void CT_RDevUsbcClientData::DoCmdUtilityLoadLogicalDevice(const TTEFSectionName& aSection)
   1.287 +	{
   1.288 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdUtilityLoadLogicalDevice"));
   1.289 +	TInt error(KErrNone);
   1.290 +	TBool dataOk = ETrue;
   1.291 +	TPtrC lddName;
   1.292 +	TBufC<9> value;	
   1.293 +	if(!GetStringFromConfig(aSection, KDriver, lddName))
   1.294 +		{
   1.295 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), & KDriver);
   1.296 +		SetBlockResult(EFail);
   1.297 +		dataOk = EFalse;
   1.298 +		}	
   1.299 +	if(dataOk)
   1.300 +		{	
   1.301 +		value = lddName;		
   1.302 +		INFO_PRINTF2(_L("Driver: %S"), & value);
   1.303 +		error = User::LoadLogicalDevice(value);		
   1.304 +		
   1.305 +		if(error == KErrAlreadyExists)
   1.306 +			{
   1.307 +			INFO_PRINTF2(_L("USB - Logical device driver loaded with %d, error will be changed to KErrNone"), error);
   1.308 +			error = KErrNone;
   1.309 +			}
   1.310 +		if(error != KErrNone)
   1.311 +			{
   1.312 +			ERR_PRINTF2(_L("USB - Could not load logical device driver. Error %d"), error);
   1.313 +			}
   1.314 +		else
   1.315 +			{
   1.316 +			INFO_PRINTF2(_L("USB - Logical device driver loaded with %d"), error);
   1.317 +			}	
   1.318 +		SetError(error);
   1.319 +		}		
   1.320 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdUtilityLoadLogicalDevice"));
   1.321 +	}
   1.322 +
   1.323 +/**
   1.324 + * Opens a USB channel 
   1.325 + */
   1.326 +void CT_RDevUsbcClientData::DoCmdOpen()
   1.327 +	{
   1.328 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdOpen"));
   1.329 +	// Open USB driver channel
   1.330 +	TInt error = iChannel->Open(USB::KUSBChannelOpenParameter);
   1.331 +
   1.332 +	if (error != KErrNone)
   1.333 +		{
   1.334 +		ERR_PRINTF2(_L("ERROR %d when opening channel"), error);
   1.335 +		}
   1.336 +	else
   1.337 +		{
   1.338 +		INFO_PRINTF2(_L("Channel open returns: %d "), error);
   1.339 +		}
   1.340 +
   1.341 +	SetError(error);
   1.342 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdOpen"));
   1.343 +	}
   1.344 +
   1.345 +/**
   1.346 + * Reads device capabilities and verifies them
   1.347 + * @param aSection		The section in the ini containing data for the command
   1.348 + */
   1.349 +void CT_RDevUsbcClientData::DoCmdDeviceCaps(const TTEFSectionName& aSection)
   1.350 +	{
   1.351 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdDeviceCaps"));
   1.352 +	TBool supportsConnect;
   1.353 +	TBool dataOk = ETrue;
   1.354 +	if(!GetBoolFromConfig(aSection, KSupportsConnect, supportsConnect))
   1.355 +		{
   1.356 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KSupportsConnect);
   1.357 +		SetBlockResult(EFail);
   1.358 +		dataOk = EFalse;
   1.359 +		}
   1.360 +	
   1.361 +	TBool supportsSelfPowered;
   1.362 +	if(!GetBoolFromConfig(aSection, KSupportsSelfPowered, supportsSelfPowered))
   1.363 +		{
   1.364 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KSupportsSelfPowered);
   1.365 +		SetBlockResult(EFail);
   1.366 +		dataOk = EFalse;
   1.367 +		}
   1.368 +	
   1.369 +	TBool supportsRemoteWakeup;
   1.370 +	if(!GetBoolFromConfig(aSection, KSupportsRemoteWakeup, supportsRemoteWakeup))
   1.371 +		{
   1.372 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KSupportsRemoteWakeup);
   1.373 +		SetBlockResult(EFail);
   1.374 +		dataOk = EFalse;
   1.375 +		}
   1.376 +	if(dataOk)
   1.377 +		{
   1.378 +		TInt error = iChannel->DeviceCaps(iCaps);
   1.379 +		if (error != KErrNone)
   1.380 +			{
   1.381 +			ERR_PRINTF2(_L("Failed to read device caps [%d]"), error);
   1.382 +			SetError(error);
   1.383 +			}
   1.384 +		else
   1.385 +			{
   1.386 +			// Check that reported device capabilities are what they should be
   1.387 +			INFO_PRINTF2(_L("Device supports %d endpoints"), iCaps().iTotalEndpoints );
   1.388 +			INFO_PRINTF2(_L("Device supports Software-Connect: %s"), iCaps().iConnect ? _S("yes") : _S("no"));
   1.389 +			if(!iCaps().iConnect && supportsConnect)
   1.390 +				{
   1.391 +				ERR_PRINTF1(_L("Device supports Software-Connect feature IS NOT SUPPORTED"));
   1.392 +				SetBlockResult(EFail);
   1.393 +				}
   1.394 +
   1.395 +			INFO_PRINTF2(_L("Device is Self-Powered: %s"), iCaps().iSelfPowered ? _S("yes") : _S("no"));
   1.396 +			if(!iCaps().iSelfPowered && supportsSelfPowered)
   1.397 +				{
   1.398 +				ERR_PRINTF1(_L("Device is Self-Powered feature IS NOT SUPPORTED"));
   1.399 +				SetBlockResult(EFail);
   1.400 +				}
   1.401 +
   1.402 +			INFO_PRINTF2(_L("Device supports Remote-Wakeup:	%s"),iCaps().iRemoteWakeup ? _S("yes") : _S("no"));
   1.403 +			if(!iCaps().iRemoteWakeup && supportsRemoteWakeup)
   1.404 +				{
   1.405 +				ERR_PRINTF1(_L("Device supports Remote-Wakeup feature IS NOT SUPPORTED"));
   1.406 +				SetBlockResult(EFail);
   1.407 +				}
   1.408 +			}		
   1.409 +		}
   1.410 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdDeviceCaps"));
   1.411 +	}
   1.412 +
   1.413 +/**
   1.414 + * Reads device endpoint capabilities and prints them
   1.415 + */
   1.416 +void CT_RDevUsbcClientData::DoCmdEndpointCaps()
   1.417 +	{
   1.418 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdEndpointCaps"));
   1.419 +	TPtr8 endpointData(reinterpret_cast<TUint8*>(iEndpointData), sizeof(iEndpointData), sizeof(iEndpointData));
   1.420 +	TInt error = iChannel->EndpointCaps(endpointData);
   1.421 +
   1.422 +	if (error != KErrNone)
   1.423 +		{
   1.424 +		ERR_PRINTF2(_L("Failed to read endpoint caps [%d]"), error);
   1.425 +		SetError(error);
   1.426 +		}
   1.427 +	else
   1.428 +		{
   1.429 +		INFO_PRINTF1(_L("User endpoint capabilities:"));
   1.430 +		for (TInt i = 0; i < iCaps().iTotalEndpoints; i++)
   1.431 +			{
   1.432 +			const TUsbcEndpointCaps* caps = &iEndpointData[i].iCaps;
   1.433 +			INFO_PRINTF4(_L("Endpoint %02d: MaxPackeSize=%s TypeDirM = 0x%08x "),
   1.434 +						i + 1,
   1.435 +						(caps->iSizes & KUsbEpSizeCont ) ? _S("Continuous") :
   1.436 +						((caps->iSizes & KUsbEpSize8) ? _S("8 bytes") :
   1.437 +						((caps->iSizes & KUsbEpSize16) ? _S("16 bytes") :
   1.438 +						((caps->iSizes & KUsbEpSize32) ? _S("32 bytes") :
   1.439 +						((caps->iSizes & KUsbEpSize64) ? _S("64 bytes") :
   1.440 +						((caps->iSizes & KUsbEpSize128) ? _S("128 bytes") :
   1.441 +						((caps->iSizes & KUsbEpSize256) ? _S("256 bytes") :
   1.442 +						((caps->iSizes & KUsbEpSize512) ? _S("512 bytes") :
   1.443 +						((caps->iSizes & KUsbEpSize1023) ? _S("1023 bytes") :
   1.444 +						((caps->iSizes & KUsbEpSize1024) ? _S("1024 bytes") :
   1.445 +						_S("Unknown")))))))))),
   1.446 +						caps->iTypesAndDir);
   1.447 +			}
   1.448 +		}
   1.449 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdEndpointCaps"));
   1.450 +	}
   1.451 +
   1.452 +
   1.453 +/*
   1.454 + * Inits USB Device Descriptors - Get the device descriptor size
   1.455 + */
   1.456 +
   1.457 +void CT_RDevUsbcClientData::DoCmdGetDeviceDescriptorSize(const TTEFSectionName& aSection)
   1.458 +	{	
   1.459 +	// Read the size of the descriptors and create buffer to store them.
   1.460 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdGetDeviceDescriptorSize"));
   1.461 +    TInt expected;
   1.462 +    if(!GetIntFromConfig(aSection, KEXPECTED, expected))
   1.463 +		{
   1.464 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KEXPECTED);
   1.465 +		SetBlockResult(EFail);
   1.466 +		}
   1.467 +    else
   1.468 +        {
   1.469 +        iDeviceDescriptorSize = 0;
   1.470 +    	INFO_PRINTF1(_L("Initializing device descriptors"));
   1.471 +        INFO_PRINTF1(_L("void CT_RDevUsbcClientData::GetDeviceDescriptorSize() BEGIN"));
   1.472 +    	iChannel->GetDeviceDescriptorSize(iDeviceDescriptorSize);	
   1.473 +        
   1.474 +        if(expected != iDeviceDescriptorSize)
   1.475 +            {
   1.476 +            ERR_PRINTF3(_L("Expected size != actual size, expected = %d, actual = %d "),expected, iDeviceDescriptorSize);
   1.477 +            SetBlockResult(EFail);
   1.478 +            }
   1.479 +        }
   1.480 +        // initialize buffer which used to verify.
   1.481 +        
   1.482 +            
   1.483 +    INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdGetDeviceDescriptorSize"));
   1.484 +	}
   1.485 +
   1.486 +/**
   1.487 + * Inits USB Device Descriptors - Get device descriptor
   1.488 + */
   1.489 +
   1.490 +void CT_RDevUsbcClientData::DoCmdGetDeviceDescriptor(const TTEFSectionName& aSection)
   1.491 +	{
   1.492 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdGetDeviceDescriptor"));
   1.493 +    
   1.494 +    //initialize descriptor buffer.
   1.495 +    TRAPD(error, iBuffer = HBufC8::NewL(iDeviceDescriptorSize));
   1.496 +    if(error != KErrNone || !iBuffer)
   1.497 +    	{
   1.498 +    	ERR_PRINTF2(_L("Failed to initialize device descriptor [%d]"),error);
   1.499 +    	SetError(error);
   1.500 +    	}
   1.501 +    TRAPD(error2, iBuffer_verify = HBufC8::NewL(iDeviceDescriptorSize));
   1.502 +    if(error2 != KErrNone || !iBuffer_verify)
   1.503 +    	{
   1.504 +    	ERR_PRINTF2(_L("Failed to initialize device descriptor [%d]"),error2);
   1.505 +    	SetError(error2);
   1.506 +    	}  
   1.507 +    
   1.508 +	TInt err;	
   1.509 +	TPtr8 devDescrPtr = iBuffer->Des();
   1.510 +	// Read the current descriptors.	
   1.511 +	err = iChannel->GetDeviceDescriptor(devDescrPtr);
   1.512 +	if (err != KErrNone)
   1.513 +		{
   1.514 +		ERR_PRINTF2(_L("Failed to get the device descriptor [%d]"),err);
   1.515 +		SetError(err);
   1.516 +		}   
   1.517 +        
   1.518 +    // Read descriptors from ini and compare.
   1.519 +    TInt USBVersionLow;
   1.520 +	TBool dataOk = ETrue;
   1.521 +	if(!GetIntFromConfig(aSection, KUSBVersionLow, USBVersionLow))
   1.522 +		{
   1.523 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUSBVersionLow);
   1.524 +		SetBlockResult(EFail);
   1.525 +		dataOk = EFalse;
   1.526 +		}
   1.527 +	TInt USBVersionHigh;
   1.528 +	if(!GetIntFromConfig(aSection, KUSBVersionHigh, USBVersionHigh))
   1.529 +		{
   1.530 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUSBVersionHigh);
   1.531 +		SetBlockResult(EFail);
   1.532 +		dataOk = EFalse;
   1.533 +		}
   1.534 +	TInt VendorIDLow;
   1.535 +	if(!GetIntFromConfig(aSection, KVendorIDLow, VendorIDLow))
   1.536 +		{
   1.537 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVendorIDLow);
   1.538 +		SetBlockResult(EFail);
   1.539 +		dataOk = EFalse;
   1.540 +		}
   1.541 +	TInt VendorIDHigh;
   1.542 +	if(!GetIntFromConfig(aSection, KVendorIDHigh, VendorIDHigh))
   1.543 +		{
   1.544 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVendorIDHigh);
   1.545 +		SetBlockResult(EFail);
   1.546 +		dataOk = EFalse;
   1.547 +		}
   1.548 +	// product ID for test device
   1.549 +	TInt ProductIDLow;
   1.550 +	if(!GetIntFromConfig(aSection, KProductIDLow, ProductIDLow))
   1.551 +		{
   1.552 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KProductIDLow);
   1.553 +		SetBlockResult(EFail);
   1.554 +		dataOk = EFalse;
   1.555 +		}
   1.556 +	TInt ProductIDHigh;
   1.557 +	if(!GetIntFromConfig(aSection, KProductIDHigh, ProductIDHigh))
   1.558 +		{
   1.559 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KProductIDHigh);
   1.560 +		SetBlockResult(EFail);
   1.561 +		dataOk = EFalse;
   1.562 +		}
   1.563 +	// release number
   1.564 +	TInt ReleaseNumberLow;
   1.565 +	if(!GetIntFromConfig(aSection, KReleaseNumberLow, ReleaseNumberLow))
   1.566 +		{
   1.567 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KReleaseNumberLow);
   1.568 +		SetBlockResult(EFail);
   1.569 +		dataOk = EFalse;
   1.570 +		}
   1.571 +	TInt ReleaseNumberHigh;
   1.572 +	if(!GetIntFromConfig(aSection, KReleaseNumberHigh, ReleaseNumberHigh))
   1.573 +		{
   1.574 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KReleaseNumberHigh);
   1.575 +		SetBlockResult(EFail);
   1.576 +		dataOk = EFalse;
   1.577 +		}			
   1.578 +	// Device descriptor data is presented in bytes (Little endian)
   1.579 +	// defined in the .ini file
   1.580 +	// The following presents numeric values device uses to introduce
   1.581 +	// herself to USB host in enumeration process
   1.582 +	if(dataOk)
   1.583 +		{
   1.584 +		TPtr8 devDescrPtr_verify = iBuffer_verify->Des();
   1.585 +		err = iChannel->GetDeviceDescriptor(devDescrPtr_verify);
   1.586 +		if (err != KErrNone)
   1.587 +			{
   1.588 +			ERR_PRINTF2(_L("Failed to get the device descriptor [%d]"),err);
   1.589 +			SetError(err);
   1.590 +			}   
   1.591 +		// USB version
   1.592 +		devDescrPtr_verify[USB::KSpecOffset] = USBVersionLow;
   1.593 +		devDescrPtr_verify[USB::KSpecOffset + 1] = USBVersionHigh;
   1.594 +
   1.595 +		devDescrPtr_verify[USB::KVendorOffset] = VendorIDLow;
   1.596 +		devDescrPtr_verify[USB::KVendorOffset + 1] = VendorIDHigh;
   1.597 +
   1.598 +		// product ID for test device
   1.599 +		devDescrPtr_verify[USB::KProductIDOffset] = ProductIDLow;
   1.600 +		devDescrPtr_verify[USB::KProductIDOffset + 1] = ProductIDHigh;
   1.601 +
   1.602 +		// Set release number
   1.603 +		devDescrPtr_verify[USB::KReleaseOffset] = ReleaseNumberLow;
   1.604 +		devDescrPtr_verify[USB::KReleaseOffset + 1] = ReleaseNumberHigh;
   1.605 +
   1.606 +        if(devDescrPtr != devDescrPtr_verify)
   1.607 +            {
   1.608 +            ERR_PRINTF1(_L("Expected DeviceDescriptor is not the same as actual. "));
   1.609 +            SetBlockResult(EFail);
   1.610 +            }
   1.611 +		}	
   1.612 +        
   1.613 +        delete iBuffer;
   1.614 +		iBuffer = NULL;
   1.615 +        delete iBuffer_verify;
   1.616 +		iBuffer_verify = NULL;
   1.617 +
   1.618 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdGetDeviceDescriptor"));
   1.619 +	}
   1.620 +
   1.621 +/**
   1.622 + * Inits USB Device Descriptors - Set device descriptor
   1.623 + * @param aSection - The section in the ini containing data for the command
   1.624 + */
   1.625 +void CT_RDevUsbcClientData::DoCmdSetDeviceDescriptor(const TTEFSectionName& aSection)
   1.626 +	{
   1.627 +	// USB version
   1.628 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdSetDeviceDescriptor"));
   1.629 +    
   1.630 +    iDeviceDescriptorSize = 0;
   1.631 +    INFO_PRINTF1(_L("Initializing device descriptors"));
   1.632 +    iChannel->GetDeviceDescriptorSize(iDeviceDescriptorSize);	
   1.633 +    INFO_PRINTF2(_L("Device descriptor size = %d"), iDeviceDescriptorSize);
   1.634 +    
   1.635 +    //initialize descriptor buffer.
   1.636 +    TRAPD(err, iBuffer = HBufC8::NewL(iDeviceDescriptorSize));
   1.637 +    if(err != KErrNone || !iBuffer)
   1.638 +    	{
   1.639 +    	ERR_PRINTF2(_L("Failed to initialize device descriptor [%d]"),err);
   1.640 +    	SetError(err);
   1.641 +    	}
   1.642 +    
   1.643 +	TInt error;
   1.644 +	TInt USBVersionLow;
   1.645 +	TBool dataOk = ETrue;
   1.646 +	if(!GetIntFromConfig(aSection, KUSBVersionLow, USBVersionLow))
   1.647 +		{
   1.648 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUSBVersionLow);
   1.649 +		SetBlockResult(EFail);
   1.650 +		dataOk = EFalse;
   1.651 +		}
   1.652 +	TInt USBVersionHigh;
   1.653 +	if(!GetIntFromConfig(aSection, KUSBVersionHigh, USBVersionHigh))
   1.654 +		{
   1.655 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUSBVersionHigh);
   1.656 +		SetBlockResult(EFail);
   1.657 +		dataOk = EFalse;
   1.658 +		}
   1.659 +
   1.660 +	TInt VendorIDLow;
   1.661 +	if(!GetIntFromConfig(aSection, KVendorIDLow, VendorIDLow))
   1.662 +		{
   1.663 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVendorIDLow);
   1.664 +		SetBlockResult(EFail);
   1.665 +		dataOk = EFalse;
   1.666 +		}
   1.667 +	TInt VendorIDHigh;
   1.668 +	if(!GetIntFromConfig(aSection, KVendorIDHigh, VendorIDHigh))
   1.669 +		{
   1.670 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVendorIDHigh);
   1.671 +		SetBlockResult(EFail);
   1.672 +		dataOk = EFalse;
   1.673 +		}
   1.674 +	// product ID for test device
   1.675 +	TInt ProductIDLow;
   1.676 +	if(!GetIntFromConfig(aSection, KProductIDLow, ProductIDLow))
   1.677 +		{
   1.678 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KProductIDLow);
   1.679 +		SetBlockResult(EFail);
   1.680 +		dataOk = EFalse;
   1.681 +		}
   1.682 +	TInt ProductIDHigh;
   1.683 +	if(!GetIntFromConfig(aSection, KProductIDHigh, ProductIDHigh))
   1.684 +		{
   1.685 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KProductIDHigh);
   1.686 +		SetBlockResult(EFail);
   1.687 +		dataOk = EFalse;
   1.688 +		}
   1.689 +	// release number
   1.690 +	TInt ReleaseNumberLow;
   1.691 +	if(!GetIntFromConfig(aSection, KReleaseNumberLow, ReleaseNumberLow))
   1.692 +		{
   1.693 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KReleaseNumberLow);
   1.694 +		SetBlockResult(EFail);
   1.695 +		dataOk = EFalse;
   1.696 +		}
   1.697 +	TInt ReleaseNumberHigh;
   1.698 +	if(!GetIntFromConfig(aSection, KReleaseNumberHigh, ReleaseNumberHigh))
   1.699 +		{
   1.700 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KReleaseNumberHigh);
   1.701 +		SetBlockResult(EFail);
   1.702 +		dataOk = EFalse;
   1.703 +		}			
   1.704 +	// Device descriptor data is presented in bytes (Little endian)
   1.705 +	// defined in the .ini file
   1.706 +	// The following presents numeric values device uses to introduce
   1.707 +	// herself to USB host in enumeration process
   1.708 +	if(dataOk)
   1.709 +		{
   1.710 +		TPtr8 devDescrPtr = iBuffer->Des();
   1.711 +		devDescrPtr.FillZ(devDescrPtr.MaxLength());
   1.712 +
   1.713 +		// USB version
   1.714 +		devDescrPtr[USB::KSpecOffset] = USBVersionLow;
   1.715 +		devDescrPtr[USB::KSpecOffset + 1] = USBVersionHigh;
   1.716 +
   1.717 +		devDescrPtr[USB::KVendorOffset] = VendorIDLow;
   1.718 +		devDescrPtr[USB::KVendorOffset + 1] = VendorIDHigh;
   1.719 +
   1.720 +		// product ID for test device
   1.721 +		devDescrPtr[USB::KProductIDOffset] = ProductIDLow;
   1.722 +		devDescrPtr[USB::KProductIDOffset + 1] = ProductIDHigh;
   1.723 +
   1.724 +		// Set release number
   1.725 +		devDescrPtr[USB::KReleaseOffset] = ReleaseNumberLow;
   1.726 +		devDescrPtr[USB::KReleaseOffset + 1] = ReleaseNumberHigh;
   1.727 +
   1.728 +		INFO_PRINTF1(_L("Setting device descriptors"));
   1.729 +		// Store the descriptors.
   1.730 +		error = iChannel->SetDeviceDescriptor(devDescrPtr);
   1.731 +		if (error != KErrNone)
   1.732 +			{
   1.733 +			ERR_PRINTF2(_L("Failed to set the device descriptor [%d]"),error);
   1.734 +			delete iBuffer;
   1.735 +			SetError(error);
   1.736 +			}
   1.737 +		else
   1.738 +			{
   1.739 +			delete iBuffer;
   1.740 +			iBuffer = NULL;
   1.741 +			}
   1.742 +		
   1.743 +		INFO_PRINTF1(_L("Device descriptors set"));
   1.744 +		}	
   1.745 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdSetDeviceDescriptor"));
   1.746 +	}
   1.747 +
   1.748 +/**
   1.749 + * Sets USB EndPoints
   1.750 + * @param aSection - The section in the ini containing data for the command
   1.751 + */
   1.752 +
   1.753 +void CT_RDevUsbcClientData::DoCmdUtilitySetEndPointL(const TTEFSectionName& aSection)
   1.754 +	{
   1.755 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdUtilitySetEndPointL"));
   1.756 +	TPtrC16 mode;
   1.757 +	TBool dataOk = ETrue;
   1.758 +	if(!GetStringFromConfig(aSection, KMode, mode))
   1.759 +		{
   1.760 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMode);
   1.761 +		SetBlockResult(EFail);
   1.762 +		dataOk = EFalse;
   1.763 +		}
   1.764 +	TPtrC16 direction;
   1.765 +	if(!GetStringFromConfig(aSection, KDirection, direction))
   1.766 +		{
   1.767 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDirection);
   1.768 +		SetBlockResult(EFail);
   1.769 +		dataOk = EFalse;
   1.770 +		}
   1.771 +	if(dataOk)
   1.772 +		{
   1.773 +		TInt error(KErrNone);	
   1.774 +		if(mode == USB::KEPBulk)
   1.775 +			{
   1.776 +			INFO_PRINTF1(_L("Selected mode is KEPBulk"));
   1.777 +			if(direction == USB::KEPIn)
   1.778 +				{
   1.779 +				error = SetEndpoint(KUsbEpTypeBulk, KUsbEpDirIn);
   1.780 +				if (error != KErrNone)
   1.781 +					{
   1.782 +					ERR_PRINTF2(_L("Failed to set end point direction to KEPIn with error [%d]"), error);
   1.783 +					SetBlockResult(EFail);					
   1.784 +					}
   1.785 +				}
   1.786 +			else if(direction == USB::KEPOut)
   1.787 +				{
   1.788 +				error = SetEndpoint(KUsbEpTypeBulk, KUsbEpDirOut);
   1.789 +				if (error != KErrNone)
   1.790 +					{
   1.791 +					ERR_PRINTF2(_L("Failed to set end point direction to KEPOut with error [%d]"), error);
   1.792 +					SetBlockResult(EFail);
   1.793 +					}
   1.794 +				}
   1.795 +			else
   1.796 +				{
   1.797 +				ERR_PRINTF2(_L("USB - INCORRECT direction %S"), direction.AllocL());
   1.798 +				SetBlockResult(EFail);
   1.799 +				}
   1.800 +			}
   1.801 +		else if(mode == USB::KEPInterrupt)
   1.802 +			{
   1.803 +			INFO_PRINTF1(_L("Selected mode is KEPInterrupt"));
   1.804 +			if(direction == USB::KEPIn)
   1.805 +				{
   1.806 +				error = SetEndpoint(KUsbEpTypeInterrupt, KUsbEpDirIn);
   1.807 +				if (error != KErrNone)
   1.808 +					{
   1.809 +					ERR_PRINTF2(_L("Failed to set end point direction to KEPIn with error [%d]"), error);
   1.810 +					SetBlockResult(EFail);
   1.811 +					}
   1.812 +				}
   1.813 +			else if(direction == USB::KEPOut)
   1.814 +				{
   1.815 +				error = SetEndpoint(KUsbEpTypeInterrupt, KUsbEpDirOut);
   1.816 +				if (error != KErrNone)
   1.817 +					{
   1.818 +					ERR_PRINTF2(_L("Failed to set end point direction to KEPOut with error [%d]"), error);
   1.819 +					SetBlockResult(EFail);
   1.820 +					}
   1.821 +				}
   1.822 +			else
   1.823 +				{
   1.824 +				ERR_PRINTF2(_L("USB - INCORRECT direction %S"), direction.AllocL());
   1.825 +				SetBlockResult(EFail);
   1.826 +				}
   1.827 +			}
   1.828 +		else
   1.829 +			{
   1.830 +			ERR_PRINTF2(_L("USB - Mode not supported %S"), mode.AllocL());
   1.831 +			SetBlockResult(EFail);
   1.832 +			}
   1.833 +		}			
   1.834 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdUtilitySetEndPointL"));
   1.835 +	}
   1.836 +
   1.837 +
   1.838 +/**
   1.839 + * Sets a new endpoint for interface handled by this channel
   1.840 + * @param aEndpointType - USB endpoint type
   1.841 + * @param aEndpointDirection - USB endpoint direction	
   1.842 + */
   1.843 +TInt CT_RDevUsbcClientData::SetEndpoint(TUint aEndpointType, TUint aEndpointDirection)
   1.844 +	{
   1.845 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::SetEndpoint"));
   1.846 +	if(iConfiguredEndpoints == KMaxEndpointsPerClient)
   1.847 +		{
   1.848 +		ERR_PRINTF2(_L("Maximum number of endpoints [%d] for clients reached "), KMaxEndpointsPerClient);
   1.849 +		SetBlockResult(EFail);
   1.850 +		return KErrArgument;
   1.851 +		}
   1.852 +
   1.853 +	// search for the endpoints that match the settings user has given.
   1.854 +	for (TInt i = 0; i < iCaps().iTotalEndpoints; ++i)
   1.855 +		{
   1.856 +		const TUsbcEndpointCaps* caps = &iEndpointData[i].iCaps;
   1.857 +		const TInt maximumPacketSize = caps->MaxPacketSize();
   1.858 +
   1.859 +		// Check if endpoint in question matches with parameters we want to use for configuring an endpoint
   1.860 +		if ( (caps->iTypesAndDir & (aEndpointType | aEndpointDirection)) == (aEndpointType | aEndpointDirection) )
   1.861 +			{
   1.862 +			INFO_PRINTF3(_L("Configuring %s endpoint with direction %s"),
   1.863 +				(aEndpointType == KUsbEpTypeControl) ? _S("Control") :
   1.864 +				((aEndpointType == KUsbEpTypeIsochronous) ? _S("Isochronous") :
   1.865 +				((aEndpointType == KUsbEpTypeBulk) ? _S("Bulk") :
   1.866 +				((aEndpointType == KUsbEpTypeInterrupt) ? _S("Interrupt") :
   1.867 +				_S("Unknown")))),
   1.868 +				(aEndpointDirection == KUsbEpDirIn) ? _S("In") :
   1.869 +				((aEndpointDirection == KUsbEpDirOut) ? _S("Out") :
   1.870 +				((aEndpointDirection == KUsbEpDirBidirect) ? _S("Bidirectional") :
   1.871 +				_S("Unknown")))
   1.872 +				);
   1.873 +
   1.874 +			iInterface().iEndpointData[iConfiguredEndpoints].iType = aEndpointType;
   1.875 +			iInterface().iEndpointData[iConfiguredEndpoints].iDir = aEndpointDirection;
   1.876 +			iInterface().iEndpointData[iConfiguredEndpoints].iSize = maximumPacketSize;
   1.877 +			iTxMaxPacketSize = maximumPacketSize;
   1.878 +
   1.879 +			iConfiguredEndpoints++;
   1.880 +
   1.881 +			break;
   1.882 +			}
   1.883 +		}
   1.884 +
   1.885 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::SetEndpoint"));
   1.886 +	return KErrNone;
   1.887 +	}
   1.888 +
   1.889 +
   1.890 +
   1.891 +/**
   1.892 + * Sets interface with endpoints configured with CT_RDevUsbcClientData::SetEndpoint
   1.893 + * Note that endpoints must be set before calling this method
   1.894 + * 
   1.895 + * @param aBandwithwidthBufferingMask TInt contains IN and OUT bandwidth buffering masks combined 
   1.896 + *									 using binary OR operation
   1.897 + *			NOTE: IT IS TEST CASE SCRIPTERS RESPONSIBILITY TO CHECK VALID (or invalid for negative cases) MASKS
   1.898 + */
   1.899 +void CT_RDevUsbcClientData::DoCmdSetInterface(const TTEFSectionName& aSection)
   1.900 +	{
   1.901 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdSetInterface"));
   1.902 +	TInt bandwidthBufferingMask;
   1.903 +	TBool dataOk = ETrue;
   1.904 +	if(!GetIntFromConfig(aSection, KBufferingMask, bandwidthBufferingMask))
   1.905 +		{
   1.906 +		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBufferingMask);
   1.907 +		SetBlockResult(EFail);
   1.908 +		dataOk = EFalse;
   1.909 +		}
   1.910 +	if(dataOk)
   1.911 +		{
   1.912 +		INFO_PRINTF2(_L("bandwidthBufferingMask %d"), bandwidthBufferingMask);
   1.913 +		INFO_PRINTF2(_L("Configuring the interface settings with %d endpoints"), iConfiguredEndpoints);
   1.914 +
   1.915 +		if( iConfiguredEndpoints == 0 )
   1.916 +			{
   1.917 +			ERR_PRINTF1(_L("No endpoints have been set! Set endpoints before configuring interface"));
   1.918 +			SetBlockResult(EFail);
   1.919 +			}
   1.920 +		else
   1.921 +			{
   1.922 +			HBufC16* allocatedName = 0;
   1.923 +			TRAPD(error, allocatedName = interfaceName().AllocL());
   1.924 +		    if (error != KErrNone)
   1.925 +		        {
   1.926 +		        ERR_PRINTF2(_L("AllocL failed [%d]"), error);
   1.927 +		        SetBlockResult(EFail);
   1.928 +		        }
   1.929 +		    else
   1.930 +		    	{
   1.931 +		    	iInterface().iString = allocatedName;
   1.932 +				iInterface().iTotalEndpointsUsed = iConfiguredEndpoints;
   1.933 +				iInterface().iClass.iClassNum = 0xff;
   1.934 +				iInterface().iClass.iSubClassNum = 0xff;
   1.935 +				iInterface().iClass.iProtocolNum = 0xff;
   1.936 +				INFO_PRINTF2(_L("Using bandwidth buffering mask 0x%08x"), bandwidthBufferingMask);
   1.937 +
   1.938 +				error = iChannel->SetInterface(0, iInterface, bandwidthBufferingMask);
   1.939 +
   1.940 +				delete allocatedName;
   1.941 +				allocatedName = NULL;
   1.942 +				
   1.943 +				if (error != KErrNone)
   1.944 +					{
   1.945 +					ERR_PRINTF2(_L("Failed to set the interface [%d]"), error);
   1.946 +					SetError(error);
   1.947 +					}
   1.948 +				INFO_PRINTF2(_L("SetInterface returns [%d]"), error);
   1.949 +		    	}			
   1.950 +			}	    
   1.951 +		}
   1.952 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdSetInterface"));
   1.953 +	}
   1.954 +
   1.955 +
   1.956 +
   1.957 +
   1.958 +/**
   1.959 + * Tell test class to stop waiting 
   1.960 + * @param result from callback
   1.961 + */
   1.962 +void CT_RDevUsbcClientData::Signal(TInt aResult)
   1.963 +	{
   1.964 +	INFO_PRINTF2(_L("Signal %d"),aResult);
   1.965 +	}
   1.966 +
   1.967 +
   1.968 +/**
   1.969 + * Destroyer
   1.970 + */
   1.971 +
   1.972 +void  CT_RDevUsbcClientData::DoCmdDestructor()
   1.973 +	{
   1.974 +	INFO_PRINTF1(_L("*START*CT_RDevUsbcClientData::DoCmdDestructor"));
   1.975 +	DestroyData();
   1.976 +	INFO_PRINTF1(_L("*END*CT_RDevUsbcClientData::DoCmdDestructor"));
   1.977 +	}
   1.978 +
   1.979 +void CT_RDevUsbcClientData::DestroyData()
   1.980 +	{
   1.981 +	if(iChannel)
   1.982 +		{
   1.983 +		iChannel->Close();
   1.984 +		delete iChannel;
   1.985 +		iChannel = NULL;
   1.986 +		}
   1.987 +	}