usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/src/AcmWriter.cpp
changeset 29 59aa7d6e3e0f
parent 0 c9bc50fca66e
child 43 012cc2ee6408
equal deleted inserted replaced
28:f1fd07aa74c9 29:59aa7d6e3e0f
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <usb/usblogger.h>
       
    19 #include "AcmWriter.h"
    18 #include "AcmWriter.h"
    20 #include "AcmPort.h"
    19 #include "AcmPort.h"
    21 #include "AcmPanic.h"
    20 #include "AcmPanic.h"
    22 #include "AcmUtils.h"
    21 #include "AcmUtils.h"
    23 
    22 #include "OstTraceDefinitions.h"
    24 #ifdef __FLOG_ACTIVE
    23 #ifdef OST_TRACE_COMPILER_IN_USE
    25 _LIT8(KLogComponent, "ECACM");
    24 #include "AcmWriterTraces.h"
    26 #endif
    25 #endif
    27 
    26 
    28 CAcmWriter* CAcmWriter::NewL(CAcmPort& aPort, 
    27 CAcmWriter* CAcmWriter::NewL(CAcmPort& aPort, 
    29 							 TUint aBufSize)
    28 							 TUint aBufSize)
    30 /**
    29 /**
    33  * @param aPort Owning CAcmPort object.
    32  * @param aPort Owning CAcmPort object.
    34  * @param aBufSize Required buffer size.
    33  * @param aBufSize Required buffer size.
    35  * @return Ownership of a newly created CAcmWriter object
    34  * @return Ownership of a newly created CAcmWriter object
    36  */
    35  */
    37 	{
    36 	{
    38 	LOG_STATIC_FUNC_ENTRY
    37 	OstTraceFunctionEntry0( CACMWRITER_NEWL_ENTRY );
    39 
       
    40 	CAcmWriter* self = new(ELeave) CAcmWriter(aPort, aBufSize);
    38 	CAcmWriter* self = new(ELeave) CAcmWriter(aPort, aBufSize);
    41 	CleanupStack::PushL(self);
    39 	CleanupStack::PushL(self);
    42 	self->ConstructL();
    40 	self->ConstructL();
    43 	CLEANUPSTACK_POP(self);
    41 	CLEANUPSTACK_POP(self);
       
    42 	OstTraceFunctionExit0( CACMWRITER_NEWL_EXIT );
    44 	return self;
    43 	return self;
    45 	}
    44 	}
    46 
    45 
    47 CAcmWriter::~CAcmWriter()
    46 CAcmWriter::~CAcmWriter()
    48 /**
    47 /**
    49  * Destructor.
    48  * Destructor.
    50  */
    49  */
    51 	{
    50 	{
    52 	LOG_FUNC
    51 	OstTraceFunctionEntry0( CACMWRITER_CACMWRITER_DES_ENTRY );
    53 
       
    54 	WriteCancel();
    52 	WriteCancel();
    55 
       
    56 	delete iBuffer;
    53 	delete iBuffer;
       
    54 	OstTraceFunctionExit0( CACMWRITER_CACMWRITER_DES_EXIT );
    57 	}
    55 	}
    58 
    56 
    59 void CAcmWriter::Write(const TAny* aClientBuffer, TUint aLength)
    57 void CAcmWriter::Write(const TAny* aClientBuffer, TUint aLength)
    60 /**
    58 /**
    61  * Queue a write.
    59  * Queue a write.
    62  *
    60  *
    63  * @param aClientBuffer pointer to the Client's buffer
    61  * @param aClientBuffer pointer to the Client's buffer
    64  * @param aLength Number of bytes to write
    62  * @param aLength Number of bytes to write
    65  */
    63  */
    66 	{
    64 	{
    67 	LOGTEXT3(_L8("CAcmWriter::Write aClientBuffer=0x%08x, aLength=%d"), 
    65 	OstTraceFunctionEntry0( CACMWRITER_WRITE_ENTRY );
    68 		aClientBuffer, aLength);
    66 	OstTraceExt2( TRACE_NORMAL, CACMWRITER_WRITE, "CAcmWriter::Write;aClientBuffer=%p;aLength=%d", aClientBuffer, (TInt)aLength );
    69 
    67 
    70 	// Check we're open to requests and make a note of interesting data.
    68 	// Check we're open to requests and make a note of interesting data.
    71 	CheckNewRequest(aClientBuffer, aLength);
    69 	CheckNewRequest(aClientBuffer, aLength);
    72 
    70 
    73 	// If the write size greater than the current buffer size then the
    71 	// If the write size greater than the current buffer size then the
    76 	
    74 	
    77 	// Get as much data as we can from the client into our buffer
    75 	// Get as much data as we can from the client into our buffer
    78 	ReadDataFromClient();
    76 	ReadDataFromClient();
    79 	// ...and write as much as we've got to the LDD
    77 	// ...and write as much as we've got to the LDD
    80 	IssueWrite();
    78 	IssueWrite();
       
    79 	OstTraceFunctionExit0( CACMWRITER_WRITE_EXIT );
    81 	}
    80 	}
    82 
    81 
    83 void CAcmWriter::WriteCancel()
    82 void CAcmWriter::WriteCancel()
    84 /**
    83 /**
    85  * Cancel a write.
    84  * Cancel a write.
    86  */
    85  */
    87 	{
    86 	{
    88 	LOG_FUNC
    87 	OstTraceFunctionEntry0( CACMWRITER_WRITECANCEL_ENTRY );
    89 
       
    90 	// Cancel any outstanding request on the LDD.
    88 	// Cancel any outstanding request on the LDD.
    91 	if ( iPort.Acm() )
    89 	if ( iPort.Acm() )
    92 		{
    90 		{
    93 		LOGTEXT(_L8("\tiPort.Acm() exists- calling WriteCancel on it"));
    91 		OstTrace0( TRACE_NORMAL, CACMWRITER_WRITECANCEL, "CAcmWriter::WriteCancel;\tiPort.Acm() exists- calling WriteCancel on it" );
    94 		iPort.Acm()->WriteCancel();
    92 		iPort.Acm()->WriteCancel();
    95 		}
    93 		}
    96 
    94 
    97 	// Reset our flag to say there's no current outstanding request. What's 
    95 	// Reset our flag to say there's no current outstanding request. What's 
    98 	// already in our buffer can stay there.
    96 	// already in our buffer can stay there.
    99 	iCurrentRequest.iClientPtr = NULL;
    97 	iCurrentRequest.iClientPtr = NULL;
       
    98 	OstTraceFunctionExit0( CACMWRITER_WRITECANCEL_EXIT );
   100 	}
    99 	}
   101 
   100 
   102 void CAcmWriter::ResetBuffer()
   101 void CAcmWriter::ResetBuffer()
   103 /**
   102 /**
   104  * Called by the port to clear the buffer.
   103  * Called by the port to clear the buffer.
   105  */
   104  */
   106 	{
   105 	{
   107 	LOG_FUNC
   106 	OstTraceFunctionEntry0( CACMWRITER_RESETBUFFER_ENTRY );
   108 
       
   109 	// A request is outstanding- C32 should protect against this.
   107 	// A request is outstanding- C32 should protect against this.
   110 	__ASSERT_DEBUG(!iCurrentRequest.iClientPtr, 
   108 
   111 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   109 	if (iCurrentRequest.iClientPtr != NULL)
   112 
   110 		{
       
   111 		OstTrace1( TRACE_FATAL, CACMWRITER_RESETBUFFER, 
       
   112 										"CAcmWriter::ResetBuffer;EPanicInternalError=%d", 
       
   113 										(TInt)EPanicInternalError );
       
   114 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   115 		}
   113 	// Don't have anything to do. There are no pointers to reset. This 
   116 	// Don't have anything to do. There are no pointers to reset. This 
   114 	// function may in the future (if we support KConfigWriteBufferedComplete) 
   117 	// function may in the future (if we support KConfigWriteBufferedComplete) 
   115 	// do work, so leave the above assertion in.
   118 	// do work, so leave the above assertion in.
       
   119 	OstTraceFunctionExit0( CACMWRITER_RESETBUFFER_EXIT );
   116 	}
   120 	}
   117 
   121 
   118 TInt CAcmWriter::SetBufSize(TUint aSize)
   122 TInt CAcmWriter::SetBufSize(TUint aSize)
   119 /**
   123 /**
   120  * Called by the port to set the buffer size. Also used as a utility by us to 
   124  * Called by the port to set the buffer size. Also used as a utility by us to 
   121  * create the buffer at instantiation. 
   125  * create the buffer at instantiation. 
   122  *
   126  *
   123  * @param aSize The required size of the buffer.
   127  * @param aSize The required size of the buffer.
   124  */
   128  */
   125 	{
   129 	{
   126 	LOG_FUNC
   130 	OstTraceFunctionEntry0( CACMWRITER_SETBUFSIZE_ENTRY );
   127 	LOGTEXT2(_L8("\taSize=%d"), aSize);
   131 	OstTrace1( TRACE_NORMAL, CACMWRITER_SETBUFSIZE, "CAcmWriter::SetBufSize;aSize=%d", (TInt)aSize );
   128 
   132 
   129 	if ( iCurrentRequest.iClientPtr )
   133 	if ( iCurrentRequest.iClientPtr )
   130 		{
   134 		{
   131 		// A request is outstanding. C32 does not protect us against this.
   135 		// A request is outstanding. C32 does not protect us against this.
   132 		LOGTEXT(_L8("\t***a request is outstanding- returning KErrInUse"));
   136 		OstTrace0( TRACE_NORMAL, CACMWRITER_SETBUFSIZE_DUP1, 
       
   137 				"CAcmWriter::SetBufSize;\t***a request is outstanding- returning KErrInUse" );
       
   138 		OstTraceFunctionExit0( CACMWRITER_SETBUFSIZE_EXIT );
   133 		return KErrInUse;
   139 		return KErrInUse;
   134 		}
   140 		}
   135 
   141 
   136 	// Create the new buffer.
   142 	// Create the new buffer.
   137 	HBufC8* newBuf = HBufC8::New(static_cast<TInt>(aSize));
   143 	HBufC8* newBuf = HBufC8::New(static_cast<TInt>(aSize));
   138 	if ( !newBuf )
   144 	if ( !newBuf )
   139 		{
   145 		{
   140 		LOGTEXT(_L8("\tfailed to create new buffer- returning KErrNoMemory"));
   146 		OstTrace0( TRACE_NORMAL, CACMWRITER_SETBUFSIZE_DUP2, 
       
   147 				"CAcmWriter::SetBufSize;\tfailed to create new buffer- returning KErrNoMemory" );
       
   148 		OstTraceFunctionExit0( CACMWRITER_SETBUFSIZE_EXIT_DUP1 );
   141 		return KErrNoMemory;
   149 		return KErrNoMemory;
   142 		}
   150 		}
   143 	delete iBuffer;
   151 	delete iBuffer;
   144 	iBuffer = newBuf;
   152 	iBuffer = newBuf;
   145 	iBuf.Set(iBuffer->Des());
   153 	iBuf.Set(iBuffer->Des());
   146 	iBufSize = aSize;
   154 	iBufSize = aSize;
   147 
   155 
       
   156 	OstTraceFunctionExit0( CACMWRITER_SETBUFSIZE_EXIT_DUP2 );
   148 	return KErrNone;
   157 	return KErrNone;
   149 	}
   158 	}
   150 
   159 
   151 CAcmWriter::CAcmWriter(CAcmPort& aPort, 
   160 CAcmWriter::CAcmWriter(CAcmPort& aPort, 
   152 					   TUint aBufSize)
   161 					   TUint aBufSize)
   158  */
   167  */
   159  :	iBufSize(aBufSize),
   168  :	iBufSize(aBufSize),
   160 	iBuf(NULL,0,0),
   169 	iBuf(NULL,0,0),
   161 	iPort(aPort)
   170 	iPort(aPort)
   162 	{
   171 	{
       
   172 	OstTraceFunctionEntry0( CACMWRITER_CACMWRITER_CONS_ENTRY );
       
   173 	OstTraceFunctionExit0( CACMWRITER_CACMWRITER_CONS_EXIT );
   163 	}
   174 	}
   164 
   175 
   165 void CAcmWriter::ConstructL()
   176 void CAcmWriter::ConstructL()
   166 /**
   177 /**
   167  * 2nd-phase constructor. 
   178  * 2nd-phase constructor. 
   168  */
   179  */
   169 	{
   180 	{
       
   181 	OstTraceFunctionEntry0( CACMWRITER_CONSTRUCTL_ENTRY );
   170 	// Create the required buffer.
   182 	// Create the required buffer.
   171 	LOGTEXT(_L8("\tabout to create iBuffer"));
   183 	OstTrace0( TRACE_NORMAL, CACMWRITER_CONSTRUCTL, "CAcmWriter::ConstructL;\tabout to create iBuffer" );
   172 	LEAVEIFERRORL(SetBufSize(iBufSize));
   184 	TInt err = SetBufSize(iBufSize);
       
   185 	if (err < 0)
       
   186 		{
       
   187 		OstTrace1( TRACE_ERROR, CACMWRITER_CONSTRUCTL_DUP1, "CAcmWriter::ConstructL;err=%d", err );
       
   188 		User::Leave(err);
       
   189 		}
       
   190 	OstTraceFunctionExit0( CACMWRITER_CONSTRUCTL_EXIT );
   173 	}
   191 	}
   174 
   192 
   175 void CAcmWriter::WriteCompleted(TInt aError)
   193 void CAcmWriter::WriteCompleted(TInt aError)
   176 /**
   194 /**
   177  * This function is called when a write on the LDD has completed. 
   195  * This function is called when a write on the LDD has completed. 
   180  * left or an error occurs.
   198  * left or an error occurs.
   181  *
   199  *
   182  * @param aError Error with which the write completed.
   200  * @param aError Error with which the write completed.
   183  */
   201  */
   184 	{
   202 	{
   185 	LOG_FUNC
   203 	OstTraceFunctionEntry0( CACMWRITER_WRITECOMPLETED_ENTRY );
   186 	LOGTEXT2(_L8("\taError=%d"), aError);						   	
   204 	OstTrace1( TRACE_NORMAL, CACMWRITER_WRITECOMPLETED, "CAcmWriter::WriteCompleted;aError=%d", (TInt)aError );					   	
   187 
       
   188 	if(iLengthToGo == 0 || aError != KErrNone)
   205 	if(iLengthToGo == 0 || aError != KErrNone)
   189 		{
   206 		{
   190 		LOGTEXT2(_L8("\tcompleting request with %d"), aError);
   207 		OstTrace1( TRACE_NORMAL, CACMWRITER_WRITECOMPLETED_DUP1, 
       
   208 				"CAcmWriter::WriteCompleted;\tcompleting request with %d", aError );
   191 		CompleteRequest(aError);	
   209 		CompleteRequest(aError);	
   192 		}
   210 		}
   193 	else
   211 	else
   194 		{
   212 		{
   195 		//there is some data remaining to be read so reissue the Read & Write 
   213 		//there is some data remaining to be read so reissue the Read & Write 
   196 		//requests until there is no data left.
   214 		//requests until there is no data left.
   197 		ReadDataFromClient();
   215 		ReadDataFromClient();
   198 		IssueWrite();
   216 		IssueWrite();
   199 		}
   217 		}
       
   218 	OstTraceFunctionExit0( CACMWRITER_WRITECOMPLETED_EXIT );
   200 	}
   219 	}
   201 
   220 
   202 void CAcmWriter::ReadDataFromClient()
   221 void CAcmWriter::ReadDataFromClient()
   203 /**
   222 /**
   204  * Read data from the client space into the internal buffer, prior to writing.
   223  * Read data from the client space into the internal buffer, prior to writing.
   205  */
   224  */
   206 	{
   225 	{
   207 	LOG_FUNC
   226 	OstTraceFunctionEntry0( CACMWRITER_READDATAFROMCLIENT_ENTRY );
   208 	TPtr8 ptr((TUint8*)iBuf.Ptr(),
   227 	TPtr8 ptr((TUint8*)iBuf.Ptr(),
   209 			  0,
   228 			  0,
   210 			  Min(iBuf.MaxLength(), iLengthToGo));
   229 			  Min(iBuf.MaxLength(), iLengthToGo));
   211 
   230 
   212 	TInt err = iPort.IPCRead(iCurrentRequest.iClientPtr,
   231 	TInt err = iPort.IPCRead(iCurrentRequest.iClientPtr,
   213 			ptr,
   232 			ptr,
   214 			static_cast<TInt>(iOffsetIntoClientsMemory));	
   233 			static_cast<TInt>(iOffsetIntoClientsMemory));
   215 	LOGTEXT2(_L8("\tIPCRead = %d"), err);
   234 	OstTrace1( TRACE_NORMAL, CACMWRITER_READDATAFROMCLIENT, "CAcmWriter::ReadDataFromClient;\tIPCRead = %d", err );
       
   235 	
   216 	iBuf.SetLength(ptr.Length());
   236 	iBuf.SetLength(ptr.Length());
   217 	__ASSERT_DEBUG(!err, _USB_PANIC(KAcmPanicCat, EPanicInternalError));
   237 	if (err != 0)
   218 	
   238 		{
       
   239 		OstTrace1( TRACE_FATAL, CACMWRITER_READDATAFROMCLIENT_DUP1, 
       
   240 										"CAcmWriter::ReadDataFromClient;EPanicInternalError=%d", 
       
   241 										(TInt)EPanicInternalError );
       
   242 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   243 		}
   219 	static_cast<void>(err);
   244 	static_cast<void>(err);
   220 
       
   221 	// Increase our pointer (into the client's space) of already-read data.
   245 	// Increase our pointer (into the client's space) of already-read data.
   222 	iOffsetIntoClientsMemory += iBuf.Length();
   246 	iOffsetIntoClientsMemory += iBuf.Length();
       
   247 	OstTraceFunctionExit0( CACMWRITER_READDATAFROMCLIENT_EXIT );
   223 	}
   248 	}
   224 
   249 
   225 
   250 
   226 
   251 
   227 void CAcmWriter::CheckNewRequest(const TAny* aClientBuffer, TUint aLength)
   252 void CAcmWriter::CheckNewRequest(const TAny* aClientBuffer, TUint aLength)
   232  *
   257  *
   233  * @param aClientBuffer Pointer to the client's memory space.
   258  * @param aClientBuffer Pointer to the client's memory space.
   234  * @param aLength Length to write.
   259  * @param aLength Length to write.
   235  */
   260  */
   236 	{
   261 	{
   237 	LOG_FUNC
   262 	OstTraceFunctionEntry0( CACMWRITER_CHECKNEWREQUEST_ENTRY );
   238 
   263 	
   239 	__ASSERT_DEBUG(aLength <= static_cast<TUint>(KMaxTInt), 
   264 	if (aLength > static_cast<TUint>(KMaxTInt))
   240 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   265 		{
   241 
   266 		OstTrace1( TRACE_FATAL, CACMWRITER_CHECKNEWREQUEST, 
       
   267 										"CAcmWriter::CheckNewRequest;aLength > static_cast<TUint>(KMaxTInt), EPanicInternalError=%d", 
       
   268 										(TInt)EPanicInternalError );
       
   269 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   270 		}
   242 	// Check we have no outstanding request already.
   271 	// Check we have no outstanding request already.
   243 	if ( iCurrentRequest.iClientPtr )
   272 	if ( iCurrentRequest.iClientPtr )
   244 		{
   273 		{
   245 		_USB_PANIC(KAcmPanicCat, EPanicInternalError);
   274 		OstTrace1( TRACE_FATAL, CACMWRITER_CHECKNEWREQUEST_DUP1, 
       
   275 										"CAcmWriter::CheckNewRequest;iCurrentRequest.iClientPtr != NULL, EPanicInternalError=%d", 
       
   276 										(TInt)EPanicInternalError );
       
   277 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
   246 		}
   278 		}
   247 	// Sanity check on what C32 gave us.
   279 	// Sanity check on what C32 gave us.
   248 	__ASSERT_DEBUG(aClientBuffer, 
   280 	if (aClientBuffer == NULL)
   249 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   281 		{
   250 
   282 		OstTrace1( TRACE_FATAL, CACMWRITER_CHECKNEWREQUEST_DUP2, 
       
   283 										"CAcmWriter::CheckNewRequest;aClientBuffer == NULL, EPanicInternalError=%d", 
       
   284 										(TInt)EPanicInternalError );
       
   285 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   286 		}
   251 	// Make a note of interesting data.
   287 	// Make a note of interesting data.
   252 	iCurrentRequest.iLength = aLength;
   288 	iCurrentRequest.iLength = aLength;
   253 	iCurrentRequest.iClientPtr = aClientBuffer;
   289 	iCurrentRequest.iClientPtr = aClientBuffer;
   254 	
   290 	
   255 	iLengthToGo = aLength;
   291 	iLengthToGo = aLength;
   256 	iOffsetIntoClientsMemory = 0;
   292 	iOffsetIntoClientsMemory = 0;
       
   293 	OstTraceFunctionExit0( CACMWRITER_CHECKNEWREQUEST_EXIT );
   257 	}
   294 	}
   258 
   295 
   259 void CAcmWriter::CompleteRequest(TInt aError)
   296 void CAcmWriter::CompleteRequest(TInt aError)
   260 /**
   297 /**
   261  * Utility to reset our 'outstanding request' flag and complete the client's 
   298  * Utility to reset our 'outstanding request' flag and complete the client's 
   262  * request back to them. 
   299  * request back to them. 
   263  * 
   300  * 
   264  * @param aError The error code to complete with.
   301  * @param aError The error code to complete with.
   265  */
   302  */
   266 	{
   303 	{
   267 	LOGTEXT2(_L8("CAcmWriter::CompleteRequest aError=%d"), aError);
   304 	OstTraceFunctionEntry0( CACMWRITER_COMPLETEREQUEST_ENTRY );
   268 
   305 	OstTrace1( TRACE_NORMAL, CACMWRITER_COMPLETEREQUEST, 
       
   306 			"CAcmWriter::CompleteRequest;CAcmWriter::CompleteRequest aError=%d", (TInt)aError );
       
   307 	
   269 	// Set our flag to say that we no longer have an outstanding request.
   308 	// Set our flag to say that we no longer have an outstanding request.
   270 	iCurrentRequest.iClientPtr = NULL;
   309 	iCurrentRequest.iClientPtr = NULL;
   271 
   310 	OstTrace1( TRACE_NORMAL, CACMWRITER_COMPLETEREQUEST_DUP1, 
   272 	LOGTEXT2(_L8("\tcalling WriteCompleted with %d"), aError);
   311 			"CAcmWriter::CompleteRequest;\tcalling WriteCompleted with %d", aError );
       
   312 	
   273 	iPort.WriteCompleted(aError);
   313 	iPort.WriteCompleted(aError);
       
   314 	OstTraceFunctionExit0( CACMWRITER_COMPLETEREQUEST_EXIT );
   274 	}
   315 	}
   275 
   316 
   276 void CAcmWriter::IssueWrite()
   317 void CAcmWriter::IssueWrite()
   277 /**
   318 /**
   278  * Writes a batch of data from our buffer to the LDD. Currently writes the 
   319  * Writes a batch of data from our buffer to the LDD. Currently writes the 
   279  * entire load of buffered data in one go.
   320  * entire load of buffered data in one go.
   280  */
   321  */
   281 	{
   322 	{
   282 	LOG_FUNC
   323 	OstTraceFunctionEntry0( CACMWRITER_ISSUEWRITE_ENTRY );
   283 
   324 	
   284 	LOGTEXT2(_L8("\tissuing Write of %d bytes"), iBuf.Length());
   325 	OstTrace1( TRACE_NORMAL, CACMWRITER_ISSUEWRITE, "CAcmWriter::IssueWrite;\tissuing Write of %d bytes", (TInt)(iBuf.Length()) );
   285 	__ASSERT_DEBUG(iPort.Acm(), 
   326 	if (iPort.Acm() == NULL)
   286 		_USB_PANIC(KAcmPanicCat, EPanicInternalError));
   327 		{
       
   328 		OstTrace1( TRACE_FATAL, CACMWRITER_ISSUEWRITE_DUP1, 
       
   329 					"CAcmWriter::IssueWrite;EPanicInternalError=%d", (TInt)EPanicInternalError);
       
   330 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
       
   331 		}
   287 	iPort.Acm()->Write(*this, 
   332 	iPort.Acm()->Write(*this, 
   288 		iBuf, 
   333 		iBuf, 
   289 		iBuf.Length());
   334 		iBuf.Length());
   290 	
   335 	
   291 #ifdef DEBUG
   336 #ifdef DEBUG
   294 	// that the LengthToGo is also 0, if it is not then we may end up looping through this
   339 	// that the LengthToGo is also 0, if it is not then we may end up looping through this
   295 	// code until a driver write error occurs which may never happen. 
   340 	// code until a driver write error occurs which may never happen. 
   296 	// This is not expected to occur but the test is in here just to be safe.
   341 	// This is not expected to occur but the test is in here just to be safe.
   297 	if(iBuf.Length() == 0 && iCurrentRequest.Length() != 0 && iLengthToGo != 0)
   342 	if(iBuf.Length() == 0 && iCurrentRequest.Length() != 0 && iLengthToGo != 0)
   298 		{
   343 		{
   299 		_USB_PANIC(KAcmPanicCat, EPanicInternalError);
   344 		OstTrace1( TRACE_FATAL, CACMWRITER_ISSUEWRITE_DUP2, 
       
   345 					"CAcmWriter::IssueWrite;EPanicInternalError=%d", (TInt)EPanicInternalError);
       
   346 		__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
   300 		}
   347 		}
   301 #endif
   348 #endif
   302 	// Update our counter of remaining data to write. 
   349 	// Update our counter of remaining data to write. 
   303 	iLengthToGo -= iBuf.Length();
   350 	iLengthToGo -= iBuf.Length();
       
   351 	OstTraceFunctionExit0( CACMWRITER_ISSUEWRITE_EXIT );
   304 	}
   352 	}
   305 
   353 
   306 //
   354 //
   307 // End of file
   355 // End of file