usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/AcmWriter.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
--- a/usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/AcmWriter.cpp	Tue Aug 31 17:01:47 2010 +0300
+++ b/usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/AcmWriter.cpp	Wed Sep 01 12:35:00 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -15,13 +15,14 @@
 *
 */
 
+#include <usb/usblogger.h>
 #include "AcmWriter.h"
 #include "AcmPort.h"
 #include "AcmPanic.h"
 #include "AcmUtils.h"
-#include "OstTraceDefinitions.h"
-#ifdef OST_TRACE_COMPILER_IN_USE
-#include "AcmWriterTraces.h"
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "ECACM");
 #endif
 
 CAcmWriter* CAcmWriter::NewL(CAcmPort& aPort, 
@@ -34,12 +35,12 @@
  * @return Ownership of a newly created CAcmWriter object
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_NEWL_ENTRY );
+	LOG_STATIC_FUNC_ENTRY
+
 	CAcmWriter* self = new(ELeave) CAcmWriter(aPort, aBufSize);
 	CleanupStack::PushL(self);
 	self->ConstructL();
 	CLEANUPSTACK_POP(self);
-	OstTraceFunctionExit0( CACMWRITER_NEWL_EXIT );
 	return self;
 	}
 
@@ -48,10 +49,11 @@
  * Destructor.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_CACMWRITER_DES_ENTRY );
+	LOG_FUNC
+
 	WriteCancel();
+
 	delete iBuffer;
-	OstTraceFunctionExit0( CACMWRITER_CACMWRITER_DES_EXIT );
 	}
 
 void CAcmWriter::Write(const TAny* aClientBuffer, TUint aLength)
@@ -62,8 +64,8 @@
  * @param aLength Number of bytes to write
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_WRITE_ENTRY );
-	OstTraceExt2( TRACE_NORMAL, CACMWRITER_WRITE, "CAcmWriter::Write;aClientBuffer=%p;aLength=%d", aClientBuffer, (TInt)aLength );
+	LOGTEXT3(_L8("CAcmWriter::Write aClientBuffer=0x%08x, aLength=%d"), 
+		aClientBuffer, aLength);
 
 	// Check we're open to requests and make a note of interesting data.
 	CheckNewRequest(aClientBuffer, aLength);
@@ -76,7 +78,6 @@
 	ReadDataFromClient();
 	// ...and write as much as we've got to the LDD
 	IssueWrite();
-	OstTraceFunctionExit0( CACMWRITER_WRITE_EXIT );
 	}
 
 void CAcmWriter::WriteCancel()
@@ -84,18 +85,18 @@
  * Cancel a write.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_WRITECANCEL_ENTRY );
+	LOG_FUNC
+
 	// Cancel any outstanding request on the LDD.
 	if ( iPort.Acm() )
 		{
-		OstTrace0( TRACE_NORMAL, CACMWRITER_WRITECANCEL, "CAcmWriter::WriteCancel;\tiPort.Acm() exists- calling WriteCancel on it" );
+		LOGTEXT(_L8("\tiPort.Acm() exists- calling WriteCancel on it"));
 		iPort.Acm()->WriteCancel();
 		}
 
 	// Reset our flag to say there's no current outstanding request. What's 
 	// already in our buffer can stay there.
 	iCurrentRequest.iClientPtr = NULL;
-	OstTraceFunctionExit0( CACMWRITER_WRITECANCEL_EXIT );
 	}
 
 void CAcmWriter::ResetBuffer()
@@ -103,20 +104,15 @@
  * Called by the port to clear the buffer.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_RESETBUFFER_ENTRY );
-	// A request is outstanding- C32 should protect against this.
+	LOG_FUNC
 
-	if (iCurrentRequest.iClientPtr != NULL)
-		{
-		OstTrace1( TRACE_FATAL, CACMWRITER_RESETBUFFER, 
-										"CAcmWriter::ResetBuffer;EPanicInternalError=%d", 
-										(TInt)EPanicInternalError );
-		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
-		}
+	// A request is outstanding- C32 should protect against this.
+	__ASSERT_DEBUG(!iCurrentRequest.iClientPtr, 
+		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
+
 	// Don't have anything to do. There are no pointers to reset. This 
 	// function may in the future (if we support KConfigWriteBufferedComplete) 
 	// do work, so leave the above assertion in.
-	OstTraceFunctionExit0( CACMWRITER_RESETBUFFER_EXIT );
 	}
 
 TInt CAcmWriter::SetBufSize(TUint aSize)
@@ -127,15 +123,13 @@
  * @param aSize The required size of the buffer.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_SETBUFSIZE_ENTRY );
-	OstTrace1( TRACE_NORMAL, CACMWRITER_SETBUFSIZE, "CAcmWriter::SetBufSize;aSize=%d", (TInt)aSize );
+	LOG_FUNC
+	LOGTEXT2(_L8("\taSize=%d"), aSize);
 
 	if ( iCurrentRequest.iClientPtr )
 		{
 		// A request is outstanding. C32 does not protect us against this.
-		OstTrace0( TRACE_NORMAL, CACMWRITER_SETBUFSIZE_DUP1, 
-				"CAcmWriter::SetBufSize;\t***a request is outstanding- returning KErrInUse" );
-		OstTraceFunctionExit0( CACMWRITER_SETBUFSIZE_EXIT );
+		LOGTEXT(_L8("\t***a request is outstanding- returning KErrInUse"));
 		return KErrInUse;
 		}
 
@@ -143,9 +137,7 @@
 	HBufC8* newBuf = HBufC8::New(static_cast<TInt>(aSize));
 	if ( !newBuf )
 		{
-		OstTrace0( TRACE_NORMAL, CACMWRITER_SETBUFSIZE_DUP2, 
-				"CAcmWriter::SetBufSize;\tfailed to create new buffer- returning KErrNoMemory" );
-		OstTraceFunctionExit0( CACMWRITER_SETBUFSIZE_EXIT_DUP1 );
+		LOGTEXT(_L8("\tfailed to create new buffer- returning KErrNoMemory"));
 		return KErrNoMemory;
 		}
 	delete iBuffer;
@@ -153,7 +145,6 @@
 	iBuf.Set(iBuffer->Des());
 	iBufSize = aSize;
 
-	OstTraceFunctionExit0( CACMWRITER_SETBUFSIZE_EXIT_DUP2 );
 	return KErrNone;
 	}
 
@@ -169,8 +160,6 @@
 	iBuf(NULL,0,0),
 	iPort(aPort)
 	{
-	OstTraceFunctionEntry0( CACMWRITER_CACMWRITER_CONS_ENTRY );
-	OstTraceFunctionExit0( CACMWRITER_CACMWRITER_CONS_EXIT );
 	}
 
 void CAcmWriter::ConstructL()
@@ -178,16 +167,9 @@
  * 2nd-phase constructor. 
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_CONSTRUCTL_ENTRY );
 	// Create the required buffer.
-	OstTrace0( TRACE_NORMAL, CACMWRITER_CONSTRUCTL, "CAcmWriter::ConstructL;\tabout to create iBuffer" );
-	TInt err = SetBufSize(iBufSize);
-	if (err < 0)
-		{
-		OstTrace1( TRACE_ERROR, CACMWRITER_CONSTRUCTL_DUP1, "CAcmWriter::ConstructL;err=%d", err );
-		User::Leave(err);
-		}
-	OstTraceFunctionExit0( CACMWRITER_CONSTRUCTL_EXIT );
+	LOGTEXT(_L8("\tabout to create iBuffer"));
+	LEAVEIFERRORL(SetBufSize(iBufSize));
 	}
 
 void CAcmWriter::WriteCompleted(TInt aError)
@@ -200,12 +182,12 @@
  * @param aError Error with which the write completed.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_WRITECOMPLETED_ENTRY );
-	OstTrace1( TRACE_NORMAL, CACMWRITER_WRITECOMPLETED, "CAcmWriter::WriteCompleted;aError=%d", (TInt)aError );					   	
+	LOG_FUNC
+	LOGTEXT2(_L8("\taError=%d"), aError);						   	
+
 	if(iLengthToGo == 0 || aError != KErrNone)
 		{
-		OstTrace1( TRACE_NORMAL, CACMWRITER_WRITECOMPLETED_DUP1, 
-				"CAcmWriter::WriteCompleted;\tcompleting request with %d", aError );
+		LOGTEXT2(_L8("\tcompleting request with %d"), aError);
 		CompleteRequest(aError);	
 		}
 	else
@@ -215,7 +197,6 @@
 		ReadDataFromClient();
 		IssueWrite();
 		}
-	OstTraceFunctionExit0( CACMWRITER_WRITECOMPLETED_EXIT );
 	}
 
 void CAcmWriter::ReadDataFromClient()
@@ -223,28 +204,22 @@
  * Read data from the client space into the internal buffer, prior to writing.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_READDATAFROMCLIENT_ENTRY );
+	LOG_FUNC
 	TPtr8 ptr((TUint8*)iBuf.Ptr(),
 			  0,
 			  Min(iBuf.MaxLength(), iLengthToGo));
 
 	TInt err = iPort.IPCRead(iCurrentRequest.iClientPtr,
 			ptr,
-			static_cast<TInt>(iOffsetIntoClientsMemory));
-	OstTrace1( TRACE_NORMAL, CACMWRITER_READDATAFROMCLIENT, "CAcmWriter::ReadDataFromClient;\tIPCRead = %d", err );
-	
+			static_cast<TInt>(iOffsetIntoClientsMemory));	
+	LOGTEXT2(_L8("\tIPCRead = %d"), err);
 	iBuf.SetLength(ptr.Length());
-	if (err != 0)
-		{
-		OstTrace1( TRACE_FATAL, CACMWRITER_READDATAFROMCLIENT_DUP1, 
-										"CAcmWriter::ReadDataFromClient;EPanicInternalError=%d", 
-										(TInt)EPanicInternalError );
-		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
-		}
+	__ASSERT_DEBUG(!err, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
+	
 	static_cast<void>(err);
+
 	// Increase our pointer (into the client's space) of already-read data.
 	iOffsetIntoClientsMemory += iBuf.Length();
-	OstTraceFunctionExit0( CACMWRITER_READDATAFROMCLIENT_EXIT );
 	}
 
 
@@ -259,38 +234,26 @@
  * @param aLength Length to write.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_CHECKNEWREQUEST_ENTRY );
-	
-	if (aLength > static_cast<TUint>(KMaxTInt))
-		{
-		OstTrace1( TRACE_FATAL, CACMWRITER_CHECKNEWREQUEST, 
-										"CAcmWriter::CheckNewRequest;aLength > static_cast<TUint>(KMaxTInt), EPanicInternalError=%d", 
-										(TInt)EPanicInternalError );
-		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
-		}
+	LOG_FUNC
+
+	__ASSERT_DEBUG(aLength <= static_cast<TUint>(KMaxTInt), 
+		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
+
 	// Check we have no outstanding request already.
 	if ( iCurrentRequest.iClientPtr )
 		{
-		OstTrace1( TRACE_FATAL, CACMWRITER_CHECKNEWREQUEST_DUP1, 
-										"CAcmWriter::CheckNewRequest;iCurrentRequest.iClientPtr != NULL, EPanicInternalError=%d", 
-										(TInt)EPanicInternalError );
-		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
+		_USB_PANIC(KAcmPanicCat, EPanicInternalError);
 		}
 	// Sanity check on what C32 gave us.
-	if (aClientBuffer == NULL)
-		{
-		OstTrace1( TRACE_FATAL, CACMWRITER_CHECKNEWREQUEST_DUP2, 
-										"CAcmWriter::CheckNewRequest;aClientBuffer == NULL, EPanicInternalError=%d", 
-										(TInt)EPanicInternalError );
-		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
-		}
+	__ASSERT_DEBUG(aClientBuffer, 
+		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
+
 	// Make a note of interesting data.
 	iCurrentRequest.iLength = aLength;
 	iCurrentRequest.iClientPtr = aClientBuffer;
 	
 	iLengthToGo = aLength;
 	iOffsetIntoClientsMemory = 0;
-	OstTraceFunctionExit0( CACMWRITER_CHECKNEWREQUEST_EXIT );
 	}
 
 void CAcmWriter::CompleteRequest(TInt aError)
@@ -301,17 +264,13 @@
  * @param aError The error code to complete with.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_COMPLETEREQUEST_ENTRY );
-	OstTrace1( TRACE_NORMAL, CACMWRITER_COMPLETEREQUEST, 
-			"CAcmWriter::CompleteRequest;CAcmWriter::CompleteRequest aError=%d", (TInt)aError );
-	
+	LOGTEXT2(_L8("CAcmWriter::CompleteRequest aError=%d"), aError);
+
 	// Set our flag to say that we no longer have an outstanding request.
 	iCurrentRequest.iClientPtr = NULL;
-	OstTrace1( TRACE_NORMAL, CACMWRITER_COMPLETEREQUEST_DUP1, 
-			"CAcmWriter::CompleteRequest;\tcalling WriteCompleted with %d", aError );
-	
+
+	LOGTEXT2(_L8("\tcalling WriteCompleted with %d"), aError);
 	iPort.WriteCompleted(aError);
-	OstTraceFunctionExit0( CACMWRITER_COMPLETEREQUEST_EXIT );
 	}
 
 void CAcmWriter::IssueWrite()
@@ -320,15 +279,11 @@
  * entire load of buffered data in one go.
  */
 	{
-	OstTraceFunctionEntry0( CACMWRITER_ISSUEWRITE_ENTRY );
-	
-	OstTrace1( TRACE_NORMAL, CACMWRITER_ISSUEWRITE, "CAcmWriter::IssueWrite;\tissuing Write of %d bytes", (TInt)(iBuf.Length()) );
-	if (iPort.Acm() == NULL)
-		{
-		OstTrace1( TRACE_FATAL, CACMWRITER_ISSUEWRITE_DUP1, 
-					"CAcmWriter::IssueWrite;EPanicInternalError=%d", (TInt)EPanicInternalError);
-		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
-		}
+	LOG_FUNC
+
+	LOGTEXT2(_L8("\tissuing Write of %d bytes"), iBuf.Length());
+	__ASSERT_DEBUG(iPort.Acm(), 
+		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
 	iPort.Acm()->Write(*this, 
 		iBuf, 
 		iBuf.Length());
@@ -341,14 +296,11 @@
 	// This is not expected to occur but the test is in here just to be safe.
 	if(iBuf.Length() == 0 && iCurrentRequest.Length() != 0 && iLengthToGo != 0)
 		{
-		OstTrace1( TRACE_FATAL, CACMWRITER_ISSUEWRITE_DUP2, 
-					"CAcmWriter::IssueWrite;EPanicInternalError=%d", (TInt)EPanicInternalError);
-		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
+		_USB_PANIC(KAcmPanicCat, EPanicInternalError);
 		}
 #endif
 	// Update our counter of remaining data to write. 
 	iLengthToGo -= iBuf.Length();
-	OstTraceFunctionExit0( CACMWRITER_ISSUEWRITE_EXIT );
 	}
 
 //