kerneltest/e32test/usbho/t_usbdi/src/endpointreader.cpp
changeset 259 57b9594f5772
parent 0 a41df078684a
child 257 3e88ff8f41d5
--- a/kerneltest/e32test/usbho/t_usbdi/src/endpointreader.cpp	Wed Aug 18 11:08:29 2010 +0300
+++ b/kerneltest/e32test/usbho/t_usbdi/src/endpointreader.cpp	Thu Sep 02 21:54:16 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of the License "Eclipse Public License v1.0"
@@ -19,6 +19,10 @@
 #include "endpointreader.h"
 #include "controltransferrequests.h"
 #include "testdebug.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "endpointreaderTraces.h"
+#endif
 
 namespace NUnitTesting_USBDI
 	{
@@ -31,38 +35,47 @@
 	iDataPtr(NULL,0),
 	iValidationPatternPtr(NULL,0)
 	{
+	OstTraceFunctionEntryExt( CENDPOINTREADER_CENDPOINTREADER_ENTRY, this );
 	CActiveScheduler::Add(this);
+	OstTraceFunctionExit1( CENDPOINTREADER_CENDPOINTREADER_EXIT, this );
 	}
 	
 CEndpointReader::~CEndpointReader()
 	{
-	LOG_FUNC
+	OstTraceFunctionEntry1( CENDPOINTREADER_CENDPOINTREADER_ENTRY_DUP01, this );
 	Cancel();
 	delete iDataBuffer;
 	iDataBuffer = NULL;
 	delete iValidationPatternBuffer;
 	iValidationPatternBuffer = NULL;
+	OstTraceFunctionExit1( CENDPOINTREADER_CENDPOINTREADER_EXIT_DUP01, this );
 	}
 			
 TPtr8 CEndpointReader::Buffer()
 	{
+	OstTraceFunctionEntry1( CENDPOINTREADER_BUFFER_ENTRY, this );
+	OstTraceFunctionExitExt( CENDPOINTREADER_BUFFER_EXIT, this, ( TUint )&( iDataPtr ) );
 	return iDataPtr;
 	}
 
 TBool CEndpointReader::IsValid()
 	{
+	OstTraceFunctionEntry1( CENDPOINTREADER_ISVALID_ENTRY, this );
+	OstTraceFunctionExitExt( CENDPOINTREADER_ISVALID_EXIT, this, iIsValid );
 	return iIsValid;
 	}
 
 TUint CEndpointReader::NumBytesReadSoFar()
 	{
+	OstTraceFunctionEntry1( CENDPOINTREADER_NUMBYTESREADSOFAR_ENTRY, this );
+	OstTraceFunctionExitExt( CENDPOINTREADER_NUMBYTESREADSOFAR_EXIT, this, iNumBytesReadSoFar );
 	return iNumBytesReadSoFar;
 	}
 
 void CEndpointReader::ReadPacketL(MEndpointDataHandler* aHandler)
 	{
-	LOG_FUNC
-	RDebug::Printf("Endpoint %d", iEndpoint);
+	OstTraceFunctionEntryExt( CENDPOINTREADER_READPACKETL_ENTRY, this );
+	OstTrace1(TRACE_NORMAL, CENDPOINTREADER_READPACKETL, "Endpoint %d", iEndpoint);
 	
 	iHandler = aHandler;
 
@@ -79,13 +92,14 @@
 	// Read from the endpoint
 	iClientDriver.ReadPacket(iStatus,iEndpoint,iDataPtr,KFullSpeedPacketSize);
 	SetActive();
+	OstTraceFunctionExit1( CENDPOINTREADER_READPACKETL_EXIT, this );
 	}
 
 
 void CEndpointReader::ReadL(TInt aByteCount)
 	{
-	LOG_FUNC
-	RDebug::Printf("Endpoint %d", iEndpoint);
+	OstTraceFunctionEntryExt( CENDPOINTREADER_READL_ENTRY, this );
+	OstTrace1(TRACE_NORMAL, CENDPOINTREADER_READL, "Endpoint %d", iEndpoint);
 	
 	// Allocate buffer for reading a data packet
 	if(iDataBuffer)
@@ -99,12 +113,13 @@
 	// Read from the endpoint
 	iClientDriver.Read(iStatus,iEndpoint,iDataPtr,aByteCount);
 	SetActive();
+	OstTraceFunctionExit1( CENDPOINTREADER_READL_EXIT, this );
 	}
 
 void CEndpointReader::ReadUntilShortL(TInt aByteCount)
 	{
-	LOG_FUNC
-	RDebug::Printf("Endpoint %d", iEndpoint);
+	OstTraceFunctionEntryExt( CENDPOINTREADER_READUNTILSHORTL_ENTRY, this );
+	OstTrace1(TRACE_NORMAL, CENDPOINTREADER_READUNTILSHORTL, "Endpoint %d", iEndpoint);
 	
 	// Allocate buffer for reading a data packet
 	if(iDataBuffer)
@@ -118,18 +133,20 @@
 	// Read from the endpoint
 	iClientDriver.ReadUntilShort(iStatus,iEndpoint,iDataPtr,aByteCount);
 	SetActive();
+	OstTraceFunctionExit1( CENDPOINTREADER_READUNTILSHORTL_EXIT, this );
 	}
 
 void CEndpointReader::ReadAndHaltL(TInt aByteCount)
 	{
-	LOG_FUNC
+	OstTraceFunctionEntryExt( CENDPOINTREADER_READANDHALTL_ENTRY, this );
 	iCompletionAction = EHaltEndpoint;
 	ReadL(aByteCount);
+	OstTraceFunctionExit1( CENDPOINTREADER_READANDHALTL_EXIT, this );
 	}
 
 void CEndpointReader::RepeatedReadAndValidateL(const TDesC8& aDataPattern, TUint aNumBytesPerRead, TUint aTotalNumBytes)
 	{
-	LOG_FUNC
+OstTraceFunctionEntryExt( CENDPOINTREADER_REPEATEDREADANDVALIDATEL_ENTRY, this );
 
 	iCompletionAction = ERepeatedRead;
 	iRepeatedReadTotalNumBytes = aTotalNumBytes;
@@ -137,7 +154,7 @@
 	iNumBytesReadSoFar = 0;
 	iDataPatternLength = aDataPattern.Length();
 	iIsValid = ETrue; //until proven guilty!
-	RDebug::Printf("Total Bytes To Read: %d, Bytes Per Individual Read: %d", iRepeatedReadTotalNumBytes, iRepeatedReadNumBytesPerRead);
+	OstTraceExt2(TRACE_NORMAL, CENDPOINTREADER_REPEATEDREADANDVALIDATEL, "Total Bytes To Read: %u, Bytes Per Individual Read: %u", iRepeatedReadTotalNumBytes, iRepeatedReadNumBytesPerRead);
 	//Create buffer to contain two lots of the payload pattern
 	//..so that we may grab cyclic chunks of said payload pattern
 	delete iValidationPatternBuffer;
@@ -151,36 +168,39 @@
 		}
 
 	ReadUntilShortL(iRepeatedReadNumBytesPerRead);
+	OstTraceFunctionExit1( CENDPOINTREADER_REPEATEDREADANDVALIDATEL_EXIT, this );
 	}
 
 
 TInt CEndpointReader::Acknowledge()
 	{
-	LOG_FUNC
+	OstTraceFunctionEntry1( CENDPOINTREADER_ACKNOWLEDGE_ENTRY, this );
 	TInt err(iClientDriver.SendEp0StatusPacket());
 	if(err != KErrNone)
 		{
-		RDebug::Printf("<Error %d> Sending acknowledge packet",err);
+		OstTrace1(TRACE_NORMAL, CENDPOINTREADER_ACKNOWLEDGE, "<Error %d> Sending acknowledge packet",err);
 		}
+	OstTraceFunctionExitExt( CENDPOINTREADER_ACKNOWLEDGE_EXIT, this, err );
 	return err;
 	}
 			
 			
 void CEndpointReader::DoCancel()
 	{
-	LOG_FUNC
+	OstTraceFunctionEntry1( CENDPOINTREADER_DOCANCEL_ENTRY, this );
 	
 	// Cancel reading from the endpoint
 	
 	iClientDriver.ReadCancel(iEndpoint);
+	OstTraceFunctionExit1( CENDPOINTREADER_DOCANCEL_EXIT, this );
 	}
 	
 	
 void CEndpointReader::RunL()
 	{
-	LOG_FUNC
-	RDebug::Printf("Endpoint %d", iEndpoint);
-	RDebug::Printf("Completion Action %d", iCompletionAction);
+	OstTraceFunctionEntry1( CENDPOINTREADER_RUNL_ENTRY, this );
+	OstTrace1(TRACE_NORMAL, CENDPOINTREADER_RUNL, "Endpoint %d", iEndpoint);
+	OstTrace1(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP01, "Completion Action %d", iCompletionAction);
 	TCompletionAction completionAction = iCompletionAction;
 	iCompletionAction = ENone; //reset here in case of 'early' returns
 	
@@ -189,7 +209,7 @@
 	
 	if(completionCode != KErrNone)
 		{
-		RDebug::Printf("<Error> void CEndpointReader::RunL()completed with ERROR %d", completionCode);
+		OstTrace1(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP02, "<Error> void CEndpointReader::RunL()completed with ERROR %d", completionCode);
 		
 		// Nak the packet received
 		iClientDriver.HaltEndpoint(iEndpoint);
@@ -200,7 +220,7 @@
 			}
 		else
 			{
-			RDebug::Printf("No handler set");
+			OstTrace0(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP03, "No handler set");
 			}
 		}
 	else
@@ -210,7 +230,7 @@
 		ent = ent==0?1:ent;
 		for(TInt i=0; i<iDataBuffer->Length(); i+=ent)
 			{
-			RDebug::Printf("byte %d %02x %c",i,(*iDataBuffer)[i],(*iDataBuffer)[i]);
+			OstTraceExt3(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP04, "byte %d %02x %c",i,(*iDataBuffer)[i],(*iDataBuffer)[i]);
 			}
 
 		if(iHandler)
@@ -219,18 +239,18 @@
 			}
 		else
 			{
-			RDebug::Printf("No handler set");
+			OstTrace0(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP05, "No handler set");
 			}
 		
 		if(completionAction==EHaltEndpoint)
 			{
-			RDebug::Printf("Halting Endpoint");
+			OstTrace0(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP06, "Halting Endpoint");
 			iClientDriver.HaltEndpoint(iEndpoint);
 			}
 
 		if(completionAction==ERepeatedRead)
 			{
-			RDebug::Printf("Repeated Read");
+			OstTrace0(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP07, "Repeated Read");
 			iCompletionAction = ERepeatedRead;
 			
 			//Prepare to validate
@@ -240,16 +260,16 @@
 			TInt err = iDataPtr.Compare(valDesc);
 
 			iNumBytesReadSoFar += iDataPtr.Length();
-			RDebug::Printf("Bytes read so far %d, Total bytes to read %d", iNumBytesReadSoFar, iRepeatedReadTotalNumBytes);
+			OstTraceExt2(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP08, "Bytes read so far %u, Total bytes to read %u", iNumBytesReadSoFar, iRepeatedReadTotalNumBytes);
 
 			if(err!=0)
 				{
-				RDebug::Printf("Validation Result %d, Validation String Length %d, Bytes Actually Read %d", err, valDesc.Length(), iDataPtr.Length());
-				RDebug::Printf("Expected string, followed by read string");
-				RDebug::RawPrint(valDesc);
-				RDebug::Printf("\n");
-				RDebug::RawPrint(iDataPtr);
-				RDebug::Printf("\n");
+				OstTraceExt3(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP09, "Validation Result %d, Validation String Length %d, Bytes Actually Read %d", err, valDesc.Length(), iDataPtr.Length());
+				OstTrace0(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP10, "Expected string, followed by read string");
+                OstTraceData(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP50, "", valDesc.Ptr(), valDesc.Length());
+				OstTrace0(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP11, "\n");
+                OstTraceData(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP51, "", iDataPtr.Ptr(), iDataPtr.Length());
+				OstTrace0(TRACE_NORMAL, CENDPOINTREADER_RUNL_DUP12, "\n");
 				iIsValid = EFalse; //record validation error
 				}
 			
@@ -268,18 +288,20 @@
 				}
 			}
 		}
+	OstTraceFunctionExit1( CENDPOINTREADER_RUNL_EXIT, this );
 	}
 
 TInt CEndpointReader::RunError(TInt aError)
 	{
-	LOG_FUNC
+	OstTraceFunctionEntryExt( CENDPOINTREADER_RUNERROR_ENTRY, this );
 	
-	RDebug::Printf("<Leaving Error> void CEndpointReader::RunError()called with ERROR %d", aError);
+	OstTrace1(TRACE_NORMAL, CENDPOINTREADER_RUNERROR, "<Leaving Error> void CEndpointReader::RunError()called with ERROR %d", aError);
 
 	// Nak the packet received
 	iClientDriver.HaltEndpoint(iEndpoint);
 
 	aError = KErrNone;	
+	OstTraceFunctionExitExt( CENDPOINTREADER_RUNERROR_EXIT, this, aError );
 	return aError;
 	}