os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/src/activerw.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/src/activerw.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1035 @@
     1.4 +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test/usb/t_usb_device/src/activerw.cpp
    1.18 +// USB Test Program T_USB_DEVICE, functional part.
    1.19 +// Device-side part, to work against T_USB_HOST running on the host.
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +#include "general.h"									// CActiveControl, CActiveRW
    1.24 +#include "config.h"
    1.25 +#include "activerw.h"
    1.26 +#include "activetimer.h" 
    1.27 +#include "usblib.h"										// Helpers
    1.28 +
    1.29 +_LIT(KFileName, "\\T_USBFILE.BIN");
    1.30 +
    1.31 +extern RTest test;
    1.32 +extern TBool gVerbose;
    1.33 +extern TBool gSkip;
    1.34 +extern TBool gStopOnFail;
    1.35 +extern TBool gAltSettingOnNotify;
    1.36 +extern TInt8 gSettingNumber [128];
    1.37 +extern TInt gSoakCount;
    1.38 +extern CActiveRW* gRW[KMaxConcurrentTests];				// the USB read/write active object
    1.39 +extern IFConfigPtr gInterfaceConfig [128] [KMaxInterfaceSettings];
    1.40 +extern TInt gActiveTestCount;
    1.41 +
    1.42 +static TInt gYieldRepeat = 0;
    1.43 +static const TInt KYieldRepeat = 100;
    1.44 +
    1.45 +//
    1.46 +// --- class CActiveRW ---------------------------------------------------------
    1.47 +//
    1.48 +
    1.49 +CActiveRW::CActiveRW(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting)
    1.50 +	: CActive(EPriorityNormal),
    1.51 +		#ifndef USB_SC
    1.52 +		iWriteBuf((TUint8 *)NULL,0,0),		// temporary initialisation
    1.53 +		iReadBuf((TUint8 *)NULL,0,0),		// temporary initialisation	
    1.54 +	  	#endif
    1.55 +	  iConsole(aConsole),
    1.56 +	  iPort(aPort),
    1.57 +	  iBufSz(0),
    1.58 +	  iMaxPktSz(0),
    1.59 +	  iCurrentXfer(ETxferNone),
    1.60 +	  iXferMode(::ENone),
    1.61 +	  iDoStop(EFalse),
    1.62 +	  iPktNum(0),
    1.63 +	  iFs(aFs),
    1.64 +	  iRepeat(0),
    1.65 +	  iComplete(EFalse),
    1.66 +	  iResult(EFalse),
    1.67 +	  iIndex (aIndex),
    1.68 +	  iLastSetting (aLastSetting)
    1.69 +	{
    1.70 +	gActiveTestCount++;
    1.71 +	TUSB_VERBOSE_PRINT("CActiveRW::CActiveRW()");
    1.72 +	}
    1.73 +
    1.74 +
    1.75 +CActiveRW* CActiveRW::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort, RFs aFs, TUint16 aIndex, TBool aLastSetting)
    1.76 +	{
    1.77 +	TUSB_VERBOSE_APRINT("CActiveRW::NewL()");
    1.78 +
    1.79 +	CActiveRW* self = new (ELeave) CActiveRW(aConsole, aPort, aFs, aIndex, aLastSetting);
    1.80 +	CleanupStack::PushL(self);
    1.81 +	self->ConstructL();
    1.82 +	CActiveScheduler::Add(self);
    1.83 +	CleanupStack::Pop();									// self
    1.84 +	return self;
    1.85 +	}
    1.86 +
    1.87 +
    1.88 +void CActiveRW::ConstructL()
    1.89 +	{
    1.90 +	TUSB_VERBOSE_PRINT("CActiveRW::ConstructL()");
    1.91 +
    1.92 +	// Create read timeout timer active object (but don't activate it yet)
    1.93 +	iTimeoutTimer = CActiveTimer::NewL(iConsole, iPort);
    1.94 +	if (!iTimeoutTimer)
    1.95 +		{
    1.96 +		TUSB_PRINT("Failed to create timeout timer");
    1.97 +		}
    1.98 +	}
    1.99 +
   1.100 +
   1.101 +CActiveRW::~CActiveRW()
   1.102 +	{
   1.103 +	TUSB_VERBOSE_PRINT("CActiveRW::~CActiveRW()");
   1.104 +	Cancel();												// base class
   1.105 +	delete iTimeoutTimer;
   1.106 +	#ifdef USB_SC
   1.107 +	if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient)
   1.108 +		{
   1.109 +		iSCReadBuf.Close();
   1.110 +		}
   1.111 +	if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient)
   1.112 +		{
   1.113 +		iSCWriteBuf.Close();
   1.114 +		}
   1.115 +	#else
   1.116 +	User::Free((TAny *)iReadBuf.Ptr());
   1.117 +	User::Free((TAny *)iWriteBuf.Ptr());
   1.118 +	#endif
   1.119 +	iFile.Close();
   1.120 +	gRW[iIndex] = NULL;
   1.121 +	gActiveTestCount--;
   1.122 +	}
   1.123 +
   1.124 +
   1.125 +void CActiveRW::SetTestParams(TestParamPtr aTpPtr)
   1.126 +	{
   1.127 +	iBufSz = aTpPtr->minSize;
   1.128 +	iPktNum = aTpPtr->packetNumber;
   1.129 +	
   1.130 +	iTestParams = *aTpPtr;
   1.131 +
   1.132 +	gYieldRepeat = ((iTestParams.settingRepeat != 0) || (iIndex == 0))? 0 : KYieldRepeat;
   1.133 +
   1.134 +	if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient)
   1.135 +		{
   1.136 +		#ifndef USB_SC
   1.137 +		TAny * newBuffer = User::Alloc(aTpPtr->maxSize);
   1.138 +		if (newBuffer == NULL)
   1.139 +			{
   1.140 +			TUSB_PRINT ("Failure to allocate heap memory");
   1.141 +			test(EFalse);
   1.142 +			}
   1.143 +		iReadBuf.Set((TUint8 *)newBuffer,0,(TInt)aTpPtr->maxSize);
   1.144 +		#endif
   1.145 +		TBuf8<KUsbDescSize_Endpoint> descriptor;
   1.146 +		TUSB_VERBOSE_PRINT2 ("GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.outPipe);
   1.147 +		TInt r = iPort->GetEndpointDescriptor(iTestParams.alternateSetting, (TENDPOINTNUMBER)iTestParams.outPipe, descriptor);
   1.148 +		if ((TUint)r != iReadSize)
   1.149 +			{
   1.150 +			TUSB_PRINT("Failed to get endpoint descriptor");
   1.151 +			test(EFalse);
   1.152 +			return;
   1.153 +			}
   1.154 +
   1.155 +		iMaxPktSz = EpSize(descriptor[KEpDesc_PacketSizeOffset],descriptor[KEpDesc_PacketSizeOffset+1]);		
   1.156 +		TUSB_VERBOSE_PRINT5 ("Out Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d",
   1.157 +			descriptor[KEpDesc_AddressOffset],descriptor[KEpDesc_AttributesOffset],iTestParams.interfaceNumber,iTestParams.alternateSetting,iMaxPktSz);
   1.158 +		if (!gSkip && iMaxPktSz != (TUint)gInterfaceConfig[iTestParams.interfaceNumber][iTestParams.alternateSetting]->iInfoPtr->iEndpointData[iTestParams.outPipe-1].iSize)
   1.159 +			{
   1.160 +			TUSB_PRINT4("Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iMaxPktSz);
   1.161 +			test(EFalse);
   1.162 +			return;
   1.163 +			}
   1.164 +		}
   1.165 +	if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient)
   1.166 +		{
   1.167 +		#ifndef USB_SC
   1.168 +		TAny * newBuffer = User::Alloc(aTpPtr->maxSize);
   1.169 +		if (newBuffer == NULL)
   1.170 +			{
   1.171 +			TUSB_PRINT ("Failure to allocate heap memory");
   1.172 +			test(EFalse);
   1.173 +			}
   1.174 +		iWriteBuf.Set((TUint8 *)newBuffer,0,(TInt)aTpPtr->maxSize);
   1.175 +		#endif
   1.176 +		TBuf8<KUsbDescSize_Endpoint> descriptor;
   1.177 +		TUSB_VERBOSE_PRINT2 ("GetEndpointDescriptor Alt Setting %d Endpoint %d",iTestParams.alternateSetting, iTestParams.inPipe);
   1.178 +		TInt r = iPort->GetEndpointDescriptor(iTestParams.alternateSetting, (TENDPOINTNUMBER)iTestParams.inPipe, descriptor);
   1.179 +		if (r != KErrNone)
   1.180 +			{
   1.181 +			TUSB_PRINT("Failed to get endpoint descriptor");
   1.182 +			test(EFalse);
   1.183 +			return;
   1.184 +			}
   1.185 +
   1.186 +		TInt maxPktSz = EpSize(descriptor[KEpDesc_PacketSizeOffset],descriptor[KEpDesc_PacketSizeOffset+1]);		
   1.187 +		TUSB_VERBOSE_PRINT5 ("In Endpoint 0x%x attributes 0x%x interface %d setting %d max packet size %d",
   1.188 +			descriptor[KEpDesc_AddressOffset],descriptor[KEpDesc_AttributesOffset],iTestParams.interfaceNumber,iTestParams.alternateSetting,maxPktSz);
   1.189 +		if (!gSkip && maxPktSz != gInterfaceConfig[iTestParams.interfaceNumber][iTestParams.alternateSetting]->iInfoPtr->iEndpointData[iTestParams.inPipe-1].iSize)
   1.190 +			{
   1.191 +			TUSB_PRINT4("Error - Interface %d Setting %d Endpoint %d Max Packet Size %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe,maxPktSz);
   1.192 +			test(EFalse);
   1.193 +			return;
   1.194 +			}
   1.195 +		}
   1.196 +		
   1.197 +	}
   1.198 +
   1.199 +
   1.200 +void CActiveRW::SetTransferMode(TXferMode aMode)
   1.201 +	{
   1.202 +	iXferMode = aMode;
   1.203 +	if (aMode == EReceiveOnly || aMode == ETransmitOnly)
   1.204 +		{
   1.205 +		// For streaming transfers we do this only once.
   1.206 +		iBufSz = iTestParams.maxSize;
   1.207 +		}
   1.208 +	}
   1.209 +
   1.210 +void CActiveRW::Suspend(TXferType aType)
   1.211 +	{
   1.212 +	if (aType == ESuspend)
   1.213 +		TUSB_VERBOSE_PRINT1("Index %d Suspend",iIndex);
   1.214 +	if (aType == EAltSetting)
   1.215 +		TUSB_VERBOSE_PRINT3("Index %d Suspend for Alternate Setting - interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting);	
   1.216 +	iStatus = KRequestPending;
   1.217 +	iCurrentXfer = aType;
   1.218 +	if (!IsActive())
   1.219 +		{
   1.220 +		SetActive();
   1.221 +		}
   1.222 +	}
   1.223 +
   1.224 +void CActiveRW::Resume()
   1.225 +	{	
   1.226 +	TUSB_VERBOSE_PRINT3("Index %d Resume interface %d setting %d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting);
   1.227 +	TRequestStatus* status = &iStatus;
   1.228 +	User::RequestComplete(status,KErrNone);
   1.229 +	if (!IsActive())
   1.230 +		{
   1.231 +		SetActive();
   1.232 +		}
   1.233 +	}
   1.234 +
   1.235 +void CActiveRW::Yield()
   1.236 +	{
   1.237 +	TUSB_VERBOSE_PRINT1("Index %d Scheduler Yield",iIndex);
   1.238 +	// removes the active object from the scheduler queue then adds it back in again
   1.239 +	Deque();	
   1.240 +	CActiveScheduler::Add(this);
   1.241 +	}
   1.242 +
   1.243 +void CActiveRW::ResumeAltSetting(TUint aAltSetting)
   1.244 +	{
   1.245 +	if (iCurrentXfer == EAltSetting && iTestParams.alternateSetting == aAltSetting)
   1.246 +		{
   1.247 +		Resume();
   1.248 +		}
   1.249 +	}
   1.250 +
   1.251 +void CActiveRW::StartOrSuspend()
   1.252 +	{
   1.253 +	TInt altSetting;
   1.254 +	
   1.255 +	iPort->GetAlternateSetting (altSetting);
   1.256 +	if (iTestParams.alternateSetting != altSetting)
   1.257 +		{
   1.258 +		Suspend(EAltSetting);
   1.259 +		}
   1.260 +	else
   1.261 +		{
   1.262 +		#ifdef USB_SC
   1.263 +		TInt r;
   1.264 +		if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber])
   1.265 +			{
   1.266 +			gSettingNumber[iTestParams.interfaceNumber] = iTestParams.alternateSetting;
   1.267 +			r = iPort->StartNextOutAlternateSetting(ETrue);
   1.268 +			TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r);
   1.269 +			test_Value(r, (r >= KErrNone) || (r == KErrNotReady)   || (r == KErrGeneral));
   1.270 +			}
   1.271 +		TUSB_VERBOSE_PRINT4 ("CActiveRW::StartOrSuspend() interface %d setting %d Out %d In %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iTestParams.inPipe);
   1.272 +		if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient)
   1.273 +			{
   1.274 +			r = iPort->OpenEndpoint(iSCReadBuf,iTestParams.outPipe);
   1.275 +			test_KErrNone(r);
   1.276 +			}
   1.277 +		if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient)
   1.278 +			{
   1.279 +			r = iPort->OpenEndpoint(iSCWriteBuf,iTestParams.inPipe);
   1.280 +			test_KErrNone(r);
   1.281 +			}
   1.282 +		#endif
   1.283 +		if (iXferMode == EReceiveOnly)
   1.284 +			{
   1.285 +			// read data and process any available
   1.286 +			iReadSize = ReadData();
   1.287 +			if (iReadSize != 0)
   1.288 +				{
   1.289 +				ProcessReadXfer();
   1.290 +				}
   1.291 +			}
   1.292 +		else
   1.293 +			{
   1.294 +			SendData();										// or we send data
   1.295 +			if (iXferMode == ETransmitOnly)
   1.296 +				{
   1.297 +				iPktNum++;				
   1.298 +				iRepeat++;		
   1.299 +				}
   1.300 +			}	
   1.301 +		}
   1.302 +	}
   1.303 +
   1.304 +void CActiveRW::RunL()
   1.305 +	{
   1.306 +	#ifdef USB_SC
   1.307 +	TInt r = 0;
   1.308 +	#else
   1.309 +	TInt altSetting;	
   1.310 +	#endif
   1.311 +	
   1.312 +	TUSB_VERBOSE_PRINT("CActiveRW::RunL()");
   1.313 +
   1.314 +	if ((iStatus != KErrNone) && (iStatus != KErrEof))
   1.315 +		{
   1.316 +		TUSB_PRINT1("Error %d in RunL", iStatus.Int());
   1.317 +		}
   1.318 +	if (iDoStop)
   1.319 +		{
   1.320 +		TUSB_PRINT("Stopped");
   1.321 +		iDoStop = EFalse;
   1.322 +		return;
   1.323 +		}
   1.324 +	switch (iCurrentXfer)
   1.325 +		{
   1.326 +	case EWaitSetting:
   1.327 +		#ifdef USB_SC
   1.328 +		if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient)
   1.329 +			{
   1.330 +			r = iSCReadBuf.Close();
   1.331 +			test_KErrNone(r);
   1.332 +			}
   1.333 +		if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient)
   1.334 +			{
   1.335 +			r = iSCWriteBuf.Close();
   1.336 +			test_KErrNone(r);
   1.337 +			}
   1.338 +		#endif
   1.339 +		if (iTestParams.settingRepeat  && ((iRepeat < iTestParams.repeat) || !iLastSetting))
   1.340 +			{
   1.341 +			gRW[iTestParams.afterIndex]->Resume();			
   1.342 +			}
   1.343 +		Suspend(ESuspend);	
   1.344 +		break;
   1.345 +			
   1.346 +	case ESuspend:
   1.347 +		#ifdef USB_SC
   1.348 +		TUSB_VERBOSE_PRINT3("Index %d Resumed interface %d setting test=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting);	
   1.349 +		if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber])
   1.350 +			{
   1.351 +			r = iPort->StartNextOutAlternateSetting(ETrue);
   1.352 +			TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r);
   1.353 +			test_Value(r, (r >= KErrNone) || (r == KErrNotReady)  || (r == KErrGeneral));
   1.354 +			if (r != KErrNotReady)
   1.355 +				{
   1.356 +				gSettingNumber[iTestParams.interfaceNumber] = r;
   1.357 +				}
   1.358 +			if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber])
   1.359 +				{
   1.360 +				Suspend(EAltSetting);
   1.361 +				break;
   1.362 +				}
   1.363 +			}
   1.364 +		#else
   1.365 +		iPort->GetAlternateSetting (altSetting);
   1.366 +		TUSB_VERBOSE_PRINT4("Index %d Resumed interface %d setting test=%d actual=%d",iIndex,iTestParams.interfaceNumber,iTestParams.alternateSetting,altSetting);	
   1.367 +		if (gAltSettingOnNotify)
   1.368 +			{
   1.369 +			if (iTestParams.alternateSetting != altSetting)
   1.370 +				{
   1.371 +				Suspend(EAltSetting);
   1.372 +				break;
   1.373 +				}
   1.374 +			}
   1.375 +		#endif
   1.376 +			
   1.377 +		// If alternate setting is ok drops through to EAltSetting to start next read or write
   1.378 +		iCurrentXfer = EAltSetting;
   1.379 +			
   1.380 +	case EAltSetting:
   1.381 +		#ifdef USB_SC
   1.382 +		if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber])
   1.383 +			{
   1.384 +			r = iPort->StartNextOutAlternateSetting(ETrue);
   1.385 +			TUSB_VERBOSE_PRINT1("StartNextOutAlternateSetting retValue %d",r);
   1.386 +			test_Value(r, (r >= KErrNone) || (r == KErrNotReady)   || (r == KErrGeneral));
   1.387 +			if (r != KErrNotReady)
   1.388 +				{
   1.389 +				gSettingNumber[iTestParams.interfaceNumber] = r;
   1.390 +				}
   1.391 +			if (iTestParams.alternateSetting != gSettingNumber[iTestParams.interfaceNumber])
   1.392 +				{
   1.393 +				Suspend(EAltSetting);
   1.394 +				break;
   1.395 +				}
   1.396 +			}
   1.397 +		TUSB_VERBOSE_PRINT4 ("CActiveRW::Runl() EAltSetting interface %d setting %d Out %d In %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe,iTestParams.inPipe);
   1.398 +		if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient)
   1.399 +			{
   1.400 +			r = iPort->OpenEndpoint(iSCReadBuf,iTestParams.outPipe);
   1.401 +			test_KErrNone(r);
   1.402 +			}
   1.403 +		if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient)
   1.404 +			{
   1.405 +			r = iPort->OpenEndpoint(iSCWriteBuf,iTestParams.inPipe);
   1.406 +			test_KErrNone(r);
   1.407 +			}
   1.408 +		#endif
   1.409 +		if (iXferMode == EReceiveOnly)
   1.410 +			{
   1.411 +			// read data and process any available
   1.412 +			iReadSize = ReadData();
   1.413 +			if (iReadSize != 0)
   1.414 +				{
   1.415 +				ProcessReadXfer();
   1.416 +				}		
   1.417 +			}
   1.418 +		else
   1.419 +			{
   1.420 +			SendData();										// or we send data
   1.421 +			if (iXferMode == ETransmitOnly)
   1.422 +				{
   1.423 +				iPktNum++;				
   1.424 +				iRepeat++;		
   1.425 +				}
   1.426 +			}
   1.427 +		break;
   1.428 +
   1.429 +	case EWriteXfer:
   1.430 +		ProcessWriteXfer();
   1.431 +		break;
   1.432 +		
   1.433 +	case EReadXfer:
   1.434 +		#ifdef USB_SC
   1.435 +		iReadSize = ReadData();
   1.436 +		if (iReadSize != 0)
   1.437 +			{
   1.438 +			ProcessReadXfer();
   1.439 +			}
   1.440 +		#else
   1.441 +		iReadSize = iReadBuf.Length();
   1.442 +		ProcessReadXfer();
   1.443 +		#endif
   1.444 +		break;
   1.445 +		
   1.446 +	default:
   1.447 +		TUSB_PRINT("Oops. (Shouldn't end up here...)");
   1.448 +		break;
   1.449 +		}
   1.450 +	return;
   1.451 +	}
   1.452 +
   1.453 +void CActiveRW::ProcessWriteXfer()
   1.454 +	{
   1.455 +	if (iXferMode == ETransmitOnly)
   1.456 +		{
   1.457 +		if (iTestParams.settingRepeat && iRepeat)
   1.458 +			{	
   1.459 +			if (((iRepeat % iTestParams.settingRepeat) == 0) || (iRepeat >= iTestParams.repeat))
   1.460 +				{
   1.461 +				if ((iRepeat < iTestParams.repeat) || !iLastSetting)
   1.462 +					{
   1.463 +					#ifdef USB_SC
   1.464 +					if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient)
   1.465 +						{
   1.466 +						test_KErrNone(iSCWriteBuf.Close());
   1.467 +						}
   1.468 +					#endif
   1.469 +					gRW[iTestParams.afterIndex]->Resume();			
   1.470 +					}
   1.471 +				if (iRepeat < iTestParams.repeat)
   1.472 +					{
   1.473 +					Suspend(ESuspend);	
   1.474 +					return;					
   1.475 +					}
   1.476 +				}
   1.477 +			}
   1.478 +
   1.479 +		if ((iTestParams.repeat == 0) || (iRepeat < iTestParams.repeat))
   1.480 +			{
   1.481 +			// Yield the scheduler to ensure other activeObjects can run
   1.482 +			if (iRepeat && gYieldRepeat)
   1.483 +				{
   1.484 +				if ((iRepeat % gYieldRepeat) == 0)
   1.485 +					{
   1.486 +					Yield();
   1.487 +					}
   1.488 +				}
   1.489 +			SendData();							// next we send data			
   1.490 +			iPktNum++;				
   1.491 +			iRepeat++;
   1.492 +			}
   1.493 +		else
   1.494 +			{
   1.495 +			TestComplete(ETrue);
   1.496 +			}
   1.497 +		}
   1.498 +	else
   1.499 +		{
   1.500 +		// read data and process any available
   1.501 +		iReadSize = ReadData();
   1.502 +		if (iReadSize != 0)
   1.503 +			{
   1.504 +			ProcessReadXfer();
   1.505 +			}
   1.506 +		}
   1.507 +
   1.508 +	return;
   1.509 +	}
   1.510 +
   1.511 +void CActiveRW::ProcessReadXfer()
   1.512 +	{
   1.513 +	if ((iReadOffset + iReadSize) > iBufSz)
   1.514 +		{
   1.515 +		TUSB_PRINT2("*** rcv'd too much data: 0x%x (expected: 0x%x)", iReadOffset + iReadSize, iBufSz);
   1.516 +		test(EFalse);
   1.517 +		}
   1.518 +
   1.519 +	if (iXferMode == EReceiveOnly)
   1.520 +		{
   1.521 +		if (iReadOffset == 0)
   1.522 +			{
   1.523 +			#ifdef USB_SC
   1.524 +			const TUint32 num = *reinterpret_cast<const TUint32*>(iSCReadData);
   1.525 +			#else
   1.526 +			const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr());
   1.527 +			#endif	
   1.528 +			if (num != iPktNum)
   1.529 +				{
   1.530 +				TUSB_PRINT3("*** Repeat %d rcv'd wrong pkt number: 0x%x (expected: 0x%x)", iRepeat, num, iPktNum);
   1.531 +				iPktNum = num;
   1.532 +				test(EFalse);
   1.533 +				}
   1.534 +			}
   1.535 +		if (iDiskAccessEnabled)
   1.536 +			{
   1.537 +			// Write out to disk previous completed Read
   1.538 +			#ifdef USB_SC
   1.539 +			TPtr8 readBuf((TUint8 *)iSCReadData,iReadSize,iReadSize);
   1.540 +			WriteBufferToDisk(readBuf, iReadSize);
   1.541 +			#else	
   1.542 +			TUSB_VERBOSE_PRINT2("Max Buffer Size = %d (iReadBuf.Size(): %d)", iTestParams.maxSize, iReadBuf.Size());
   1.543 +			WriteBufferToDisk(iReadBuf, iTestParams.maxSize);
   1.544 +			#endif
   1.545 +			}		
   1.546 +		iReadOffset += iReadSize;
   1.547 +		if (iReadOffset >= iBufSz)
   1.548 +			{
   1.549 +			iReadOffset = 0;			
   1.550 +			}
   1.551 +		else
   1.552 +			{
   1.553 +			#ifdef USB_SC
   1.554 +			iReadSize = ReadData();
   1.555 +			if (iReadSize)
   1.556 +				{
   1.557 +				ProcessReadXfer();
   1.558 +				}
   1.559 +			#endif
   1.560 +			return;
   1.561 +			}
   1.562 +		iPktNum++;
   1.563 +		iRepeat++;
   1.564 +		iReadSize = 0;
   1.565 +		if (iTestParams.settingRepeat)
   1.566 +			{	
   1.567 +			if (((iRepeat % iTestParams.settingRepeat) == 0) || (iRepeat >= iTestParams.repeat))
   1.568 +				{
   1.569 +				#ifdef USB_SC
   1.570 +				if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient)
   1.571 +					{
   1.572 +					test_KErrNone(iSCReadBuf.Close());
   1.573 +					}
   1.574 +				#endif
   1.575 +				if ((iRepeat < iTestParams.repeat) || !iLastSetting)
   1.576 +					{
   1.577 +					gRW[iTestParams.afterIndex]->Resume();			
   1.578 +					}
   1.579 +				if (iRepeat < iTestParams.repeat)
   1.580 +					{
   1.581 +					Suspend(ESuspend);	
   1.582 +					return;					
   1.583 +					}
   1.584 +				}
   1.585 +			}
   1.586 +		if ((iTestParams.repeat == 0) || (iRepeat < iTestParams.repeat))
   1.587 +			{
   1.588 +			// Yield the scheduler to ensure other activeObjects can run
   1.589 +			if (iRepeat && gYieldRepeat)
   1.590 +				{
   1.591 +				if ((iRepeat % gYieldRepeat) == 0)
   1.592 +					{
   1.593 +					Yield();
   1.594 +					}
   1.595 +				}
   1.596 +			#ifdef USB_SC
   1.597 +			TRequestStatus* status = &iStatus;
   1.598 +			User::RequestComplete(status,KErrNone);
   1.599 +			if (!IsActive())
   1.600 +				{
   1.601 +				SetActive();
   1.602 +				}	
   1.603 +			#else
   1.604 +			iReadSize = ReadData();			
   1.605 +			#endif
   1.606 +			}
   1.607 +		else
   1.608 +			{
   1.609 +			TestComplete(ETrue);
   1.610 +			}
   1.611 +		}
   1.612 +	else
   1.613 +		{
   1.614 +		if (iXferMode == ELoopComp)
   1.615 +			{
   1.616 +			test(CompareBuffers());
   1.617 +			}
   1.618 +		else if (iBufSz > 3)
   1.619 +			{
   1.620 +			if (iReadOffset == 0)
   1.621 +				{
   1.622 +				#ifdef USB_SC
   1.623 +				const TUint32 num = *reinterpret_cast<const TUint32*>(iSCReadData);
   1.624 +				#else
   1.625 +				const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr());
   1.626 +				#endif
   1.627 +				if (num != iPktNum)
   1.628 +					{
   1.629 +					TUSB_PRINT2("*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum);
   1.630 +					}
   1.631 +				}
   1.632 +			}
   1.633 +		iReadOffset += iReadSize;
   1.634 +		if (iReadOffset >= iBufSz)
   1.635 +			{
   1.636 +			iReadOffset = 0;			
   1.637 +			}
   1.638 +		else
   1.639 +			{
   1.640 +			iReadSize = ReadData();
   1.641 +			if (iReadSize)
   1.642 +				{
   1.643 +				ProcessReadXfer();
   1.644 +				}
   1.645 +			return;
   1.646 +			}
   1.647 +		if ((TUint)iBufSz == iTestParams.maxSize)
   1.648 +			{
   1.649 +			iBufSz = iTestParams.minSize;
   1.650 +			}
   1.651 +		else
   1.652 +			{
   1.653 +			iBufSz++;
   1.654 +			}
   1.655 +		iPktNum++;
   1.656 +		iRepeat++;
   1.657 +		iReadSize = 0;
   1.658 +		if (iTestParams.settingRepeat)
   1.659 +			{	
   1.660 +			if (((iRepeat % iTestParams.settingRepeat) == 0) || (iRepeat >= iTestParams.repeat))
   1.661 +				{
   1.662 +				if (iRepeat < iTestParams.repeat)
   1.663 +					{
   1.664 +					SendWaitSetting();
   1.665 +					return;					
   1.666 +					}
   1.667 +				else
   1.668 +					{
   1.669 +					#ifdef USB_SC
   1.670 +					if ((TENDPOINTNUMBER)iTestParams.outPipe <= KMaxEndpointsPerClient)
   1.671 +						{
   1.672 +						test_KErrNone(iSCReadBuf.Close());
   1.673 +						}
   1.674 +					if ((TENDPOINTNUMBER)iTestParams.inPipe <= KMaxEndpointsPerClient)
   1.675 +						{
   1.676 +						test_KErrNone(iSCWriteBuf.Close());
   1.677 +						}
   1.678 +					#endif	
   1.679 +					if (!iLastSetting)
   1.680 +						{
   1.681 +						gRW[iTestParams.afterIndex]->Resume();			
   1.682 +						}
   1.683 +					}
   1.684 +				}
   1.685 +			}
   1.686 +			
   1.687 +		if ((iTestParams.repeat == 0) || (iRepeat < iTestParams.repeat))
   1.688 +			{
   1.689 +			// Yield the scheduler to ensure other activeObjects can run
   1.690 +			if (iRepeat && gYieldRepeat)
   1.691 +				{
   1.692 +				if ((iRepeat % gYieldRepeat) == 0)
   1.693 +					{
   1.694 +					Yield();
   1.695 +					}
   1.696 +				}
   1.697 +			SendData();				
   1.698 +			}
   1.699 +		else
   1.700 +			{
   1.701 +			TestComplete(ETrue);
   1.702 +			}	
   1.703 +		}
   1.704 +
   1.705 +	return;
   1.706 +	}
   1.707 +
   1.708 +void CActiveRW::SendWaitSetting()
   1.709 +	{
   1.710 +	__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 662));
   1.711 +	#ifdef	USB_SC
   1.712 +	TAny* inBuffer;
   1.713 +	TUint inBufLength;
   1.714 +	test_KErrNone(iSCWriteBuf.GetInBufferRange(inBuffer, inBufLength));
   1.715 +	test_KErrNone(iSCWriteBuf.WriteBuffer(inBuffer,KWaitSettingSize,FALSE,iStatus));
   1.716 +	#else
   1.717 +	iWriteBuf.SetLength(KWaitSettingSize);
   1.718 +	iPort->Write(iStatus, (TENDPOINTNUMBER)iTestParams.inPipe, iWriteBuf, KWaitSettingSize);
   1.719 +	#endif
   1.720 +	iCurrentXfer = EWaitSetting;
   1.721 +	if (!IsActive())
   1.722 +		{
   1.723 +		SetActive();
   1.724 +		}
   1.725 +	}
   1.726 +
   1.727 +	
   1.728 +void CActiveRW::SendData()
   1.729 +	{
   1.730 +	__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 663));
   1.731 +	#ifdef	USB_SC
   1.732 +	TUint8* inBuffer;
   1.733 +	TUint inBufLength;
   1.734 +	test_KErrNone(iSCWriteBuf.GetInBufferRange((TAny*&)inBuffer, inBufLength));
   1.735 +	if (iDiskAccessEnabled)
   1.736 +		{
   1.737 +		TPtr8 writeBuf((TUint8 *)inBuffer,iBufSz,iBufSz);
   1.738 +		ReadBufferFromDisk(writeBuf, iBufSz);
   1.739 +		}
   1.740 +	if (iBufSz > 3)
   1.741 +		*reinterpret_cast<TUint32*>(inBuffer) = iPktNum;
   1.742 +	
   1.743 +	if (iXferMode == ELoopComp)
   1.744 +		{
   1.745 +		for (TUint i = 4; i < iBufSz; i++)
   1.746 +			{
   1.747 +			*(inBuffer+i) = static_cast<TUint8>((iPktNum+i) & 0x000000ff);
   1.748 +			}
   1.749 +		}
   1.750 +	TUSB_VERBOSE_PRINT3("SendData interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe);
   1.751 +	iCurrentXfer = EWriteXfer;
   1.752 +	TInt r = iSCWriteBuf.WriteBuffer(inBuffer, iBufSz, FALSE, iStatus);
   1.753 +	test_KErrNone(r);
   1.754 +	#else
   1.755 +	if (iDiskAccessEnabled)
   1.756 +		{
   1.757 +		ReadBufferFromDisk(iWriteBuf, iBufSz);
   1.758 +		}
   1.759 +	iWriteBuf.SetLength(iBufSz);
   1.760 +	if (iBufSz > 3)
   1.761 +		*reinterpret_cast<TUint32*>(const_cast<TUint8*>(iWriteBuf.Ptr())) = iPktNum;
   1.762 +	if (iXferMode == ELoopComp)
   1.763 +		{
   1.764 +		for (TUint i = 4; i < iBufSz; i++)
   1.765 +			{
   1.766 +			iWriteBuf[i] = static_cast<TUint8>((iPktNum+i) & 0x000000ff);
   1.767 +			}
   1.768 +		}
   1.769 +
   1.770 +	TUSB_VERBOSE_PRINT3("SendData interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.inPipe);
   1.771 +	iCurrentXfer = EWriteXfer;
   1.772 +	iPort->Write(iStatus, (TENDPOINTNUMBER)iTestParams.inPipe, iWriteBuf, iBufSz);
   1.773 +	#endif
   1.774 +	if (!IsActive())
   1.775 +		{
   1.776 +		SetActive();
   1.777 +		}
   1.778 +	}
   1.779 +
   1.780 +TInt CActiveRW::WriteToDisk(TChar aDriveLetter)
   1.781 +	{
   1.782 +	iDiskAccessEnabled = ETrue;
   1.783 +	TInt r = KErrNone;
   1.784 +
   1.785 +	iFileName.Format(_L("%c:"), aDriveLetter.operator TUint());
   1.786 +	iFileName.Append(KFileName);
   1.787 +	TUSB_PRINT1("\nFilename = %S", &iFileName);
   1.788 +
   1.789 +	// open the record file
   1.790 +	r = iFile.Replace(iFs, iFileName, EFileWrite);
   1.791 +	iFileOffset = 0;
   1.792 +	if (r != KErrNone)
   1.793 +		{
   1.794 +		TUSB_PRINT1("RFile::Replace() returned %d", r);
   1.795 +		iDiskAccessEnabled = EFalse;
   1.796 +		return r;
   1.797 +		}
   1.798 +		
   1.799 +	return r;
   1.800 +	}
   1.801 +
   1.802 +
   1.803 +TInt CActiveRW::ReadFromDisk(TChar aDriveLetter, TInt aMaxFileSize)
   1.804 +	{
   1.805 +	iDiskAccessEnabled = ETrue;
   1.806 +	TInt r = KErrNone;
   1.807 +
   1.808 +	iFileName.Format(_L("%c:"), aDriveLetter.operator TUint());
   1.809 +	iFileName.Append(KFileName);
   1.810 +	TUSB_PRINT1("\nFilename = %S", &iFileName);
   1.811 +	TUSB_PRINT1("File size: %d", aMaxFileSize);
   1.812 +
   1.813 +	// First create the file & fill it
   1.814 +	r = iFile.Replace(iFs, iFileName, EFileWrite);
   1.815 +	if (r != KErrNone)
   1.816 +		{
   1.817 +		TUSB_PRINT1("RFile::Replace() returned %d", r);
   1.818 +		iDiskAccessEnabled = EFalse;
   1.819 +		return r;
   1.820 +		}
   1.821 +	const TInt KBufferSize = 4 * 1024;
   1.822 +	TBuf8<KBufferSize> buffer;
   1.823 +	buffer.SetLength(KBufferSize);
   1.824 +	for (TInt n = 0; n < KBufferSize; n++)
   1.825 +		{
   1.826 +		buffer[n] = static_cast<TUint8>(n & 0x000000ff);
   1.827 +		}
   1.828 +	TUSB_PRINT("Writing data to file (this may take some minutes...)");
   1.829 +	for (TInt n = 0; n < aMaxFileSize; n += KBufferSize)
   1.830 +		{
   1.831 +		r = iFile.Write(buffer, KBufferSize);
   1.832 +		if (r != KErrNone)
   1.833 +			{
   1.834 +			TUSB_PRINT1("RFile::Write() returned %d (disk full?)", r);
   1.835 +			iFile.Close();
   1.836 +			iDiskAccessEnabled = EFalse;
   1.837 +			return r;
   1.838 +			}
   1.839 +		}
   1.840 +	TUSB_PRINT("Done.");
   1.841 +	iFile.Close();
   1.842 +	// Now open the file for reading
   1.843 +	r = iFile.Open(iFs, iFileName, EFileRead);
   1.844 +	if (r != KErrNone)
   1.845 +		{
   1.846 +		TUSB_PRINT1("RFile::Open() returned %d", r);
   1.847 +		iDiskAccessEnabled = EFalse;
   1.848 +		return r;
   1.849 +		}
   1.850 +	iFileOffset = 0;
   1.851 +
   1.852 +	return r;
   1.853 +	}
   1.854 +
   1.855 +
   1.856 +void CActiveRW::WriteBufferToDisk(TDes8& aBuffer, TInt aLen)
   1.857 +	{
   1.858 +	TUSB_VERBOSE_PRINT1("CActiveRW::WriteBufferToDisk(), len = %d", aLen);
   1.859 +	TInt r = iFile.Write(aBuffer, aLen);
   1.860 +	if (r != KErrNone)
   1.861 +		{
   1.862 +		TUSB_PRINT2("Error writing to %S (%d)", &iFileName, r);
   1.863 +		iDiskAccessEnabled = EFalse;
   1.864 +		return;
   1.865 +		}
   1.866 +	iFileOffset += aLen;
   1.867 +	}
   1.868 +
   1.869 +
   1.870 +void CActiveRW::ReadBufferFromDisk(TDes8& aBuffer, TInt aLen)
   1.871 +	{
   1.872 +	const TInt r = iFile.Read(aBuffer, aLen);
   1.873 +	if (r != KErrNone)
   1.874 +		{
   1.875 +		TUSB_PRINT2("Error reading from %S (%d)", &iFileName, r);
   1.876 +		iDiskAccessEnabled = EFalse;
   1.877 +		return;
   1.878 +		}
   1.879 +	TInt readLen = aBuffer.Length();
   1.880 +	TUSB_VERBOSE_PRINT1("CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen);
   1.881 +	if (readLen < aLen)
   1.882 +		{
   1.883 +		TUSB_PRINT3("Only %d bytes of %d read from file %S)",
   1.884 +					readLen, aLen, &iFileName);
   1.885 +		iDiskAccessEnabled = EFalse;
   1.886 +		return;
   1.887 +		}
   1.888 +	iFileOffset += aLen;
   1.889 +	}
   1.890 +
   1.891 +
   1.892 +TUint CActiveRW::ReadData()
   1.893 +	{
   1.894 +	__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 664));
   1.895 +	iCurrentXfer = EReadXfer;
   1.896 +	#ifdef	USB_SC
   1.897 +	TUint readSize = 0;			// note that this returns zero when asynchronous read is pending 
   1.898 +	TInt r = 0;
   1.899 +	do
   1.900 +		{
   1.901 +		r = iSCReadBuf.GetBuffer (iSCReadData,readSize,iReadZlp,iStatus);
   1.902 +		test_Value(r, (r == KErrNone) || (r == KErrCompletion) || (r == KErrEof));
   1.903 +		TUSB_VERBOSE_PRINT4("Get Buffer Return code %d Status %d DataPtr 0x%x Size %d", r, iStatus.Int(),iSCReadData,readSize);	
   1.904 +		}
   1.905 +	while ((r == KErrCompletion && readSize == 0) || (r == KErrEof));
   1.906 +	if (r == KErrCompletion)
   1.907 +		{
   1.908 +		return readSize;
   1.909 +		}
   1.910 +	else
   1.911 +		{
   1.912 +		if (!IsActive())
   1.913 +			{
   1.914 +			SetActive();
   1.915 +			}
   1.916 +		return 0;
   1.917 +		}
   1.918 +	#else
   1.919 +	iReadBuf.SetLength (0);
   1.920 +	if (iBufSz <= iMaxPktSz)
   1.921 +		{
   1.922 +		// Testing the packet version of Read()
   1.923 +		TUSB_VERBOSE_PRINT3("ReadData (single packet) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe);
   1.924 +		iPort->ReadPacket(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf, iBufSz);
   1.925 +		}
   1.926 +	else if ((TUint)iBufSz == iTestParams.maxSize)
   1.927 +		{
   1.928 +		// Testing the two-parameter version
   1.929 +		TUSB_VERBOSE_PRINT3("ReadData (w/o length) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe);
   1.930 +		iPort->Read(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf);
   1.931 +		}
   1.932 +	else
   1.933 +		{
   1.934 +		// otherwise, we use the universal default version
   1.935 +		// Testing the three-parameter version
   1.936 +		TUSB_VERBOSE_PRINT3("ReadData (normal) interface %d setting %d endpoint %d",iTestParams.interfaceNumber,iTestParams.alternateSetting,iTestParams.outPipe);
   1.937 +		iPort->Read(iStatus, (TENDPOINTNUMBER)iTestParams.outPipe, iReadBuf, iBufSz);
   1.938 +		}
   1.939 +	if (!IsActive())
   1.940 +		{
   1.941 +		SetActive();
   1.942 +		}
   1.943 +	return 0;
   1.944 +	#endif
   1.945 +	}
   1.946 +
   1.947 +
   1.948 +void CActiveRW::Stop()
   1.949 +	{
   1.950 +	if (!IsActive())
   1.951 +		{
   1.952 +		TUSB_PRINT("CActiveRW::Stop(): Not active");
   1.953 +		return;
   1.954 +		}
   1.955 +	TUSB_PRINT("Cancelling outstanding transfer requests\n");
   1.956 +	iBufSz = 0;
   1.957 +	iPktNum = 0;
   1.958 +	iDoStop = ETrue;
   1.959 +	iCurrentXfer = ETxferNone;
   1.960 +	Cancel();
   1.961 +	}
   1.962 +
   1.963 +
   1.964 +void CActiveRW::DoCancel()
   1.965 +	{
   1.966 +	TUSB_VERBOSE_PRINT("CActiveRW::DoCancel()");
   1.967 +	// Canceling the transfer requests can be done explicitly
   1.968 +	// for every transfer...
   1.969 +	iPort->WriteCancel((TENDPOINTNUMBER)iTestParams.inPipe);
   1.970 +	iPort->ReadCancel((TENDPOINTNUMBER)iTestParams.outPipe);
   1.971 +	// or like this:
   1.972 +	// iPort->EndpointTransferCancel(~0);	
   1.973 +	}
   1.974 +
   1.975 +
   1.976 +TBool CActiveRW::CompareBuffers()
   1.977 +	{
   1.978 +	TUSB_VERBOSE_PRINT2("CActiveRW::CompareBuffers() ReadOffset %d ReadSize %d",iReadOffset,iReadSize);
   1.979 +	#ifdef USB_SC
   1.980 +	TUint8 *readPtr = reinterpret_cast<TUint8*>(iSCReadData);
   1.981 +	TUint8* writePtr;
   1.982 +	TUint inBufLength;
   1.983 +	test_KErrNone(iSCWriteBuf.GetInBufferRange((TAny*&)writePtr, inBufLength));
   1.984 +	writePtr += iReadOffset;
   1.985 +	#endif
   1.986 +	for (TUint i = 0; i < iReadSize; i++)
   1.987 +		{
   1.988 +		#ifdef USB_SC
   1.989 +		if (*readPtr != *writePtr)
   1.990 +			{
   1.991 +			TUSB_PRINT3 ("*** Error while comparing tx & rx buffers packet 0x%x length %d index %d",iPktNum, iReadSize,i + iReadOffset); 
   1.992 +			TUSB_PRINT2 ("*** Read byte 0x%x Write byte 0x%x",*readPtr,*writePtr); 
   1.993 +			return EFalse;
   1.994 +			}
   1.995 +		readPtr++;
   1.996 +		writePtr++;
   1.997 +		#else
   1.998 +		if (iReadBuf[i] != iWriteBuf[i + iReadOffset])
   1.999 +			{
  1.1000 +			TUSB_PRINT3 ("*** Error while comparing tx & rx buffers packet 0x%x length %d index %d",iPktNum, iReadSize,i + iReadOffset); 
  1.1001 +			TUSB_PRINT5 ("WriteBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x",
  1.1002 +				iWriteBuf[i], iWriteBuf[i+1], iWriteBuf[i+2], iWriteBuf[i+3], iWriteBuf[i+4]); 
  1.1003 +			TUSB_PRINT5 ("ReadBuf Start 0x%x 0x%x 0x%x 0x%x 0x%x",
  1.1004 +				iReadBuf[i], iReadBuf[i+1], iReadBuf[i+2], iReadBuf[i+3], iReadBuf[i+4]);
  1.1005 +			if (iReadSize >= 10)
  1.1006 +				{
  1.1007 +				TUSB_PRINT5 ("WriteBuf End 0x%x 0x%x 0x%x 0x%x 0x%x",
  1.1008 +					iWriteBuf[iReadSize-5], iWriteBuf[iReadSize-4], iWriteBuf[iReadSize-3], iWriteBuf[iReadSize-2], iWriteBuf[iReadSize-1]); 
  1.1009 +				TUSB_PRINT5 ("ReadBuf End 0x%x 0x%x 0x%x 0x%x 0x%x",
  1.1010 +					iReadBuf[iReadSize-5], iReadBuf[iReadSize-4], iReadBuf[iReadSize-3], iReadBuf[iReadSize-2], iReadBuf[iReadSize-1]); 
  1.1011 +				}
  1.1012 +			return EFalse;
  1.1013 +			}
  1.1014 +		#endif
  1.1015 +		}
  1.1016 +	return ETrue;
  1.1017 +	}
  1.1018 +
  1.1019 +void CActiveRW::TestComplete(TBool aResult)
  1.1020 +	{
  1.1021 +	TUSB_VERBOSE_PRINT("CActiveRW::TestComplete()");
  1.1022 +
  1.1023 +	iResult = aResult;
  1.1024 +	
  1.1025 +	if (iComplete || !iResult || iTestParams.repeat == 0)
  1.1026 +		{
  1.1027 +		test(iResult);
  1.1028 +		test.End();
  1.1029 +		gRW[iIndex] = NULL;
  1.1030 +		delete this;
  1.1031 +		}
  1.1032 +	else
  1.1033 +		{
  1.1034 +		iComplete = ETrue;
  1.1035 +		}
  1.1036 +	}
  1.1037 +
  1.1038 +// -eof-