os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-1230.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// @file PBASE-T_USBDI-1230.cpp
sl@0
    15
// @internalComponent
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include "PBASE-T_USBDI-1230.h"
sl@0
    20
#include "testpolicy.h"
sl@0
    21
#include "modelleddevices.h"
sl@0
    22
#include "testliterals.h"
sl@0
    23
sl@0
    24
sl@0
    25
 
sl@0
    26
sl@0
    27
namespace NUnitTesting_USBDI
sl@0
    28
	{
sl@0
    29
const TUint KTotalBytesToTransfer = 1024*64+511; //64kB + 511 bytes
sl@0
    30
const TUint KHostNumReadBytes = 1024*16;
sl@0
    31
const TInt KBulkMaxTransferSize = KHostNumReadBytes + 1000;
sl@0
    32
const TInt KDeviceNumWriteBytes = 1024;
sl@0
    33
sl@0
    34
sl@0
    35
//Make these single bit values ... 
sl@0
    36
// ... so that their completion can be easily recorded in a bit mask!
sl@0
    37
const TUint32 KBulkTransferInId0 = 1<<0;
sl@0
    38
const TUint32 KBulkTransferInId1 = 1<<1; 
sl@0
    39
const TUint32 KBulkTransferInId[KMaxNumInTransfers] = {KBulkTransferInId0, KBulkTransferInId1};
sl@0
    40
const TUint32 KBulkTransferIdMask = KBulkTransferInId[0] | KBulkTransferInId[1];
sl@0
    41
sl@0
    42
const TInt KUndefinedStep	 		= -102;
sl@0
    43
const TInt KUnexpectedTransferID 	= -103;
sl@0
    44
const TInt KErrReturnedDeviceReadBytesTooVariable = -140;
sl@0
    45
const TInt KTransferSuccess	 = +100;
sl@0
    46
sl@0
    47
const TUint KRepeatedTimerInterval = 10000; //10ms
sl@0
    48
const TUint KBaseTimer = 0;
sl@0
    49
const TUint KTestTimer = 1;
sl@0
    50
const TUint KMaxTimeDiffPercentage = 60; //on inspection worst result was just under 70%
sl@0
    51
const TUint KMaxBytesWrittenDiffPercentage = 50;
sl@0
    52
sl@0
    53
sl@0
    54
sl@0
    55
sl@0
    56
_LIT(KTestCaseId,"PBASE-T_USBDI-1230");
sl@0
    57
const TFunctorTestCase<CUT_PBASE_T_USBDI_1230,TBool> CUT_PBASE_T_USBDI_1230::iFunctor(KTestCaseId);	
sl@0
    58
sl@0
    59
CUT_PBASE_T_USBDI_1230* CUT_PBASE_T_USBDI_1230::NewL(TBool aHostRole)
sl@0
    60
	{
sl@0
    61
	CUT_PBASE_T_USBDI_1230* self = new (ELeave) CUT_PBASE_T_USBDI_1230(aHostRole);
sl@0
    62
	CleanupStack::PushL(self);
sl@0
    63
	self->ConstructL();
sl@0
    64
	CleanupStack::Pop(self);
sl@0
    65
	return self;
sl@0
    66
	}
sl@0
    67
	
sl@0
    68
sl@0
    69
CUT_PBASE_T_USBDI_1230::CUT_PBASE_T_USBDI_1230(TBool aHostRole)
sl@0
    70
:	CBaseBulkTestCase(KTestCaseId,aHostRole),
sl@0
    71
	iCaseStep(EInProgress)
sl@0
    72
	{
sl@0
    73
	} 
sl@0
    74
sl@0
    75
sl@0
    76
void CUT_PBASE_T_USBDI_1230::ConstructL()
sl@0
    77
	{
sl@0
    78
	BaseBulkConstructL();
sl@0
    79
sl@0
    80
	iInBuffer = HBufC8::NewL(KTestBufferLength);
sl@0
    81
sl@0
    82
	iBulkTestTimer = CBulkTestTimer::NewL(*this);	
sl@0
    83
sl@0
    84
	//Create buffer to contain multiple lots of the payload pattern
sl@0
    85
	//..so that we may grab cyclic chunks of said payload pattern
sl@0
    86
	TInt repeats = KHostNumReadBytes / (KLiteralEnglish5().Length()) + 1 + 1; //1 extra to accommodate start point plus 1 to accomodate remainder in division
sl@0
    87
	iValidateBuffer = HBufC8::NewL(KLiteralEnglish5().Length() * repeats);
sl@0
    88
	iValidateBufferPtr.Set(iValidateBuffer->Des());
sl@0
    89
	iValidateBufferPtr.Zero();
sl@0
    90
	for(TInt i=0;i<repeats;i++)
sl@0
    91
		{
sl@0
    92
		iValidateBufferPtr.Append(KLiteralEnglish5());
sl@0
    93
		}
sl@0
    94
	
sl@0
    95
	RDebug::Printf("CUT_PBASE_T_USBDI_1230::ConstructL(): buffer created");
sl@0
    96
	}
sl@0
    97
sl@0
    98
sl@0
    99
CUT_PBASE_T_USBDI_1230::~CUT_PBASE_T_USBDI_1230()
sl@0
   100
	{
sl@0
   101
	LOG_FUNC
sl@0
   102
	}
sl@0
   103
	
sl@0
   104
void CUT_PBASE_T_USBDI_1230::KillTransfers()
sl@0
   105
	{
sl@0
   106
	LOG_FUNC
sl@0
   107
	
sl@0
   108
	iInTransfer[0]->Cancel();
sl@0
   109
	iInTransfer[1]->Cancel();
sl@0
   110
	}
sl@0
   111
sl@0
   112
void CUT_PBASE_T_USBDI_1230::ExtractDeviceReadBytes()
sl@0
   113
	{
sl@0
   114
	LOG_FUNC
sl@0
   115
	
sl@0
   116
	iControlEp0->LastRequestCompletionTime( iEndTime[KTestTimer]);
sl@0
   117
	iTimingError = iTimingError == KErrNone ? CheckTimes(KBaseTimer, KTestTimer, KMaxTimeDiffPercentage) : iTimingError;
sl@0
   118
	ResetTimes(KTestTimer);
sl@0
   119
	
sl@0
   120
	RDebug::Printf("Collect client's return of the number of bytes written on its bulk in endpoint ...");
sl@0
   121
	TLex8 lex(iInBufferPtr.Left(KNumberStringLength));
sl@0
   122
	TUint32 numBytes = 0;
sl@0
   123
	User::LeaveIfError(lex.Val(numBytes, EDecimal));
sl@0
   124
	RDebug::Printf("********************NUM*BYTES****************************");
sl@0
   125
	RDebug::Printf("         NUM BYTES READ BY CLIENT ==== %d ====           ", numBytes);
sl@0
   126
	RDebug::Printf("********************NUM*BYTES****************************");
sl@0
   127
	RDebug::Printf("\n");
sl@0
   128
sl@0
   129
	if(numBytes != 0)
sl@0
   130
		//Do not count this case - it may result from the remote resetting when all bulk transfers have completed
sl@0
   131
		{
sl@0
   132
		TUint numBytesSinceLast = numBytes - iDeviceNumBytesReadInTotal;
sl@0
   133
		iDeviceNumBytesReadInTotal = numBytes;
sl@0
   134
		iDeviceMinTimedNumBytesRead = numBytesSinceLast < iDeviceMinTimedNumBytesRead ?  numBytesSinceLast : iDeviceMinTimedNumBytesRead ;
sl@0
   135
		iDeviceMaxTimedNumBytesRead = numBytesSinceLast > iDeviceMaxTimedNumBytesRead ?  numBytesSinceLast : iDeviceMaxTimedNumBytesRead ;;
sl@0
   136
		}
sl@0
   137
	}
sl@0
   138
sl@0
   139
sl@0
   140
void CUT_PBASE_T_USBDI_1230::PostTransferAction()
sl@0
   141
	{
sl@0
   142
	switch(iTransferResult)
sl@0
   143
		{
sl@0
   144
		case KErrNone:
sl@0
   145
			//do nothing
sl@0
   146
			return;
sl@0
   147
sl@0
   148
		case KTransferSuccess:
sl@0
   149
			{
sl@0
   150
			// Indicates success - comparison is a match
sl@0
   151
			RDebug::Printf("Comparison for IN transfer is a match");
sl@0
   152
			iCaseStep = EPassed;
sl@0
   153
			TTestCasePassed request;
sl@0
   154
			iTransferComplete = 0; //reset
sl@0
   155
			iControlEp0->SendRequest(request,this);
sl@0
   156
			}
sl@0
   157
			return; 
sl@0
   158
			
sl@0
   159
			
sl@0
   160
		default:
sl@0
   161
			{
sl@0
   162
			iCaseStep = EFailed;
sl@0
   163
			RDebug::Print(iMsg);
sl@0
   164
			TTestCaseFailed request(iTransferResult,iMsg);
sl@0
   165
			iControlEp0->SendRequest(request,this);
sl@0
   166
			}
sl@0
   167
			return;
sl@0
   168
		}
sl@0
   169
	}
sl@0
   170
sl@0
   171
sl@0
   172
TInt CUT_PBASE_T_USBDI_1230::ValidatePreviousAndPerformNextTransfers(TInt aTransferId)
sl@0
   173
		{
sl@0
   174
	LOG_FUNC
sl@0
   175
	
sl@0
   176
	TUint8 index = 0;
sl@0
   177
	switch(aTransferId)
sl@0
   178
		{
sl@0
   179
		case KBulkTransferInId0:
sl@0
   180
			index = 0;
sl@0
   181
			break;
sl@0
   182
sl@0
   183
		case KBulkTransferInId1:
sl@0
   184
			index = 1;
sl@0
   185
			break;
sl@0
   186
		
sl@0
   187
		default:
sl@0
   188
			_LIT(lit, "TRANSFER ID OUT OF RANGE");
sl@0
   189
			User::Panic(lit, KErrArgument);
sl@0
   190
			return 0; //should never get here
sl@0
   191
		}
sl@0
   192
sl@0
   193
	RDebug::Printf("\n");
sl@0
   194
	RDebug::Printf("Transfer[%d]", index);
sl@0
   195
	
sl@0
   196
	
sl@0
   197
	if(iNumBytesExpected[index] != 0)
sl@0
   198
		{
sl@0
   199
		TPtrC8 data1(iInTransfer[index]->DataPolled());
sl@0
   200
		if(ValidateData(data1, iValidateBufferPtr.Mid(iValidationStringStartPointTransfer[index], iNumBytesExpected[index])) == EFalse)
sl@0
   201
			{
sl@0
   202
			RDebug::Printf("=====VALIDATION FAILURE: Point of Validation String Entry %d, Newly Read Bytes %d=====",iValidationStringStartPointTransfer[index], iNumBytesExpected[index]);
sl@0
   203
			iIsValid = EFalse;
sl@0
   204
			}
sl@0
   205
		iNumBytesExpected[index] = 0; //reset
sl@0
   206
		}
sl@0
   207
	if(iNumBytesRequestedSoFar >= KTotalBytesToTransfer)
sl@0
   208
		//if we are near the end end the other transfer will mop up remaining bytes...
sl@0
   209
		{
sl@0
   210
		RDebug::Printf("****ALL DONE for Transfer[%d]****", index);
sl@0
   211
		return KBulkTransferInId[index];
sl@0
   212
		}
sl@0
   213
	iValidationStringStartPointTransfer[index] = iNumBytesRequestedSoFar%(KLiteralEnglish5().Length()); //PRIOR TO THIS TRANSFER
sl@0
   214
	TUint bytesLeftToRead = KTotalBytesToTransfer - iNumBytesRequestedSoFar;
sl@0
   215
	iNumBytesExpected[index] = bytesLeftToRead < KHostNumReadBytes ? bytesLeftToRead : KHostNumReadBytes;
sl@0
   216
	iNumBytesRequestedSoFar += iNumBytesExpected[index];
sl@0
   217
	iInTransfer[index]->TransferIn(KHostNumReadBytes); //rely on ZLP to complete the last 'TransferIn'
sl@0
   218
	iExpectedNextTransferNumber = 1 - iExpectedNextTransferNumber;
sl@0
   219
sl@0
   220
	return 0;
sl@0
   221
	}
sl@0
   222
sl@0
   223
	
sl@0
   224
void CUT_PBASE_T_USBDI_1230::RequestNumBytesSent(TUint8 aTimerIndex)
sl@0
   225
	{
sl@0
   226
	iInBufferPtr.Set(iInBuffer->Des());
sl@0
   227
	iInBufferPtr.Zero(); //reset
sl@0
   228
	iInBufferPtr.SetLength(KNumberStringLength);
sl@0
   229
	TInterfaceGetRecordedNumBytesReadInPayload request(1,1,iInBufferPtr);
sl@0
   230
	iControlEp0->SendRequest(request,this);
sl@0
   231
 	iControlEp0->LastRequestStartTime( iStartTime[aTimerIndex]);
sl@0
   232
	}
sl@0
   233
sl@0
   234
sl@0
   235
void CUT_PBASE_T_USBDI_1230::Ep0TransferCompleteL(TInt aCompletionCode)
sl@0
   236
	{
sl@0
   237
	LOG_FUNC
sl@0
   238
	
sl@0
   239
	RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d, test step = %d", aCompletionCode, iCaseStep);
sl@0
   240
	
sl@0
   241
	if(aCompletionCode != KErrNone)
sl@0
   242
		{
sl@0
   243
		if(iCaseStep == EFailed)
sl@0
   244
			{// ignore error, nad catch the TestFailed method called further down.
sl@0
   245
			RDebug::Printf("***Failure sending FAIL message to client on endpoint 0***");
sl@0
   246
			}
sl@0
   247
		else
sl@0
   248
			{
sl@0
   249
			TBuf<256> msg;
sl@0
   250
			KillTransfers();
sl@0
   251
			_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful");
sl@0
   252
			msg.Format(lit,aCompletionCode);
sl@0
   253
			RDebug::Print(msg);
sl@0
   254
			iCaseStep = EFailed;
sl@0
   255
			TTestCaseFailed request(aCompletionCode,msg);
sl@0
   256
			iControlEp0->SendRequest(request,this);
sl@0
   257
			return;
sl@0
   258
			}
sl@0
   259
		}
sl@0
   260
	
sl@0
   261
	switch(iCaseStep)
sl@0
   262
		{
sl@0
   263
		// Test case passed
sl@0
   264
		case EPassed:
sl@0
   265
			TestPassed();
sl@0
   266
			break;
sl@0
   267
		
sl@0
   268
		// Test case failed	
sl@0
   269
		case EFailed:
sl@0
   270
			TestFailed(KErrCompletion);
sl@0
   271
			break;
sl@0
   272
		
sl@0
   273
		case EGetTimerBase:
sl@0
   274
			{
sl@0
   275
			iControlEp0->LastRequestCompletionTime( iEndTime[KBaseTimer]);
sl@0
   276
			RDebug::Printf("Asking client for repeated 'Write'");
sl@0
   277
			iCaseStep = ERequestRepeatedWrite;	
sl@0
   278
			TRepeatedWriteDataRequest request(1,1,KLiteralEnglish5(),KDeviceNumWriteBytes,KTotalBytesToTransfer);// EP2 means endpoint index 2 not the actual endpoint number, here the ep with 32 byte max packet size
sl@0
   279
			iControlEp0->SendRequest(request,this);
sl@0
   280
			}
sl@0
   281
			break;
sl@0
   282
			
sl@0
   283
		case ERequestRepeatedWrite:
sl@0
   284
			{
sl@0
   285
			RDebug::Printf("Try to perform ALL transfers");
sl@0
   286
			
sl@0
   287
			iCaseStep = ETransfer;	
sl@0
   288
			iIsValid = ETrue; //innocent until proved guilty
sl@0
   289
			RDebug::Printf("\n");
sl@0
   290
			ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[0]); //should not validate - just perform necessary transfers
sl@0
   291
			ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[1]); //should not validate - just perform necessary transfers
sl@0
   292
			RDebug::Printf("\n");
sl@0
   293
			_LITDBG("Bulk test timer NOT instanciated");
sl@0
   294
			__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
sl@0
   295
			iBulkTestTimer->After(KRepeatedTimerInterval);
sl@0
   296
			}
sl@0
   297
			break;
sl@0
   298
			
sl@0
   299
		case ETransfer:
sl@0
   300
		// we must be getting num bytes read
sl@0
   301
			{
sl@0
   302
			ExtractDeviceReadBytes();
sl@0
   303
	
sl@0
   304
			//Restart timer
sl@0
   305
			_LITDBG("Bulk test timer NOT instanciated");
sl@0
   306
			__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
sl@0
   307
			iBulkTestTimer->After(KRepeatedTimerInterval);
sl@0
   308
			}
sl@0
   309
			break;
sl@0
   310
			
sl@0
   311
		case EDelayedTransferComplete:
sl@0
   312
			{
sl@0
   313
			PostTransferAction();
sl@0
   314
			}
sl@0
   315
			break;
sl@0
   316
			
sl@0
   317
		default:
sl@0
   318
			RDebug::Printf("<Error> Unknown test step");
sl@0
   319
			TestFailed(KErrUnknown);
sl@0
   320
			break;
sl@0
   321
		}
sl@0
   322
	}
sl@0
   323
	
sl@0
   324
void CUT_PBASE_T_USBDI_1230::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
sl@0
   325
	{
sl@0
   326
	LOG_FUNC
sl@0
   327
	Cancel();
sl@0
   328
	
sl@0
   329
	iTransferResult = KErrNone;
sl@0
   330
	RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
sl@0
   331
sl@0
   332
sl@0
   333
	switch(iCaseStep)
sl@0
   334
		{
sl@0
   335
		case ETransfer:
sl@0
   336
			if(aCompletionCode != KErrNone)
sl@0
   337
				{
sl@0
   338
				KillTransfers();
sl@0
   339
				iTransferResult = KErrCorrupt;
sl@0
   340
				_LIT(lit, "<Error %d> The transfer completed with an error.");
sl@0
   341
				iMsg.Format(lit, aCompletionCode);
sl@0
   342
				break;
sl@0
   343
				}
sl@0
   344
			if(aTransferId != KBulkTransferInId[0] && aTransferId != KBulkTransferInId[1])
sl@0
   345
				{
sl@0
   346
				iTransferComplete = 0; //reset
sl@0
   347
				iTransferResult = KUnexpectedTransferID;
sl@0
   348
				_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d");
sl@0
   349
				iMsg.Format(lit, iTransferResult, KBulkTransferInId[0], KBulkTransferInId[1], aTransferId);
sl@0
   350
				break;
sl@0
   351
				}
sl@0
   352
		
sl@0
   353
			RDebug::Printf("Transfer IN %d completed - num bytes requested = %d", aTransferId, iNumBytesRequestedSoFar);
sl@0
   354
	
sl@0
   355
			RDebug::Printf("\n");
sl@0
   356
			iTransferComplete |= ValidatePreviousAndPerformNextTransfers(aTransferId);
sl@0
   357
			RDebug::Printf("\n");
sl@0
   358
			
sl@0
   359
			if(iTransferResult==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask)
sl@0
   360
				{
sl@0
   361
				/*
sl@0
   362
				Transfers all complete - now check validation
sl@0
   363
				*/
sl@0
   364
				RDebug::Printf("All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
sl@0
   365
				iBulkTestTimer->Cancel(); //Cancel Timer 
sl@0
   366
				iTransferResult = KTransferSuccess;
sl@0
   367
				if(!iIsValid)
sl@0
   368
					{
sl@0
   369
					iTransferResult = KErrCompletion; //indicates data validation failure
sl@0
   370
					iIsValid = ETrue; //reset
sl@0
   371
					}
sl@0
   372
			
sl@0
   373
				if(iTimingError == KErrTooBig)
sl@0
   374
					{
sl@0
   375
					__PRINT_CONTROL_TRANSFER_TIMER_COMPARISON_WARNING
sl@0
   376
					iTransferResult = KErrTooBig;
sl@0
   377
					iTimingError = KErrNone; //reset
sl@0
   378
					}
sl@0
   379
				
sl@0
   380
				if(KMaxBytesWrittenDiffPercentage*iDeviceMaxTimedNumBytesRead > KPercent*iDeviceMinTimedNumBytesRead)
sl@0
   381
					{
sl@0
   382
					RDebug::Printf("Device APPARENTLY reading rate erratic:-");
sl@0
   383
					RDebug::Printf("Min Timed Number of Bytes = %d", iDeviceMinTimedNumBytesRead);
sl@0
   384
					RDebug::Printf("Max Timed Number of Bytes = %d", iDeviceMaxTimedNumBytesRead);
sl@0
   385
					iTransferResult = KErrTooBig;
sl@0
   386
					iDeviceMaxTimedNumBytesRead = 0;
sl@0
   387
					iDeviceMinTimedNumBytesRead = KMaxTUint;
sl@0
   388
					}
sl@0
   389
				}
sl@0
   390
			break;
sl@0
   391
sl@0
   392
		default:
sl@0
   393
			iTransferResult = KUndefinedStep;
sl@0
   394
			_LIT(lit, "<Error %d> Undefined case step %d reached");
sl@0
   395
			iMsg.Format(lit,KUndefinedStep, iCaseStep);
sl@0
   396
			break;
sl@0
   397
		}
sl@0
   398
sl@0
   399
sl@0
   400
	if(iTransferResult == KErrReturnedDeviceReadBytesTooVariable)
sl@0
   401
		//indicates apparent device read rate validation failure
sl@0
   402
		{
sl@0
   403
		iMsg.Format(_L("<Error %d> Device APPEARS not to be reading bytes at a constant rate"), iTransferResult);
sl@0
   404
		}
sl@0
   405
sl@0
   406
	if(iTransferResult == KErrTooBig)
sl@0
   407
		//indicates timing validation failure
sl@0
   408
		{
sl@0
   409
		iMsg.Format(_L("<Error %d> Timer comparison showed too great a difference in transfer times between the time taken by EP0 transfers with and without a bulk transfer"), iTransferResult);
sl@0
   410
		}
sl@0
   411
	
sl@0
   412
	if(iTransferResult == KErrCompletion)
sl@0
   413
		//indicates data validation failure
sl@0
   414
		{
sl@0
   415
		_LIT(lit, "<Error %d> Client has posted an error discovered in validation");
sl@0
   416
		iMsg.Format(lit, iTransferResult);
sl@0
   417
		}
sl@0
   418
sl@0
   419
	if(iTransferResult != KErrNone)
sl@0
   420
		{	
sl@0
   421
		KillTransfers(); //harmless if tranfers are all done
sl@0
   422
		if(!iControlEp0->IsActive())
sl@0
   423
			{
sl@0
   424
			PostTransferAction();
sl@0
   425
			}
sl@0
   426
		else
sl@0
   427
			{
sl@0
   428
			iCaseStep = EDelayedTransferComplete; //so that we move forward when the EP0 transfer has completed
sl@0
   429
			}
sl@0
   430
		}
sl@0
   431
	}
sl@0
   432
	
sl@0
   433
void CUT_PBASE_T_USBDI_1230::DeviceInsertedL(TUint aDeviceHandle)
sl@0
   434
	{
sl@0
   435
	LOG_FUNC
sl@0
   436
	
sl@0
   437
	Cancel();
sl@0
   438
	RDebug::Printf("this - %08x", this);
sl@0
   439
	
sl@0
   440
	TBuf<256> msg;
sl@0
   441
	TInt err = KErrNone;
sl@0
   442
	if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
sl@0
   443
		// Prepare for response from control transfer to client
sl@0
   444
		{
sl@0
   445
		err = KErrGeneral;
sl@0
   446
		_LIT(lit, "Base class DeviceInsertedL failed");
sl@0
   447
		msg.Format(lit);
sl@0
   448
		}
sl@0
   449
	else
sl@0
   450
		{
sl@0
   451
		if(SetUpInterfaceAndPipesL(aDeviceHandle, 2) == EDeviceConfigurationError)
sl@0
   452
			// Prepare for response from control transfer to client
sl@0
   453
			{
sl@0
   454
			err = KErrGeneral;
sl@0
   455
			_LIT(lit, "Base class SetUpInterfaceAndPipes for Interface 2 failed");
sl@0
   456
			msg.Format(lit);
sl@0
   457
			}
sl@0
   458
		else
sl@0
   459
			{
sl@0
   460
	
sl@0
   461
			iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[0]);
sl@0
   462
			iInTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[1]);
sl@0
   463
			
sl@0
   464
			// Initialise the descriptors for transfer		
sl@0
   465
			RDebug::Printf("Initialising the transfer descriptors - interface 1");
sl@0
   466
			err = iUsbInterface1.InitialiseTransferDescriptors();
sl@0
   467
			if(err != KErrNone)
sl@0
   468
				{
sl@0
   469
				_LIT(lit, "<Error %d> Unable to initialise transfer descriptors");
sl@0
   470
				msg.Format(lit,err);
sl@0
   471
				}
sl@0
   472
			}
sl@0
   473
		}
sl@0
   474
	if(err != KErrNone)
sl@0
   475
		{
sl@0
   476
		RDebug::Print(msg);
sl@0
   477
		iCaseStep = EFailed;
sl@0
   478
		TTestCaseFailed request(err,msg);
sl@0
   479
		iControlEp0->SendRequest(request,this);
sl@0
   480
		}
sl@0
   481
	else
sl@0
   482
		{
sl@0
   483
		iCaseStep = EGetTimerBase;
sl@0
   484
		iDeviceMinTimedNumBytesRead = KMaxTUint;
sl@0
   485
		iDeviceMaxTimedNumBytesRead = 0;
sl@0
   486
		iDeviceNumBytesReadInTotal = 0;
sl@0
   487
		RequestNumBytesSent(KBaseTimer);
sl@0
   488
		}
sl@0
   489
	}
sl@0
   490
sl@0
   491
void CUT_PBASE_T_USBDI_1230::HandleBulkTestTimerFired()
sl@0
   492
	{
sl@0
   493
	if(iCaseStep == ETransfer)
sl@0
   494
		{
sl@0
   495
		RequestNumBytesSent(KTestTimer);
sl@0
   496
		}
sl@0
   497
	}
sl@0
   498
	
sl@0
   499
	} //end namespace