kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-1229.cpp
changeset 259 57b9594f5772
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
247:d8d70de2bd36 259:57b9594f5772
     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-1229.h"
    19 #include "PBASE-T_USBDI-1229.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-1229Traces.h"
       
    26 #endif
    23 
    27 
    24 
    28 
    25  
    29  
    26 
    30 
    27 namespace NUnitTesting_USBDI
    31 namespace NUnitTesting_USBDI
    54 _LIT(KTestCaseId,"PBASE-T_USBDI-1229");
    58 _LIT(KTestCaseId,"PBASE-T_USBDI-1229");
    55 const TFunctorTestCase<CUT_PBASE_T_USBDI_1229,TBool> CUT_PBASE_T_USBDI_1229::iFunctor(KTestCaseId);	
    59 const TFunctorTestCase<CUT_PBASE_T_USBDI_1229,TBool> CUT_PBASE_T_USBDI_1229::iFunctor(KTestCaseId);	
    56 
    60 
    57 CUT_PBASE_T_USBDI_1229* CUT_PBASE_T_USBDI_1229::NewL(TBool aHostRole)
    61 CUT_PBASE_T_USBDI_1229* CUT_PBASE_T_USBDI_1229::NewL(TBool aHostRole)
    58 	{
    62 	{
       
    63 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_NEWL_ENTRY, aHostRole );
    59 	CUT_PBASE_T_USBDI_1229* self = new (ELeave) CUT_PBASE_T_USBDI_1229(aHostRole);
    64 	CUT_PBASE_T_USBDI_1229* self = new (ELeave) CUT_PBASE_T_USBDI_1229(aHostRole);
    60 	CleanupStack::PushL(self);
    65 	CleanupStack::PushL(self);
    61 	self->ConstructL();
    66 	self->ConstructL();
    62 	CleanupStack::Pop(self);
    67 	CleanupStack::Pop(self);
       
    68 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_NEWL_EXIT, ( TUint )( self ) );
    63 	return self;
    69 	return self;
    64 	}
    70 	}
    65 	
    71 	
    66 
    72 
    67 CUT_PBASE_T_USBDI_1229::CUT_PBASE_T_USBDI_1229(TBool aHostRole)
    73 CUT_PBASE_T_USBDI_1229::CUT_PBASE_T_USBDI_1229(TBool aHostRole)
    68 :	CBaseBulkTestCase(KTestCaseId,aHostRole),
    74 :	CBaseBulkTestCase(KTestCaseId,aHostRole),
    69 	iCaseStep(EInProgress)
    75 	iCaseStep(EInProgress)
    70 	{
    76 	{
       
    77 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_ENTRY, this );
       
    78 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_EXIT, this );
    71 	} 
    79 	} 
    72 
    80 
    73 
    81 
    74 void CUT_PBASE_T_USBDI_1229::ConstructL()
    82 void CUT_PBASE_T_USBDI_1229::ConstructL()
    75 	{
    83 	{
       
    84 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_CONSTRUCTL_ENTRY, this );
    76 	BaseBulkConstructL();
    85 	BaseBulkConstructL();
    77 
    86 
    78 	iInBuffer = HBufC8::NewL(KTestBufferLength);
    87 	iInBuffer = HBufC8::NewL(KTestBufferLength);
    79 
    88 
    80 	iBulkTestTimer = CBulkTestTimer::NewL(*this);	
    89 	iBulkTestTimer = CBulkTestTimer::NewL(*this);	
    90 	for(TInt i=0;i<repeats;i++)
    99 	for(TInt i=0;i<repeats;i++)
    91 		{
   100 		{
    92 		iOutBufferPtr.Append(KLiteralEnglish5());
   101 		iOutBufferPtr.Append(KLiteralEnglish5());
    93 		}
   102 		}
    94 
   103 
    95 	RDebug::Printf("CUT_PBASE_T_USBDI_1229::ConstructL(): buffer created");
   104 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_CONSTRUCTL, "CUT_PBASE_T_USBDI_1229::ConstructL(): buffer created");
       
   105 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_CONSTRUCTL_EXIT, this );
    96 	}
   106 	}
    97 
   107 
    98 
   108 
    99 CUT_PBASE_T_USBDI_1229::~CUT_PBASE_T_USBDI_1229()
   109 CUT_PBASE_T_USBDI_1229::~CUT_PBASE_T_USBDI_1229()
   100 	{
   110 	{
   101 	LOG_FUNC
   111 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_ENTRY_DUP01, this );
       
   112 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_CUT_PBASE_T_USBDI_1229_EXIT_DUP01, this );
   102 	}
   113 	}
   103 	
   114 	
   104 void CUT_PBASE_T_USBDI_1229::KillTransfers()
   115 void CUT_PBASE_T_USBDI_1229::KillTransfers()
   105 	{
   116 	{
   106 	LOG_FUNC
   117 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_KILLTRANSFERS_ENTRY, this );
   107 	
   118 	
   108 	iOutTransfer[0]->Cancel();
   119 	iOutTransfer[0]->Cancel();
   109 	iOutTransfer[1]->Cancel();
   120 	iOutTransfer[1]->Cancel();
       
   121 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_KILLTRANSFERS_EXIT, this );
   110 	}
   122 	}
   111 
   123 
   112 void CUT_PBASE_T_USBDI_1229::ExtractDeviceReadBytes()
   124 void CUT_PBASE_T_USBDI_1229::ExtractDeviceReadBytes()
   113 	{
   125 	{
   114 	LOG_FUNC
   126 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_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 read on its bulk out endpoint ...");
   132 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES, "Collect client's return of the number of bytes read on its bulk out 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_1229_EXTRACTDEVICEREADBYTES_DUP01, "********************NUM*BYTES****************************");
   125 	RDebug::Printf("         NUM BYTES READ BY CLIENT ==== %d ====           ", numBytes);
   137 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_DUP02, "         NUM BYTES READ BY CLIENT ==== %d ====           ", numBytes);
   126 	RDebug::Printf("********************NUM*BYTES****************************");
   138 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EXTRACTDEVICEREADBYTES_DUP03, "********************NUM*BYTES****************************");
   127 	RDebug::Printf("\n");
   139 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_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_1229_EXTRACTDEVICEREADBYTES_EXIT, this );
   137 	}
   150 	}
   138 
   151 
   139 
   152 
   140 void CUT_PBASE_T_USBDI_1229::PostTransferAction()
   153 void CUT_PBASE_T_USBDI_1229::PostTransferAction()
   141 	{
   154 	{
       
   155 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_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 			//indicates data validation failure
   163 			//indicates data validation failure
   150 			{
   164 			{
   151 			RDebug::Printf("Asking client to post validation recorded on the endpoint on its interface - ready for collection");
   165 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION, "Asking client to post validation recorded on the endpoint on its interface - ready for collection");
   152 			iCaseStep = ERequestPrepareEndpointValidationResult;
   166 			iCaseStep = ERequestPrepareEndpointValidationResult;
   153 			TRecordedValidationResultRequest request(1,1);
   167 			TRecordedValidationResultRequest request(1,1);
   154 			iControlEp0->SendRequest(request,this);
   168 			iControlEp0->SendRequest(request,this);
   155 			}
   169 			}
       
   170 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION_EXIT, this );
   156 			return;
   171 			return;
   157 		
   172 		
   158 		default:
   173 		default:
   159 			{
   174 			{
   160 			iCaseStep = EFailed;
   175 			iCaseStep = EFailed;
   161 			RDebug::Print(iMsg);
   176 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION_DUP01, iMsg);
   162 			TTestCaseFailed request(iTransferResult,iMsg);
   177 			TTestCaseFailed request(iTransferResult,iMsg);
   163 			iControlEp0->SendRequest(request,this);
   178 			iControlEp0->SendRequest(request,this);
   164 			}
   179 			}
       
   180 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_POSTTRANSFERACTION_EXIT_DUP01, this );
   165 			return;
   181 			return;
   166 		}
   182 		}
   167 	}
   183 	}
   168 
   184 
   169 
   185 
   170 TBool CUT_PBASE_T_USBDI_1229::PerformNextTransfer(TInt aTransferId)
   186 TBool CUT_PBASE_T_USBDI_1229::PerformNextTransfer(TInt aTransferId)
   171 	{
   187 	{
   172 	LOG_FUNC
   188 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER_ENTRY, this );
   173 	
   189 	
   174 	if(iNumWriteBytesRequested >= KTotalBytesToTransfer)
   190 	if(iNumWriteBytesRequested >= KTotalBytesToTransfer)
   175 		{
   191 		{
   176 		RDebug::Printf("All transfers sent - num bytes actually written = %d, num bytes required to be written = %d", iNumWriteBytesRequested, KTotalBytesToTransfer);
   192 		OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER, "All transfers sent - num bytes actually written = %u, num bytes required to be written = %u", iNumWriteBytesRequested, KTotalBytesToTransfer);
       
   193 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER_EXIT, this, EFalse );
   177 		return EFalse; //Not writing any more - signal to user that no more transfers are required
   194 		return EFalse; //Not writing any more - signal to user that no more transfers are required
   178 		}
   195 		}
   179 	TUint bytesToWrite = KTotalBytesToTransfer - iNumWriteBytesRequested;
   196 	TUint bytesToWrite = KTotalBytesToTransfer - iNumWriteBytesRequested;
   180 	TUint numWriteBytes = bytesToWrite < KHostNumWriteBytes ? bytesToWrite : KHostNumWriteBytes;
   197 	TUint numWriteBytes = bytesToWrite < KHostNumWriteBytes ? bytesToWrite : KHostNumWriteBytes;
   181 
   198 
   183 	__ASSERT_DEBUG(aTransferId==KBulkTransferOutId[0] || aTransferId==KBulkTransferOutId[1], User::Panic(lit, KErrArgument));
   200 	__ASSERT_DEBUG(aTransferId==KBulkTransferOutId[0] || aTransferId==KBulkTransferOutId[1], User::Panic(lit, KErrArgument));
   184 	CBulkTransfer& bulkTransfer = aTransferId==KBulkTransferOutId[0]?*iOutTransfer[0]:*iOutTransfer[1];
   201 	CBulkTransfer& bulkTransfer = aTransferId==KBulkTransferOutId[0]?*iOutTransfer[0]:*iOutTransfer[1];
   185 	bulkTransfer.TransferOut(iOutBufferPtr.Mid(iNumWriteBytesRequested%(KLiteralEnglish5().Length()), numWriteBytes), EFalse);
   202 	bulkTransfer.TransferOut(iOutBufferPtr.Mid(iNumWriteBytesRequested%(KLiteralEnglish5().Length()), numWriteBytes), EFalse);
   186 	iNumWriteBytesRequested += numWriteBytes;
   203 	iNumWriteBytesRequested += numWriteBytes;
   187 
   204 
       
   205 	OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1229_PERFORMNEXTTRANSFER_EXIT_DUP01, this, ETrue );
   188 	return ETrue;
   206 	return ETrue;
   189 	}
   207 	}
   190 
   208 
   191 	
   209 	
   192 void CUT_PBASE_T_USBDI_1229::RequestNumBytesSent(TUint8 aTimerIndex)
   210 void CUT_PBASE_T_USBDI_1229::RequestNumBytesSent(TUint8 aTimerIndex)
   193 	{
   211 	{
       
   212 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_REQUESTNUMBYTESSENT_ENTRY, this );
   194 	iInBufferPtr.Set(iInBuffer->Des());
   213 	iInBufferPtr.Set(iInBuffer->Des());
   195 	iInBufferPtr.Zero(); //reset
   214 	iInBufferPtr.Zero(); //reset
   196 	iInBufferPtr.SetLength(KNumberStringLength);
   215 	iInBufferPtr.SetLength(KNumberStringLength);
   197 	TInterfaceGetRecordedNumBytesReadInPayload request(1,1,iInBufferPtr);
   216 	TInterfaceGetRecordedNumBytesReadInPayload request(1,1,iInBufferPtr);
   198 	iControlEp0->SendRequest(request,this);
   217 	iControlEp0->SendRequest(request,this);
   199 	iControlEp0->LastRequestStartTime( iStartTime[aTimerIndex]);
   218 	iControlEp0->LastRequestStartTime( iStartTime[aTimerIndex]);
       
   219 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_REQUESTNUMBYTESSENT_EXIT, this );
   200 	}
   220 	}
   201 
   221 
   202 
   222 
   203 void CUT_PBASE_T_USBDI_1229::Ep0TransferCompleteL(TInt aCompletionCode)
   223 void CUT_PBASE_T_USBDI_1229::Ep0TransferCompleteL(TInt aCompletionCode)
   204 	{
   224 	{
   205 	LOG_FUNC
   225 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_ENTRY, this );
   206 	
   226 	
   207 	RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d, test step = %d", aCompletionCode, iCaseStep);
   227 	OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d, test step = %d", aCompletionCode, iCaseStep);
   208 	
   228 	
   209 	if(aCompletionCode != KErrNone)
   229 	if(aCompletionCode != KErrNone)
   210 		{
   230 		{
   211 		if(iCaseStep == EFailed)
   231 		if(iCaseStep == EFailed)
   212 			{// ignore error, nad catch the TestFailed method called further down.
   232 			{// ignore error, nad catch the TestFailed method called further down.
   213 			RDebug::Printf("***Failure sending FAIL message to client on endpoint 0***");
   233 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP01, "***Failure sending FAIL message to client on endpoint 0***");
   214 			}
   234 			}
   215 		else
   235 		else
   216 			{
   236 			{
   217 			TBuf<256> msg;
   237 			TBuf<256> msg;
   218 			KillTransfers();
   238 			KillTransfers();
   219 			_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful");
   239 			_LIT(lit, "<Error %d> Transfer to control endpoint 0 was not successful");
   220 			msg.Format(lit,aCompletionCode);
   240 			msg.Format(lit,aCompletionCode);
   221 			RDebug::Print(msg);
   241 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP02, msg);
   222 			iCaseStep = EFailed;
   242 			iCaseStep = EFailed;
   223 			TTestCaseFailed request(aCompletionCode,msg);
   243 			TTestCaseFailed request(aCompletionCode,msg);
   224 			iControlEp0->SendRequest(request,this);
   244 			iControlEp0->SendRequest(request,this);
       
   245 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_EXIT, this );
   225 			return;
   246 			return;
   226 			}
   247 			}
   227 		}
   248 		}
   228 	
   249 	
   229 	switch(iCaseStep)
   250 	switch(iCaseStep)
   239 			break;
   260 			break;
   240 		
   261 		
   241 		case EGetTimerBase:
   262 		case EGetTimerBase:
   242 			{
   263 			{
   243 			iControlEp0->LastRequestCompletionTime( iEndTime[KBaseTimer]);
   264 			iControlEp0->LastRequestCompletionTime( iEndTime[KBaseTimer]);
   244 			RDebug::Printf("Asking client for continuous 'Read' and 'Validate'");
   265 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP03, "Asking client for continuous 'Read' and 'Validate'");
   245 			iCaseStep = ERequestRepeatedReadAndValidate;
   266 			iCaseStep = ERequestRepeatedReadAndValidate;
   246 			TRepeatedReadAndValidateDataRequest request(1,1,KLiteralEnglish5(),KDeviceNumReadBytes,KTotalBytesToTransfer);// EP2 means endpoint index 2 not the actual endpoint number, here the ep with 32 byte max packet size
   267 			TRepeatedReadAndValidateDataRequest request(1,1,KLiteralEnglish5(),KDeviceNumReadBytes,KTotalBytesToTransfer);// EP2 means endpoint index 2 not the actual endpoint number, here the ep with 32 byte max packet size
   247 			iControlEp0->SendRequest(request,this);
   268 			iControlEp0->SendRequest(request,this);
   248 			}
   269 			}
   249 			break;
   270 			break;
   250 			
   271 			
   251 		case ERequestRepeatedReadAndValidate:
   272 		case ERequestRepeatedReadAndValidate:
   252 			{
   273 			{
   253 			RDebug::Printf("Try to perform ALL transfers");
   274 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP04, "Try to perform ALL transfers");
   254 	
   275 	
   255 			iCaseStep = ETransfer;	
   276 			iCaseStep = ETransfer;	
   256 			
   277 			
   257 			PerformNextTransfer(KBulkTransferOutId[0]);
   278 			PerformNextTransfer(KBulkTransferOutId[0]);
   258 			PerformNextTransfer(KBulkTransferOutId[1]);
   279 			PerformNextTransfer(KBulkTransferOutId[1]);
   276 			PostTransferAction();
   297 			PostTransferAction();
   277 			break;
   298 			break;
   278 			
   299 			
   279 		case ERequestPrepareEndpointValidationResult:
   300 		case ERequestPrepareEndpointValidationResult:
   280 			{
   301 			{
   281 			RDebug::Printf("Asking client to prepare the result of its continuous validation");
   302 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP05, "Asking client to prepare the result of its continuous validation");
   282 			iCaseStep = ERequestValidationResult;
   303 			iCaseStep = ERequestValidationResult;
   283 			iInBufferPtr.Set(iInBuffer->Des());
   304 			iInBufferPtr.Set(iInBuffer->Des());
   284 			iInBufferPtr.Zero(); //reset
   305 			iInBufferPtr.Zero(); //reset
   285 			iInBufferPtr.SetLength(KPassFailStringLength);
   306 			iInBufferPtr.SetLength(KPassFailStringLength);
   286 			TInterfaceGetPayloadRequest request(1,iInBufferPtr);
   307 			TInterfaceGetPayloadRequest request(1,iInBufferPtr);
   287 			iControlEp0->SendRequest(request,this);
   308 			iControlEp0->SendRequest(request,this);
   288 			}
   309 			}
   289 			break;
   310 			break;
   290 	
   311 	
   291 		case ERequestValidationResult:
   312 		case ERequestValidationResult:
   292 			RDebug::Printf("Collect client's return validation  result in a pass or fail string ...");
   313 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP06, "Collect client's return validation  result in a pass or fail string ...");
   293 			RDebug::RawPrint(*iInBuffer);
   314             OstTraceData(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP56, "", iInBuffer->Ptr(), iInBuffer->Length());
   294 			RDebug::Printf("\n");
   315 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP07, "\n");
   295 			iInBufferPtr.Set(iInBuffer->Des());
   316 			iInBufferPtr.Set(iInBuffer->Des());
   296 			if(iInBufferPtr.Compare(KClientPassString) == 0)
   317 			if(iInBufferPtr.Compare(KClientPassString) == 0)
   297 				{
   318 				{
   298 				RDebug::Printf("Client Validation Result is a PASS");
   319 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP08, "Client Validation Result is a PASS");
   299 				RDebug::Printf("This is the FINAL check - the whole test has a PASSED");
   320 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP09, "This is the FINAL check - the whole test has a PASSED");
   300 				iCaseStep = EPassed;
   321 				iCaseStep = EPassed;
   301 				TTestCasePassed request;
   322 				TTestCasePassed request;
   302 				iControlEp0->SendRequest(request,this);
   323 				iControlEp0->SendRequest(request,this);
   303 				}
   324 				}
   304 			else
   325 			else
   305 				{
   326 				{
   306 				TBuf<256> msg;
   327 				TBuf<256> msg;
   307 				_LIT(lit, "<Error> Bulk data VALIDATION check was NOT successful");
   328 				_LIT(lit, "<Error> Bulk data VALIDATION check was NOT successful");
   308 				msg.Format(lit);
   329 				msg.Format(lit);
   309 				RDebug::Print(msg);
   330 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP10, msg);
   310 				iCaseStep = EFailed;
   331 				iCaseStep = EFailed;
   311 				TTestCaseFailed request(KErrCorrupt,msg);
   332 				TTestCaseFailed request(KErrCorrupt,msg);
   312 				iControlEp0->SendRequest(request,this);
   333 				iControlEp0->SendRequest(request,this);
   313 				}
   334 				}
   314 			break;
   335 			break;
   315 	
   336 	
   316 		default:
   337 		default:
   317 			RDebug::Printf("<Error> Unknown test step");
   338 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_DUP11, "<Error> Unknown test step");
   318 			TestFailed(KErrUnknown);
   339 			TestFailed(KErrUnknown);
   319 			break;
   340 			break;
   320 		}
   341 		}
       
   342 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
   321 	}
   343 	}
   322 	
   344 	
   323 void CUT_PBASE_T_USBDI_1229::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
   345 void CUT_PBASE_T_USBDI_1229::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
   324 	{
   346 	{
   325 	LOG_FUNC
   347 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_ENTRY, this );
   326 	Cancel();
   348 	Cancel();
   327 	
   349 	
   328 	iTransferResult = KErrNone;
   350 	iTransferResult = KErrNone;
   329 	RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
   351 	OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL, "Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
   330 
   352 
   331 
   353 
   332 	switch(iCaseStep)
   354 	switch(iCaseStep)
   333 		{
   355 		{
   334 		case ETransfer:
   356 		case ETransfer:
   346 				iTransferResult = KUnexpectedTransferID;
   368 				iTransferResult = KUnexpectedTransferID;
   347 				_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d");
   369 				_LIT(lit, "<Error %d> Unexpected transfer ID, wanted %d or %d, got %d");
   348 				iMsg.Format(lit, iTransferResult, KBulkTransferOutId[0], KBulkTransferOutId[1], aTransferId);
   370 				iMsg.Format(lit, iTransferResult, KBulkTransferOutId[0], KBulkTransferOutId[1], aTransferId);
   349 				break;
   371 				break;
   350 				}
   372 				}
   351 			RDebug::Printf("Transfer OUT %d completed - num bytes sent = %d", aTransferId, iNumWriteBytesRequested);
   373 			OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP01, "Transfer OUT %d completed - num bytes sent = %d", aTransferId, iNumWriteBytesRequested);
   352 			
   374 			
   353 			if(PerformNextTransfer(aTransferId)==EFalse)
   375 			if(PerformNextTransfer(aTransferId)==EFalse)
   354 				{
   376 				{
   355 				iTransferComplete |= aTransferId;
   377 				iTransferComplete |= aTransferId;
   356 				RDebug::Printf("All transfer OUT %ds completed (Transfer Completion Aggregation Mask 0x%x)", aTransferId, iTransferComplete);
   378 				OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP02, "All transfer OUT %ds completed (Transfer Completion Aggregation Mask 0x%x)", aTransferId, iTransferComplete);
   357 				}
   379 				}
   358 			
   380 			
   359 			if(iTransferResult==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask)
   381 			if(iTransferResult==KErrNone && (iTransferComplete & KBulkTransferIdMask) == KBulkTransferIdMask)
   360 				{
   382 				{
   361 				/*
   383 				/*
   362 				Transfers all complete - now ask device to validate first interface's transfer OUT
   384 				Transfers all complete - now ask device to validate first interface's transfer OUT
   363 				*/
   385 				*/
   364 				RDebug::Printf("All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
   386 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP03, "All Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
   365 				if(iTransferResult==KErrNone)
   387 				if(iTransferResult==KErrNone)
   366 					{
   388 					{
   367 					iBulkTestTimer->Cancel(); //Cancel Timer 
   389 					iBulkTestTimer->Cancel(); //Cancel Timer 
   368 					iTransferResult = KTransferSuccess;
   390 					iTransferResult = KTransferSuccess;
   369 					if(iTimingError == KErrTooBig)
   391 					if(iTimingError == KErrTooBig)
   372 						iTransferResult = KErrTooBig;
   394 						iTransferResult = KErrTooBig;
   373 						iTimingError = KErrNone; //reset
   395 						iTimingError = KErrNone; //reset
   374 						}
   396 						}
   375 					if(KMaxBytesReadDiffPercentage*iDeviceMaxTimedNumBytesRead > KPercent*iDeviceMinTimedNumBytesRead)
   397 					if(KMaxBytesReadDiffPercentage*iDeviceMaxTimedNumBytesRead > KPercent*iDeviceMinTimedNumBytesRead)
   376 						{
   398 						{
   377 						RDebug::Printf("Device APPARENTLY reading rate erratic:-");
   399 						OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP04, "Device APPARENTLY reading rate erratic:-");
   378 						RDebug::Printf("Min Timed Number of Bytes = %d", iDeviceMinTimedNumBytesRead);
   400 						OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP05, "Min Timed Number of Bytes = %d", iDeviceMinTimedNumBytesRead);
   379 						RDebug::Printf("Max Timed Number of Bytes = %d", iDeviceMaxTimedNumBytesRead);
   401 						OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_DUP06, "Max Timed Number of Bytes = %d", iDeviceMaxTimedNumBytesRead);
   380 						iTransferResult = KErrTooBig;
   402 						iTransferResult = KErrTooBig;
   381 						iDeviceMaxTimedNumBytesRead = 0;
   403 						iDeviceMaxTimedNumBytesRead = 0;
   382 						iDeviceMinTimedNumBytesRead = KMaxTUint;
   404 						iDeviceMinTimedNumBytesRead = KMaxTUint;
   383 						}
   405 						}
   384 					}
   406 					}
   422 		else
   444 		else
   423 			{
   445 			{
   424 			iCaseStep = EDelayedTransferComplete; //so that we move forward when the EP0 transfer has completed
   446 			iCaseStep = EDelayedTransferComplete; //so that we move forward when the EP0 transfer has completed
   425 			}
   447 			}
   426 		}
   448 		}
       
   449 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_TRANSFERCOMPLETEL_EXIT, this );
   427 	}
   450 	}
   428 	
   451 	
   429 void CUT_PBASE_T_USBDI_1229::DeviceInsertedL(TUint aDeviceHandle)
   452 void CUT_PBASE_T_USBDI_1229::DeviceInsertedL(TUint aDeviceHandle)
   430 	{
   453 	{
   431 	LOG_FUNC
   454 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_ENTRY, this );
   432 	
   455 	
   433 	Cancel();
   456 	Cancel();
   434 	RDebug::Printf("this - %08x", this);
   457 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL, "this - %08x", this);
   435 	
   458 	
   436 	TBuf<256> msg;
   459 	TBuf<256> msg;
   437 	TInt err = KErrNone;
   460 	TInt err = KErrNone;
   438 	if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
   461 	if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
   439 		// Prepare for response from control transfer to client
   462 		// Prepare for response from control transfer to client
   456 	
   479 	
   457 			iOutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[0]);
   480 			iOutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[0]);
   458 			iOutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[1]);
   481 			iOutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KBulkTransferOutId[1]);
   459 			
   482 			
   460 			// Initialise the descriptors for transfer		
   483 			// Initialise the descriptors for transfer		
   461 			RDebug::Printf("Initialising the transfer descriptors - interface 1");
   484 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_DUP01, "Initialising the transfer descriptors - interface 1");
   462 			err = iUsbInterface1.InitialiseTransferDescriptors();
   485 			err = iUsbInterface1.InitialiseTransferDescriptors();
   463 			if(err != KErrNone)
   486 			if(err != KErrNone)
   464 				{
   487 				{
   465 				_LIT(lit, "<Error %d> Unable to initialise transfer descriptors");
   488 				_LIT(lit, "<Error %d> Unable to initialise transfer descriptors");
   466 				msg.Format(lit,err);
   489 				msg.Format(lit,err);
   467 				}
   490 				}
   468 			}
   491 			}
   469 		}
   492 		}
   470 	if(err != KErrNone)
   493 	if(err != KErrNone)
   471 		{
   494 		{
   472 		RDebug::Print(msg);
   495 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_DUP02, msg);
   473 		iCaseStep = EFailed;
   496 		iCaseStep = EFailed;
   474 		TTestCaseFailed request(err,msg);
   497 		TTestCaseFailed request(err,msg);
   475 		iControlEp0->SendRequest(request,this);
   498 		iControlEp0->SendRequest(request,this);
   476 		}
   499 		}
   477 	else
   500 	else
   480 		iDeviceMinTimedNumBytesRead = KMaxTUint;
   503 		iDeviceMinTimedNumBytesRead = KMaxTUint;
   481 		iDeviceMaxTimedNumBytesRead = 0;
   504 		iDeviceMaxTimedNumBytesRead = 0;
   482 		iDeviceNumBytesReadInTotal = 0;
   505 		iDeviceNumBytesReadInTotal = 0;
   483 		RequestNumBytesSent(KBaseTimer);
   506 		RequestNumBytesSent(KBaseTimer);
   484 		}
   507 		}
       
   508 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_DEVICEINSERTEDL_EXIT, this );
   485 	}
   509 	}
   486 
   510 
   487 void CUT_PBASE_T_USBDI_1229::HandleBulkTestTimerFired()
   511 void CUT_PBASE_T_USBDI_1229::HandleBulkTestTimerFired()
   488 	{
   512 	{
       
   513 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1229_HANDLEBULKTESTTIMERFIRED_ENTRY, this );
   489 	if(iCaseStep == ETransfer)
   514 	if(iCaseStep == ETransfer)
   490 		{
   515 		{
   491 		RequestNumBytesSent(KTestTimer);
   516 		RequestNumBytesSent(KTestTimer);
   492 		}
   517 		}
       
   518 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1229_HANDLEBULKTESTTIMERFIRED_EXIT, this );
   493 	}
   519 	}
   494 	
   520 	
   495 	} //end namespace
   521 	} //end namespace