kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-1230.cpp
changeset 253 d37db4dcc88d
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
252:0a40b8675b23 253:d37db4dcc88d
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 
    18 
    19 #include "PBASE-T_USBDI-1230.h"
    19 #include "PBASE-T_USBDI-1230.h"
    20 #include "testpolicy.h"
    20 #include "testpolicy.h"
    21 #include "modelleddevices.h"
    21 #include "modelleddevices.h"
    22 #include "testliterals.h"
    22 #include "testliterals.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "PBASE-T_USBDI-1230Traces.h"
       
    26 #endif
    23 
    27 
    24 
    28 
    25  
    29  
    26 
    30 
    27 namespace NUnitTesting_USBDI
    31 namespace NUnitTesting_USBDI
    56 _LIT(KTestCaseId,"PBASE-T_USBDI-1230");
    60 _LIT(KTestCaseId,"PBASE-T_USBDI-1230");
    57 const TFunctorTestCase<CUT_PBASE_T_USBDI_1230,TBool> CUT_PBASE_T_USBDI_1230::iFunctor(KTestCaseId);	
    61 const TFunctorTestCase<CUT_PBASE_T_USBDI_1230,TBool> CUT_PBASE_T_USBDI_1230::iFunctor(KTestCaseId);	
    58 
    62 
    59 CUT_PBASE_T_USBDI_1230* CUT_PBASE_T_USBDI_1230::NewL(TBool aHostRole)
    63 CUT_PBASE_T_USBDI_1230* CUT_PBASE_T_USBDI_1230::NewL(TBool aHostRole)
    60 	{
    64 	{
       
    65 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_NEWL_ENTRY, aHostRole );
    61 	CUT_PBASE_T_USBDI_1230* self = new (ELeave) CUT_PBASE_T_USBDI_1230(aHostRole);
    66 	CUT_PBASE_T_USBDI_1230* self = new (ELeave) CUT_PBASE_T_USBDI_1230(aHostRole);
    62 	CleanupStack::PushL(self);
    67 	CleanupStack::PushL(self);
    63 	self->ConstructL();
    68 	self->ConstructL();
    64 	CleanupStack::Pop(self);
    69 	CleanupStack::Pop(self);
       
    70 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_NEWL_EXIT, ( TUint )( self ) );
    65 	return self;
    71 	return self;
    66 	}
    72 	}
    67 	
    73 	
    68 
    74 
    69 CUT_PBASE_T_USBDI_1230::CUT_PBASE_T_USBDI_1230(TBool aHostRole)
    75 CUT_PBASE_T_USBDI_1230::CUT_PBASE_T_USBDI_1230(TBool aHostRole)
    70 :	CBaseBulkTestCase(KTestCaseId,aHostRole),
    76 :	CBaseBulkTestCase(KTestCaseId,aHostRole),
    71 	iCaseStep(EInProgress)
    77 	iCaseStep(EInProgress)
    72 	{
    78 	{
       
    79 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_ENTRY, this );
       
    80 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_EXIT, this );
    73 	} 
    81 	} 
    74 
    82 
    75 
    83 
    76 void CUT_PBASE_T_USBDI_1230::ConstructL()
    84 void CUT_PBASE_T_USBDI_1230::ConstructL()
    77 	{
    85 	{
       
    86 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_CONSTRUCTL_ENTRY, this );
    78 	BaseBulkConstructL();
    87 	BaseBulkConstructL();
    79 
    88 
    80 	iInBuffer = HBufC8::NewL(KTestBufferLength);
    89 	iInBuffer = HBufC8::NewL(KTestBufferLength);
    81 
    90 
    82 	iBulkTestTimer = CBulkTestTimer::NewL(*this);	
    91 	iBulkTestTimer = CBulkTestTimer::NewL(*this);	
    90 	for(TInt i=0;i<repeats;i++)
    99 	for(TInt i=0;i<repeats;i++)
    91 		{
   100 		{
    92 		iValidateBufferPtr.Append(KLiteralEnglish5());
   101 		iValidateBufferPtr.Append(KLiteralEnglish5());
    93 		}
   102 		}
    94 	
   103 	
    95 	RDebug::Printf("CUT_PBASE_T_USBDI_1230::ConstructL(): buffer created");
   104 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_CONSTRUCTL, "CUT_PBASE_T_USBDI_1230::ConstructL(): buffer created");
       
   105 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_CONSTRUCTL_EXIT, this );
    96 	}
   106 	}
    97 
   107 
    98 
   108 
    99 CUT_PBASE_T_USBDI_1230::~CUT_PBASE_T_USBDI_1230()
   109 CUT_PBASE_T_USBDI_1230::~CUT_PBASE_T_USBDI_1230()
   100 	{
   110 	{
   101 	LOG_FUNC
   111 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_ENTRY_DUP01, this );
       
   112 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_CUT_PBASE_T_USBDI_1230_EXIT_DUP01, this );
   102 	}
   113 	}
   103 	
   114 	
   104 void CUT_PBASE_T_USBDI_1230::KillTransfers()
   115 void CUT_PBASE_T_USBDI_1230::KillTransfers()
   105 	{
   116 	{
   106 	LOG_FUNC
   117 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_KILLTRANSFERS_ENTRY, this );
   107 	
   118 	
   108 	iInTransfer[0]->Cancel();
   119 	iInTransfer[0]->Cancel();
   109 	iInTransfer[1]->Cancel();
   120 	iInTransfer[1]->Cancel();
       
   121 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_KILLTRANSFERS_EXIT, this );
   110 	}
   122 	}
   111 
   123 
   112 void CUT_PBASE_T_USBDI_1230::ExtractDeviceReadBytes()
   124 void CUT_PBASE_T_USBDI_1230::ExtractDeviceReadBytes()
   113 	{
   125 	{
   114 	LOG_FUNC
   126 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_ENTRY, this );
   115 	
   127 	
   116 	iControlEp0->LastRequestCompletionTime( iEndTime[KTestTimer]);
   128 	iControlEp0->LastRequestCompletionTime( iEndTime[KTestTimer]);
   117 	iTimingError = iTimingError == KErrNone ? CheckTimes(KBaseTimer, KTestTimer, KMaxTimeDiffPercentage) : iTimingError;
   129 	iTimingError = iTimingError == KErrNone ? CheckTimes(KBaseTimer, KTestTimer, KMaxTimeDiffPercentage) : iTimingError;
   118 	ResetTimes(KTestTimer);
   130 	ResetTimes(KTestTimer);
   119 	
   131 	
   120 	RDebug::Printf("Collect client's return of the number of bytes written on its bulk in endpoint ...");
   132 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES, "Collect client's return of the number of bytes written on its bulk in endpoint ...");
   121 	TLex8 lex(iInBufferPtr.Left(KNumberStringLength));
   133 	TLex8 lex(iInBufferPtr.Left(KNumberStringLength));
   122 	TUint32 numBytes = 0;
   134 	TUint32 numBytes = 0;
   123 	User::LeaveIfError(lex.Val(numBytes, EDecimal));
   135 	User::LeaveIfError(lex.Val(numBytes, EDecimal));
   124 	RDebug::Printf("********************NUM*BYTES****************************");
   136 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_DUP01, "********************NUM*BYTES****************************");
   125 	RDebug::Printf("         NUM BYTES READ BY CLIENT ==== %d ====           ", numBytes);
   137 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_DUP02, "         NUM BYTES READ BY CLIENT ==== %d ====           ", numBytes);
   126 	RDebug::Printf("********************NUM*BYTES****************************");
   138 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_DUP03, "********************NUM*BYTES****************************");
   127 	RDebug::Printf("\n");
   139 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_DUP04, "\n");
   128 
   140 
   129 	if(numBytes != 0)
   141 	if(numBytes != 0)
   130 		//Do not count this case - it may result from the remote resetting when all bulk transfers have completed
   142 		//Do not count this case - it may result from the remote resetting when all bulk transfers have completed
   131 		{
   143 		{
   132 		TUint numBytesSinceLast = numBytes - iDeviceNumBytesReadInTotal;
   144 		TUint numBytesSinceLast = numBytes - iDeviceNumBytesReadInTotal;
   133 		iDeviceNumBytesReadInTotal = numBytes;
   145 		iDeviceNumBytesReadInTotal = numBytes;
   134 		iDeviceMinTimedNumBytesRead = numBytesSinceLast < iDeviceMinTimedNumBytesRead ?  numBytesSinceLast : iDeviceMinTimedNumBytesRead ;
   146 		iDeviceMinTimedNumBytesRead = numBytesSinceLast < iDeviceMinTimedNumBytesRead ?  numBytesSinceLast : iDeviceMinTimedNumBytesRead ;
   135 		iDeviceMaxTimedNumBytesRead = numBytesSinceLast > iDeviceMaxTimedNumBytesRead ?  numBytesSinceLast : iDeviceMaxTimedNumBytesRead ;;
   147 		iDeviceMaxTimedNumBytesRead = numBytesSinceLast > iDeviceMaxTimedNumBytesRead ?  numBytesSinceLast : iDeviceMaxTimedNumBytesRead ;;
   136 		}
   148 		}
       
   149 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_EXTRACTDEVICEREADBYTES_EXIT, this );
   137 	}
   150 	}
   138 
   151 
   139 
   152 
   140 void CUT_PBASE_T_USBDI_1230::PostTransferAction()
   153 void CUT_PBASE_T_USBDI_1230::PostTransferAction()
   141 	{
   154 	{
       
   155 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_ENTRY, this );
   142 	switch(iTransferResult)
   156 	switch(iTransferResult)
   143 		{
   157 		{
   144 		case KErrNone:
   158 		case KErrNone:
   145 			//do nothing
   159 			//do nothing
   146 			return;
   160 			return;
   147 
   161 
   148 		case KTransferSuccess:
   162 		case KTransferSuccess:
   149 			{
   163 			{
   150 			// Indicates success - comparison is a match
   164 			// Indicates success - comparison is a match
   151 			RDebug::Printf("Comparison for IN transfer is a match");
   165 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION, "Comparison for IN transfer is a match");
   152 			iCaseStep = EPassed;
   166 			iCaseStep = EPassed;
   153 			TTestCasePassed request;
   167 			TTestCasePassed request;
   154 			iTransferComplete = 0; //reset
   168 			iTransferComplete = 0; //reset
   155 			iControlEp0->SendRequest(request,this);
   169 			iControlEp0->SendRequest(request,this);
   156 			}
   170 			}
       
   171 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_EXIT, this );
   157 			return; 
   172 			return; 
   158 			
   173 			
   159 			
   174 			
   160 		default:
   175 		default:
   161 			{
   176 			{
   162 			iCaseStep = EFailed;
   177 			iCaseStep = EFailed;
   163 			RDebug::Print(iMsg);
   178 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_DUP01, iMsg);
   164 			TTestCaseFailed request(iTransferResult,iMsg);
   179 			TTestCaseFailed request(iTransferResult,iMsg);
   165 			iControlEp0->SendRequest(request,this);
   180 			iControlEp0->SendRequest(request,this);
   166 			}
   181 			}
       
   182 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_POSTTRANSFERACTION_EXIT_DUP01, this );
   167 			return;
   183 			return;
   168 		}
   184 		}
   169 	}
   185 	}
   170 
   186 
   171 
   187 
   172 TInt CUT_PBASE_T_USBDI_1230::ValidatePreviousAndPerformNextTransfers(TInt aTransferId)
   188 TInt CUT_PBASE_T_USBDI_1230::ValidatePreviousAndPerformNextTransfers(TInt aTransferId)
   173 		{
   189 		{
   174 	LOG_FUNC
   190 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_ENTRY, this );
   175 	
   191 	
   176 	TUint8 index = 0;
   192 	TUint8 index = 0;
   177 	switch(aTransferId)
   193 	switch(aTransferId)
   178 		{
   194 		{
   179 		case KBulkTransferInId0:
   195 		case KBulkTransferInId0:
   185 			break;
   201 			break;
   186 		
   202 		
   187 		default:
   203 		default:
   188 			_LIT(lit, "TRANSFER ID OUT OF RANGE");
   204 			_LIT(lit, "TRANSFER ID OUT OF RANGE");
   189 			User::Panic(lit, KErrArgument);
   205 			User::Panic(lit, KErrArgument);
       
   206 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_EXIT, this );
   190 			return 0; //should never get here
   207 			return 0; //should never get here
   191 		}
   208 		}
   192 
   209 
   193 	RDebug::Printf("\n");
   210 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS, "\n");
   194 	RDebug::Printf("Transfer[%d]", index);
   211 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_DUP01, "Transfer[%d]", index);
   195 	
   212 	
   196 	
   213 	
   197 	if(iNumBytesExpected[index] != 0)
   214 	if(iNumBytesExpected[index] != 0)
   198 		{
   215 		{
   199 		TPtrC8 data1(iInTransfer[index]->DataPolled());
   216 		TPtrC8 data1(iInTransfer[index]->DataPolled());
   200 		if(ValidateData(data1, iValidateBufferPtr.Mid(iValidationStringStartPointTransfer[index], iNumBytesExpected[index])) == EFalse)
   217 		if(ValidateData(data1, iValidateBufferPtr.Mid(iValidationStringStartPointTransfer[index], iNumBytesExpected[index])) == EFalse)
   201 			{
   218 			{
   202 			RDebug::Printf("=====VALIDATION FAILURE: Point of Validation String Entry %d, Newly Read Bytes %d=====",iValidationStringStartPointTransfer[index], iNumBytesExpected[index]);
   219 			OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_DUP02, "=====VALIDATION FAILURE: Point of Validation String Entry %u, Newly Read Bytes %u=====",iValidationStringStartPointTransfer[index], iNumBytesExpected[index]);
   203 			iIsValid = EFalse;
   220 			iIsValid = EFalse;
   204 			}
   221 			}
   205 		iNumBytesExpected[index] = 0; //reset
   222 		iNumBytesExpected[index] = 0; //reset
   206 		}
   223 		}
   207 	if(iNumBytesRequestedSoFar >= KTotalBytesToTransfer)
   224 	if(iNumBytesRequestedSoFar >= KTotalBytesToTransfer)
   208 		//if we are near the end end the other transfer will mop up remaining bytes...
   225 		//if we are near the end end the other transfer will mop up remaining bytes...
   209 		{
   226 		{
   210 		RDebug::Printf("****ALL DONE for Transfer[%d]****", index);
   227 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_DUP03, "****ALL DONE for Transfer[%d]****", index);
       
   228 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_EXIT_DUP01, this, (TUint)KBulkTransferInId[index] );
   211 		return KBulkTransferInId[index];
   229 		return KBulkTransferInId[index];
   212 		}
   230 		}
   213 	iValidationStringStartPointTransfer[index] = iNumBytesRequestedSoFar%(KLiteralEnglish5().Length()); //PRIOR TO THIS TRANSFER
   231 	iValidationStringStartPointTransfer[index] = iNumBytesRequestedSoFar%(KLiteralEnglish5().Length()); //PRIOR TO THIS TRANSFER
   214 	TUint bytesLeftToRead = KTotalBytesToTransfer - iNumBytesRequestedSoFar;
   232 	TUint bytesLeftToRead = KTotalBytesToTransfer - iNumBytesRequestedSoFar;
   215 	iNumBytesExpected[index] = bytesLeftToRead < KHostNumReadBytes ? bytesLeftToRead : KHostNumReadBytes;
   233 	iNumBytesExpected[index] = bytesLeftToRead < KHostNumReadBytes ? bytesLeftToRead : KHostNumReadBytes;
   216 	iNumBytesRequestedSoFar += iNumBytesExpected[index];
   234 	iNumBytesRequestedSoFar += iNumBytesExpected[index];
   217 	iInTransfer[index]->TransferIn(KHostNumReadBytes); //rely on ZLP to complete the last 'TransferIn'
   235 	iInTransfer[index]->TransferIn(KHostNumReadBytes); //rely on ZLP to complete the last 'TransferIn'
   218 	iExpectedNextTransferNumber = 1 - iExpectedNextTransferNumber;
   236 	iExpectedNextTransferNumber = 1 - iExpectedNextTransferNumber;
   219 
   237 
       
   238 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_VALIDATEPREVIOUSANDPERFORMNEXTTRANSFERS_EXIT_DUP02, this );
   220 	return 0;
   239 	return 0;
   221 	}
   240 	}
   222 
   241 
   223 	
   242 	
   224 void CUT_PBASE_T_USBDI_1230::RequestNumBytesSent(TUint8 aTimerIndex)
   243 void CUT_PBASE_T_USBDI_1230::RequestNumBytesSent(TUint8 aTimerIndex)
   225 	{
   244 	{
       
   245 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_REQUESTNUMBYTESSENT_ENTRY, this );
   226 	iInBufferPtr.Set(iInBuffer->Des());
   246 	iInBufferPtr.Set(iInBuffer->Des());
   227 	iInBufferPtr.Zero(); //reset
   247 	iInBufferPtr.Zero(); //reset
   228 	iInBufferPtr.SetLength(KNumberStringLength);
   248 	iInBufferPtr.SetLength(KNumberStringLength);
   229 	TInterfaceGetRecordedNumBytesReadInPayload request(1,1,iInBufferPtr);
   249 	TInterfaceGetRecordedNumBytesReadInPayload request(1,1,iInBufferPtr);
   230 	iControlEp0->SendRequest(request,this);
   250 	iControlEp0->SendRequest(request,this);
   231  	iControlEp0->LastRequestStartTime( iStartTime[aTimerIndex]);
   251  	iControlEp0->LastRequestStartTime( iStartTime[aTimerIndex]);
       
   252 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_REQUESTNUMBYTESSENT_EXIT, this );
   232 	}
   253 	}
   233 
   254 
   234 
   255 
   235 void CUT_PBASE_T_USBDI_1230::Ep0TransferCompleteL(TInt aCompletionCode)
   256 void CUT_PBASE_T_USBDI_1230::Ep0TransferCompleteL(TInt aCompletionCode)
   236 	{
   257 	{
   237 	LOG_FUNC
   258 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_ENTRY, this );
   238 	
   259 	
   239 	RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d, test step = %d", aCompletionCode, iCaseStep);
   260 	OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d, test step = %d", aCompletionCode, iCaseStep);
   240 	
   261 	
   241 	if(aCompletionCode != KErrNone)
   262 	if(aCompletionCode != KErrNone)
   242 		{
   263 		{
   243 		if(iCaseStep == EFailed)
   264 		if(iCaseStep == EFailed)
   244 			{// ignore error, nad catch the TestFailed method called further down.
   265 			{// ignore error, nad catch the TestFailed method called further down.
   245 			RDebug::Printf("***Failure sending FAIL message to client on endpoint 0***");
   266 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP01, "***Failure sending FAIL message to client on endpoint 0***");
   246 			}
   267 			}
   247 		else
   268 		else
   248 			{
   269 			{
   249 			TBuf<256> msg;
   270 			TBuf<256> msg;
   250 			KillTransfers();
   271 			KillTransfers();
   251 			_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful");
   272 			_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful");
   252 			msg.Format(lit,aCompletionCode);
   273 			msg.Format(lit,aCompletionCode);
   253 			RDebug::Print(msg);
   274 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP02, msg);
   254 			iCaseStep = EFailed;
   275 			iCaseStep = EFailed;
   255 			TTestCaseFailed request(aCompletionCode,msg);
   276 			TTestCaseFailed request(aCompletionCode,msg);
   256 			iControlEp0->SendRequest(request,this);
   277 			iControlEp0->SendRequest(request,this);
       
   278 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_EXIT, this );
   257 			return;
   279 			return;
   258 			}
   280 			}
   259 		}
   281 		}
   260 	
   282 	
   261 	switch(iCaseStep)
   283 	switch(iCaseStep)
   271 			break;
   293 			break;
   272 		
   294 		
   273 		case EGetTimerBase:
   295 		case EGetTimerBase:
   274 			{
   296 			{
   275 			iControlEp0->LastRequestCompletionTime( iEndTime[KBaseTimer]);
   297 			iControlEp0->LastRequestCompletionTime( iEndTime[KBaseTimer]);
   276 			RDebug::Printf("Asking client for repeated 'Write'");
   298 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP03, "Asking client for repeated 'Write'");
   277 			iCaseStep = ERequestRepeatedWrite;	
   299 			iCaseStep = ERequestRepeatedWrite;	
   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
   300 			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
   279 			iControlEp0->SendRequest(request,this);
   301 			iControlEp0->SendRequest(request,this);
   280 			}
   302 			}
   281 			break;
   303 			break;
   282 			
   304 			
   283 		case ERequestRepeatedWrite:
   305 		case ERequestRepeatedWrite:
   284 			{
   306 			{
   285 			RDebug::Printf("Try to perform ALL transfers");
   307 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP04, "Try to perform ALL transfers");
   286 			
   308 			
   287 			iCaseStep = ETransfer;	
   309 			iCaseStep = ETransfer;	
   288 			iIsValid = ETrue; //innocent until proved guilty
   310 			iIsValid = ETrue; //innocent until proved guilty
   289 			RDebug::Printf("\n");
   311 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP05, "\n");
   290 			ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[0]); //should not validate - just perform necessary transfers
   312 			ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[0]); //should not validate - just perform necessary transfers
   291 			ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[1]); //should not validate - just perform necessary transfers
   313 			ValidatePreviousAndPerformNextTransfers(KBulkTransferInId[1]); //should not validate - just perform necessary transfers
   292 			RDebug::Printf("\n");
   314 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP06, "\n");
   293 			_LITDBG("Bulk test timer NOT instanciated");
   315 			_LITDBG("Bulk test timer NOT instanciated");
   294 			__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
   316 			__ASSERT_DEBUG(iBulkTestTimer, User::Panic(lit, KErrGeneral));
   295 			iBulkTestTimer->After(KRepeatedTimerInterval);
   317 			iBulkTestTimer->After(KRepeatedTimerInterval);
   296 			}
   318 			}
   297 			break;
   319 			break;
   313 			PostTransferAction();
   335 			PostTransferAction();
   314 			}
   336 			}
   315 			break;
   337 			break;
   316 			
   338 			
   317 		default:
   339 		default:
   318 			RDebug::Printf("<Error> Unknown test step");
   340 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_DUP07, "<Error> Unknown test step");
   319 			TestFailed(KErrUnknown);
   341 			TestFailed(KErrUnknown);
   320 			break;
   342 			break;
   321 		}
   343 		}
       
   344 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
   322 	}
   345 	}
   323 	
   346 	
   324 void CUT_PBASE_T_USBDI_1230::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
   347 void CUT_PBASE_T_USBDI_1230::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
   325 	{
   348 	{
   326 	LOG_FUNC
   349 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_ENTRY, this );
   327 	Cancel();
   350 	Cancel();
   328 	
   351 	
   329 	iTransferResult = KErrNone;
   352 	iTransferResult = KErrNone;
   330 	RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
   353 	OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL, "Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
   331 
   354 
   332 
   355 
   333 	switch(iCaseStep)
   356 	switch(iCaseStep)
   334 		{
   357 		{
   335 		case ETransfer:
   358 		case ETransfer:
   348 				_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d");
   371 				_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d");
   349 				iMsg.Format(lit, iTransferResult, KBulkTransferInId[0], KBulkTransferInId[1], aTransferId);
   372 				iMsg.Format(lit, iTransferResult, KBulkTransferInId[0], KBulkTransferInId[1], aTransferId);
   350 				break;
   373 				break;
   351 				}
   374 				}
   352 		
   375 		
   353 			RDebug::Printf("Transfer IN %d completed - num bytes requested = %d", aTransferId, iNumBytesRequestedSoFar);
   376 			OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP01, "Transfer IN %d completed - num bytes requested = %u", aTransferId, iNumBytesRequestedSoFar);
   354 	
   377 	
   355 			RDebug::Printf("\n");
   378 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP02, "\n");
   356 			iTransferComplete |= ValidatePreviousAndPerformNextTransfers(aTransferId);
   379 			iTransferComplete |= ValidatePreviousAndPerformNextTransfers(aTransferId);
   357 			RDebug::Printf("\n");
   380 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP03, "\n");
   358 			
   381 			
   359 			if(iTransferResult==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask)
   382 			if(iTransferResult==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask)
   360 				{
   383 				{
   361 				/*
   384 				/*
   362 				Transfers all complete - now check validation
   385 				Transfers all complete - now check validation
   363 				*/
   386 				*/
   364 				RDebug::Printf("All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
   387 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP04, "All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
   365 				iBulkTestTimer->Cancel(); //Cancel Timer 
   388 				iBulkTestTimer->Cancel(); //Cancel Timer 
   366 				iTransferResult = KTransferSuccess;
   389 				iTransferResult = KTransferSuccess;
   367 				if(!iIsValid)
   390 				if(!iIsValid)
   368 					{
   391 					{
   369 					iTransferResult = KErrCompletion; //indicates data validation failure
   392 					iTransferResult = KErrCompletion; //indicates data validation failure
   377 					iTimingError = KErrNone; //reset
   400 					iTimingError = KErrNone; //reset
   378 					}
   401 					}
   379 				
   402 				
   380 				if(KMaxBytesWrittenDiffPercentage*iDeviceMaxTimedNumBytesRead > KPercent*iDeviceMinTimedNumBytesRead)
   403 				if(KMaxBytesWrittenDiffPercentage*iDeviceMaxTimedNumBytesRead > KPercent*iDeviceMinTimedNumBytesRead)
   381 					{
   404 					{
   382 					RDebug::Printf("Device APPARENTLY reading rate erratic:-");
   405 					OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP05, "Device APPARENTLY reading rate erratic:-");
   383 					RDebug::Printf("Min Timed Number of Bytes = %d", iDeviceMinTimedNumBytesRead);
   406 					OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP06, "Min Timed Number of Bytes = %d", iDeviceMinTimedNumBytesRead);
   384 					RDebug::Printf("Max Timed Number of Bytes = %d", iDeviceMaxTimedNumBytesRead);
   407 					OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_DUP07, "Max Timed Number of Bytes = %d", iDeviceMaxTimedNumBytesRead);
   385 					iTransferResult = KErrTooBig;
   408 					iTransferResult = KErrTooBig;
   386 					iDeviceMaxTimedNumBytesRead = 0;
   409 					iDeviceMaxTimedNumBytesRead = 0;
   387 					iDeviceMinTimedNumBytesRead = KMaxTUint;
   410 					iDeviceMinTimedNumBytesRead = KMaxTUint;
   388 					}
   411 					}
   389 				}
   412 				}
   426 		else
   449 		else
   427 			{
   450 			{
   428 			iCaseStep = EDelayedTransferComplete; //so that we move forward when the EP0 transfer has completed
   451 			iCaseStep = EDelayedTransferComplete; //so that we move forward when the EP0 transfer has completed
   429 			}
   452 			}
   430 		}
   453 		}
       
   454 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_TRANSFERCOMPLETEL_EXIT, this );
   431 	}
   455 	}
   432 	
   456 	
   433 void CUT_PBASE_T_USBDI_1230::DeviceInsertedL(TUint aDeviceHandle)
   457 void CUT_PBASE_T_USBDI_1230::DeviceInsertedL(TUint aDeviceHandle)
   434 	{
   458 	{
   435 	LOG_FUNC
   459 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_ENTRY, this );
   436 	
   460 	
   437 	Cancel();
   461 	Cancel();
   438 	RDebug::Printf("this - %08x", this);
   462 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL, "this - %08x", this);
   439 	
   463 	
   440 	TBuf<256> msg;
   464 	TBuf<256> msg;
   441 	TInt err = KErrNone;
   465 	TInt err = KErrNone;
   442 	if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
   466 	if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
   443 		// Prepare for response from control transfer to client
   467 		// Prepare for response from control transfer to client
   460 	
   484 	
   461 			iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[0]);
   485 			iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[0]);
   462 			iInTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[1]);
   486 			iInTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferInId[1]);
   463 			
   487 			
   464 			// Initialise the descriptors for transfer		
   488 			// Initialise the descriptors for transfer		
   465 			RDebug::Printf("Initialising the transfer descriptors - interface 1");
   489 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_DUP01, "Initialising the transfer descriptors - interface 1");
   466 			err = iUsbInterface1.InitialiseTransferDescriptors();
   490 			err = iUsbInterface1.InitialiseTransferDescriptors();
   467 			if(err != KErrNone)
   491 			if(err != KErrNone)
   468 				{
   492 				{
   469 				_LIT(lit, "<Error %d> Unable to initialise transfer descriptors");
   493 				_LIT(lit, "<Error %d> Unable to initialise transfer descriptors");
   470 				msg.Format(lit,err);
   494 				msg.Format(lit,err);
   471 				}
   495 				}
   472 			}
   496 			}
   473 		}
   497 		}
   474 	if(err != KErrNone)
   498 	if(err != KErrNone)
   475 		{
   499 		{
   476 		RDebug::Print(msg);
   500 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_DUP02, msg);
   477 		iCaseStep = EFailed;
   501 		iCaseStep = EFailed;
   478 		TTestCaseFailed request(err,msg);
   502 		TTestCaseFailed request(err,msg);
   479 		iControlEp0->SendRequest(request,this);
   503 		iControlEp0->SendRequest(request,this);
   480 		}
   504 		}
   481 	else
   505 	else
   484 		iDeviceMinTimedNumBytesRead = KMaxTUint;
   508 		iDeviceMinTimedNumBytesRead = KMaxTUint;
   485 		iDeviceMaxTimedNumBytesRead = 0;
   509 		iDeviceMaxTimedNumBytesRead = 0;
   486 		iDeviceNumBytesReadInTotal = 0;
   510 		iDeviceNumBytesReadInTotal = 0;
   487 		RequestNumBytesSent(KBaseTimer);
   511 		RequestNumBytesSent(KBaseTimer);
   488 		}
   512 		}
       
   513 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_DEVICEINSERTEDL_EXIT, this );
   489 	}
   514 	}
   490 
   515 
   491 void CUT_PBASE_T_USBDI_1230::HandleBulkTestTimerFired()
   516 void CUT_PBASE_T_USBDI_1230::HandleBulkTestTimerFired()
   492 	{
   517 	{
       
   518 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1230_HANDLEBULKTESTTIMERFIRED_ENTRY, this );
   493 	if(iCaseStep == ETransfer)
   519 	if(iCaseStep == ETransfer)
   494 		{
   520 		{
   495 		RequestNumBytesSent(KTestTimer);
   521 		RequestNumBytesSent(KTestTimer);
   496 		}
   522 		}
       
   523 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1230_HANDLEBULKTESTTIMERFIRED_EXIT, this );
   497 	}
   524 	}
   498 	
   525 	
   499 	} //end namespace
   526 	} //end namespace