kerneltest/e32test/usbho/t_usbdi/src/endpointwriter.cpp
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 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".
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // @file endpointwriter.cpp
    14 // @file endpointwriter.cpp
    15 // @internalComponent
    15 // @internalComponent
    16 //
    16 // 
    17 //
    17 //
    18 
    18 
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include <e32base_private.h>
    20 #include <e32base_private.h>
    21 #include <d32usbc.h>
    21 #include <d32usbc.h>
    22 #include "endpointwriter.h"
    22 #include "endpointwriter.h"
    23 #include "testdebug.h"
    23 #include "testdebug.h"
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "endpointwriterTraces.h"
       
    27 #endif
       
    28 
    24 
    29 namespace NUnitTesting_USBDI
    25 namespace NUnitTesting_USBDI
    30 	{
    26 	{
    31 const TUint KMaxTransferBuffer = 0x1000;
    27 const TUint KMaxTransferBuffer = 0x1000;
    32 
    28 
    35 :	CActive(EPriorityStandard),
    31 :	CActive(EPriorityStandard),
    36 	iClientDriver(aClientDriver),
    32 	iClientDriver(aClientDriver),
    37 	iEndpoint(aEndpoint),
    33 	iEndpoint(aEndpoint),
    38 	iBufPtr(NULL,0)
    34 	iBufPtr(NULL,0)
    39 	{
    35 	{
    40 	OstTraceFunctionEntryExt( CENDPOINTWRITER_CENDPOINTWRITER_ENTRY, this );
       
    41 	CActiveScheduler::Add(this);
    36 	CActiveScheduler::Add(this);
    42 	OstTraceFunctionExit1( CENDPOINTWRITER_CENDPOINTWRITER_EXIT, this );
    37 	}
    43 	}
    38 	
    44 
    39 					
    45 
       
    46 CEndpointWriter::~CEndpointWriter()
    40 CEndpointWriter::~CEndpointWriter()
    47 	{
    41 	{
    48 	OstTraceFunctionEntry1( CENDPOINTWRITER_CENDPOINTWRITER_ENTRY_DUP01, this );
    42 	LOG_FUNC
    49 
    43 	
    50 	Cancel();
    44 	Cancel();
    51 	if(iBuffer)
    45 	if(iBuffer)
    52 		{
    46 		{
    53 		OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_DCENDPOINTWRITER, "Freeing %d bytes", iBuffer->Size());
    47 		RDebug::Printf("Freeing %d bytes", iBuffer->Size());
    54 		}
    48 		}
    55 	delete iBuffer;
    49 	delete iBuffer;
    56 	OstTraceFunctionExit1( CENDPOINTWRITER_CENDPOINTWRITER_EXIT_DUP01, this );
       
    57 	}
    50 	}
    58 
    51 
    59 
    52 
    60 void CEndpointWriter::DoCancel()
    53 void CEndpointWriter::DoCancel()
    61 	{
    54 	{
    62 	OstTraceFunctionEntry1( CENDPOINTWRITER_DOCANCEL_ENTRY, this );
    55 	LOG_FUNC
    63 
    56 	
    64 	// Cancel the write to the endpoint
    57 	// Cancel the write to the endpoint
    65 
    58 	
    66 	iClientDriver.WriteCancel(iEndpoint);
    59 	iClientDriver.WriteCancel(iEndpoint);
    67 	OstTraceFunctionExit1( CENDPOINTWRITER_DOCANCEL_EXIT, this );
    60 	}
    68 	}
    61 	
    69 
    62 	
    70 
       
    71 TUint CEndpointWriter::NumBytesWrittenSoFar()
    63 TUint CEndpointWriter::NumBytesWrittenSoFar()
    72 	{
    64 	{
    73 	OstTraceFunctionEntry1( CENDPOINTWRITER_NUMBYTESWRITTENSOFAR_ENTRY, this );
       
    74 	OstTraceFunctionExitExt( CENDPOINTWRITER_NUMBYTESWRITTENSOFAR_EXIT, this, iNumBytesWritten );
       
    75 	return iNumBytesWritten;
    65 	return iNumBytesWritten;
    76 	}
    66 	}
    77 
    67 
    78 void CEndpointWriter::RunL()
    68 void CEndpointWriter::RunL()
    79 	{
    69 	{
    80 	OstTraceFunctionEntry1( CENDPOINTWRITER_RUNL_ENTRY, this );
    70 	LOG_FUNC
    81 
    71 	
    82 	TInt completionCode(iStatus.Int());
    72 	TInt completionCode(iStatus.Int());
    83 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_RUNL, "Write completed, err=%d",completionCode);
    73 	RDebug::Printf("Write completed, err=%d",completionCode);
    84 
    74 	
    85 	iNumBytesWritten += iNumBytesOnCurrentWrite; // all zero if not a repeated write
    75 	iNumBytesWritten += iNumBytesOnCurrentWrite; // all zero if not a repeated write
    86 	if(iNumBytesWritten < iTotalNumBytes)
    76 	if(iNumBytesWritten < iTotalNumBytes)
    87 		//This conditional will not be entered for non-repeat cases because then
    77 		//This conditional will not be entered for non-repeat cases because then 
    88 		//'iNumBytesWritten' and 'iTotalNumBytes' will both be zero.
    78 		//'iNumBytesWritten' and 'iTotalNumBytes' will both be zero.
    89 		{
    79 		{
    90 		TUint totalNumBytesStillToWrite = iTotalNumBytes - iNumBytesWritten;
    80 		TUint totalNumBytesStillToWrite = iTotalNumBytes - iNumBytesWritten;
    91 
    81 
    92 		//NB iNumBytesOnCurrentWrite should remain at the requested 'bytes per Write' value until the last iteration
    82 		//NB iNumBytesOnCurrentWrite should remain at the requested 'bytes per Write' value until the last iteration
    93 		iNumBytesOnCurrentWrite = totalNumBytesStillToWrite <= iNumBytesOnCurrentWrite ? totalNumBytesStillToWrite : iNumBytesOnCurrentWrite;
    83 		iNumBytesOnCurrentWrite = totalNumBytesStillToWrite <= iNumBytesOnCurrentWrite ? totalNumBytesStillToWrite : iNumBytesOnCurrentWrite;
    94 
    84 
    95 		//Only add a ZLP, if requested and if the last 'Write'
    85 		//Only add a ZLP, if requested and if the last 'Write'
    96 		TBool useUsb = totalNumBytesStillToWrite <= iNumBytesOnCurrentWrite ? iUseZLP : EFalse;
    86 		TBool useUsb = totalNumBytesStillToWrite <= iNumBytesOnCurrentWrite ? iUseZLP : EFalse;
    97 		TPtrC8 writeDesc = iBufPtr.Mid(iNumBytesWritten%iDataPatternLength, iNumBytesOnCurrentWrite);
    87 		TPtrC8 writeDesc = iBufPtr.Mid(iNumBytesWritten%iDataPatternLength, iNumBytesOnCurrentWrite);
    98 		OstTraceExt4(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP01, "Total Bytes To Write = %u, Bytes Still To Write = %u, Bytes Written = %d, Bytes on Current Write = %d", iTotalNumBytes, totalNumBytesStillToWrite, iNumBytesWritten, iNumBytesOnCurrentWrite);
    88 		RDebug::Printf("Total Bytes To Write = %d, Bytes Still To Write = %d, Bytes Written = %d, Bytes on Current 'Write'", iTotalNumBytes, totalNumBytesStillToWrite, iNumBytesWritten, iNumBytesOnCurrentWrite);
    99 
    89 		 
   100 		OstTrace0(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP02, "\n");
    90 		RDebug::Printf("\n");
   101 		OstTrace0(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP03, "First 256 bytes (or all) of data to write");
    91 		RDebug::Printf("First 256 bytes (or all) of data to write");
   102 		OstTraceData(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP53, "", writeDesc.Ptr(), writeDesc.Length());
    92 		RDebug::RawPrint(writeDesc);
   103 		OstTrace0(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP04, "\n");
    93 		RDebug::Printf("\n");
   104 
    94 		
   105 
    95 		
   106 		Write(writeDesc, useUsb, EFalse);
    96 		Write(writeDesc, useUsb, EFalse);
   107 		}
    97 		}
   108 	else
    98 	else
   109 		{
    99 		{
   110 		if(iBuffer!=NULL)
   100 		if(iBuffer!=NULL)
   111 			{
   101 			{
   112 			OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP05, "Freeing %d bytes", iBuffer->Size());
   102 			RDebug::Printf("Freeing %d bytes", iBuffer->Size());
   113 			}
   103 			}
   114 		else
   104 		else
   115 			{
   105 			{
   116 			OstTrace0(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP06, "iBuffer is NULL");
   106 			RDebug::Printf("iBuffer is NULL");
   117 			}
   107 			}
   118 		if(iTotalNumBytes != 0)
   108 		if(iTotalNumBytes != 0)
   119 			//if a repeated write
   109 			//if a repeated write
   120 			{
   110 			{
   121 			OstTraceExt2(TRACE_NORMAL, CENDPOINTWRITER_RUNL_DUP07, "Total Bytes = %u, Bytes Written = %u", iTotalNumBytes, iNumBytesWritten);
   111 			RDebug::Printf("Total Bytes = %d, Bytes Written = %d", iTotalNumBytes, iNumBytesWritten);
   122 			}
   112 			}
   123 		delete iBuffer;
   113 		delete iBuffer;
   124 		iBuffer = 0;
   114 		iBuffer = 0;
   125 		iNumBytesOnCurrentWrite = 0;
   115 		iNumBytesOnCurrentWrite = 0;
   126 		iNumBytesWritten = 0;
   116 		iNumBytesWritten = 0;
   127 		iTotalNumBytes = 0;
   117 		iTotalNumBytes = 0;
   128 		iDataPatternLength = 0;
   118 		iDataPatternLength = 0;
   129 		iUseZLP = EFalse;
   119 		iUseZLP = EFalse;
   130 		}
   120 		}
   131 	OstTraceFunctionExit1( CENDPOINTWRITER_RUNL_EXIT, this );
       
   132 	}
   121 	}
   133 
   122 
   134 
   123 
   135 TInt CEndpointWriter::RunError(TInt aError)
   124 TInt CEndpointWriter::RunError(TInt aError)
   136 	{
   125 	{
   137 	OstTraceFunctionEntryExt( CENDPOINTWRITER_RUNERROR_ENTRY, this );
   126 	LOG_FUNC
   138 
   127 	
   139 	aError = KErrNone;
   128 	aError = KErrNone;
   140 	OstTraceFunctionExitExt( CENDPOINTWRITER_RUNERROR_EXIT, this, aError );
       
   141 	return aError;
   129 	return aError;
   142 	}
   130 	}
   143 
   131 
   144 
   132 
   145 void CEndpointWriter::Write(const TDesC8& aData, TBool aUseZLP, TBool aCreateBuffer)
   133 void CEndpointWriter::Write(const TDesC8& aData, TBool aUseZLP, TBool aCreateBuffer)
   146 	{
   134 	{
   147 	OstTraceFunctionEntryExt( CENDPOINTWRITER_WRITE_ENTRY, this );
   135 	LOG_FUNC
   148 
   136 	
   149   	if(aCreateBuffer == EFalse)
   137   	if(aCreateBuffer == EFalse)
   150   		{
   138   		{
   151   		OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITE, "Use ZLP %d", aUseZLP?1:0);
   139   		RDebug::Printf("Use ZLP %d", aUseZLP?1:0);
   152   		iClientDriver.Write(iStatus,iEndpoint,aData,aData.Length(),aUseZLP);
   140   		iClientDriver.Write(iStatus,iEndpoint,aData,aData.Length(),aUseZLP);
   153   		SetActive();
   141   		SetActive();
   154  		OstTraceFunctionExit1( CENDPOINTWRITER_WRITE_EXIT, this );
       
   155  		return;
   142  		return;
   156   		}
   143   		}
   157 
   144 
   158 
   145 	
   159 	//Copy aData to this object's buffer
   146 	//Copy aData to this object's buffer
   160 	//'aData' will go out of scope before the USB driver 'Write' completes
   147 	//'aData' will go out of scope before the USB driver 'Write' completes	
   161 	delete iBuffer;
   148 	delete iBuffer;
   162   	iBuffer = NULL;
   149   	iBuffer = NULL;
   163 	iBuffer = HBufC8::NewL(aData.Length());
   150 	iBuffer = HBufC8::NewL(aData.Length());
   164 	iBufPtr.Set(iBuffer->Des());
   151 	iBufPtr.Set(iBuffer->Des());
   165 	iBufPtr.Copy(aData);
   152 	iBufPtr.Copy(aData);
   166 
   153 
   167 	// Write the data to the host through the endpoint (host opened pipe)
   154 	// Write the data to the host through the endpoint (host opened pipe)
   168 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITE_DUP01, "Write Length = %d", iBufPtr.Length());
   155 	RDebug::Printf("Write Length = %d", iBufPtr.Length());
   169 	OstTraceData(TRACE_NORMAL, CENDPOINTWRITER_WRITE_DUP51, "", iBufPtr.Ptr(), iBufPtr.Length());
   156 	RDebug::RawPrint(iBufPtr);
   170 	OstTrace0(TRACE_NORMAL, CENDPOINTWRITER_WRITE_DUP02, "\n");
   157 	RDebug::Printf("\n");
   171 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITE_DUP03, "Use ZLP %d", aUseZLP?1:0);
   158 	RDebug::Printf("Use ZLP %d", aUseZLP?1:0);
   172 	iClientDriver.Write(iStatus,iEndpoint,iBufPtr,iBufPtr.Length(),aUseZLP);
   159 	iClientDriver.Write(iStatus,iEndpoint,iBufPtr,iBufPtr.Length(),aUseZLP);
   173 	SetActive();
   160 	SetActive();
   174 	OstTraceFunctionExit1( CENDPOINTWRITER_WRITE_EXIT_DUP01, this );
       
   175 	}
   161 	}
   176 
   162 
   177 TInt CEndpointWriter::WriteSynchronous(const TDesC8& aData, TBool aUseZLP)
   163 TInt CEndpointWriter::WriteSynchronous(const TDesC8& aData, TBool aUseZLP)
   178 	{
   164 	{
   179 	OstTraceFunctionEntryExt( CENDPOINTWRITER_WRITESYNCHRONOUS_ENTRY, this );
   165 	LOG_FUNC
   180 
   166 	
   181 	TRequestStatus status = KRequestPending;
   167 	TRequestStatus status = KRequestPending;
   182 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITESYNCHRONOUS, "Write Length = %d", aData.Length());
   168 	RDebug::Printf("Write Length = %d", aData.Length());
   183 	OstTraceData(TRACE_NORMAL, CENDPOINTWRITER_WRITESYNCHRONOUS_DUP50, "", aData.Ptr(), aData.Length());
   169 	RDebug::RawPrint(aData);
   184 	OstTrace0(TRACE_NORMAL, CENDPOINTWRITER_WRITESYNCHRONOUS_DUP01, "\n");
   170 	RDebug::Printf("\n");
   185 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITESYNCHRONOUS_DUP02, "Use ZLP %d", aUseZLP?1:0);
   171 	RDebug::Printf("Use ZLP %d", aUseZLP?1:0);
   186 	iClientDriver.Write(status,iEndpoint,aData,aData.Length(),aUseZLP);
   172 	iClientDriver.Write(status,iEndpoint,aData,aData.Length(),aUseZLP);
   187 	User::WaitForRequest(status);
   173 	User::WaitForRequest(status);
   188 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITESYNCHRONOUS_DUP03, "Write has completed with error %d", status.Int());
   174 	RDebug::Printf("Write has completed with error %d", status.Int());
   189 	return status.Int();
   175 	return status.Int();
   190 	}
   176 	}
   191 
   177 
   192 void CEndpointWriter::WriteSynchronousUsingPatternL(const TDesC8& aData, const TUint aNumBytes, const TBool aUseZLP)
   178 void CEndpointWriter::WriteSynchronousUsingPatternL(const TDesC8& aData, const TUint aNumBytes, const TBool aUseZLP)
   193 	{
   179 	{
   194     OstTraceFunctionEntryExt( CENDPOINTWRITER_WRITESYNCHRONOUSUSINGPATTERNL_ENTRY, this );
   180 	LOG_FUNC
   195 
   181 
   196 	TBool useZLP = EFalse; //only want this if you are making the last call to client Write (=WriteSynchronous)
   182 	TBool useZLP = EFalse; //only want this if you are making the last call to client Write (=WriteSynchronous)
   197 	if(aNumBytes <= aData.Length())
   183 	if(aNumBytes <= aData.Length())
   198 	//Don't need to allocate a buffer and copy to it - write will be done synchronously
   184 	//Don't need to allocate a buffer and copy to it - write will be done synchronously
   199 		{
   185 		{
   258 			WriteSynchronous(iBufPtr.Left(endBytes), aUseZLP); //if last 'Write'
   244 			WriteSynchronous(iBufPtr.Left(endBytes), aUseZLP); //if last 'Write'
   259 	  		}
   245 	  		}
   260 		}
   246 		}
   261 	delete iBuffer;
   247 	delete iBuffer;
   262 	iBuffer = 0;
   248 	iBuffer = 0;
   263 	OstTraceFunctionExit1( CENDPOINTWRITER_WRITESYNCHRONOUSUSINGPATTERNL_EXIT, this );
       
   264 	}
   249 	}
   265 
   250 
   266 void CEndpointWriter::WriteSynchronousUsingPatternL(const TDesC8& aData, const TUint aNumBytes)
   251 void CEndpointWriter::WriteSynchronousUsingPatternL(const TDesC8& aData, const TUint aNumBytes)
   267 	{
   252 	{
   268 	OstTraceFunctionEntryExt( CENDPOINTWRITER_WRITESYNCHRONOUSUSINGPATTERNL_ENTRY_DUP01, this );
       
   269 	WriteSynchronousUsingPatternL(aData, aNumBytes, ETrue);
   253 	WriteSynchronousUsingPatternL(aData, aNumBytes, ETrue);
   270 	OstTraceFunctionExit1( CENDPOINTWRITER_WRITESYNCHRONOUSUSINGPATTERNL_EXIT_DUP01, this );
       
   271 	}
   254 	}
   272 
   255 
   273 void CEndpointWriter::WriteSynchronousUsingPatternAndHaltL(const TDesC8& aData, const TUint aNumBytes)
   256 void CEndpointWriter::WriteSynchronousUsingPatternAndHaltL(const TDesC8& aData, const TUint aNumBytes)
   274 	{
   257 	{
   275 	OstTraceFunctionEntryExt( CENDPOINTWRITER_WRITESYNCHRONOUSUSINGPATTERNANDHALTL_ENTRY, this );
   258 	LOG_FUNC
   276 	WriteSynchronousUsingPatternL(aData, aNumBytes, EFalse);
   259 	WriteSynchronousUsingPatternL(aData, aNumBytes, EFalse);
   277 	iClientDriver.HaltEndpoint(iEndpoint);
   260 	iClientDriver.HaltEndpoint(iEndpoint);
   278 	OstTraceFunctionExit1( CENDPOINTWRITER_WRITESYNCHRONOUSUSINGPATTERNANDHALTL_EXIT, this );
       
   279 	}
   261 	}
   280 
   262 
   281 void CEndpointWriter::WriteUsingPatternL(const TDesC8& aData, const TUint aNumBytes, const TBool aUseZLP)
   263 void CEndpointWriter::WriteUsingPatternL(const TDesC8& aData, const TUint aNumBytes, const TBool aUseZLP)
   282 	{
   264 	{
   283     OstTraceFunctionEntryExt( CENDPOINTWRITER_WRITEUSINGPATTERNL_ENTRY, this );
   265 	LOG_FUNC
   284 
   266 
   285 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITEUSINGPATTERNL, "Allocating %d bytes", aNumBytes);
   267 	RDebug::Printf("Allocating %d bytes", aNumBytes);
   286   	delete iBuffer;
   268   	delete iBuffer;
   287   	iBuffer = NULL;
   269   	iBuffer = NULL;
   288 	iBuffer = HBufC8::NewL(aNumBytes);
   270 	iBuffer = HBufC8::NewL(aNumBytes);
   289 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITEUSINGPATTERNL_DUP01, "Allocated %d bytes", aNumBytes);
   271 	RDebug::Printf("Allocated %d bytes", aNumBytes);
   290 	iBufPtr.Set(iBuffer->Des());
   272 	iBufPtr.Set(iBuffer->Des());
   291 	iBufPtr.Zero();
   273 	iBufPtr.Zero();
   292 	TInt repeats = aNumBytes/aData.Length();
   274 	TInt repeats = aNumBytes/aData.Length();
   293 	for(TUint i =0; i<repeats; i++)
   275 	for(TUint i =0; i<repeats; i++)
   294 		{
   276 		{
   297 	if(TInt extraBytes = aNumBytes%aData.Length())
   279 	if(TInt extraBytes = aNumBytes%aData.Length())
   298 		{
   280 		{
   299 		iBufPtr.Append(aData.Left(extraBytes));
   281 		iBufPtr.Append(aData.Left(extraBytes));
   300 		}
   282 		}
   301 	Write(*iBuffer, aUseZLP, EFalse);
   283 	Write(*iBuffer, aUseZLP, EFalse);
   302 	OstTraceFunctionExit1( CENDPOINTWRITER_WRITEUSINGPATTERNL_EXIT, this );
       
   303 	}
   284 	}
   304 
   285 
   305 void CEndpointWriter::WriteInPartsUsingPatternL(const TDesC8& aData, const TUint aNumBytesPerWrite, TUint aTotalNumBytes, const TBool aUseZLP)
   286 void CEndpointWriter::WriteInPartsUsingPatternL(const TDesC8& aData, const TUint aNumBytesPerWrite, TUint aTotalNumBytes, const TBool aUseZLP)
   306 	{
   287 	{
   307     OstTraceFunctionEntryExt( CENDPOINTWRITER_WRITEINPARTSUSINGPATTERNL_ENTRY, this );
   288 	LOG_FUNC
   308 
   289 
   309 	iUseZLP = aUseZLP;
   290 	iUseZLP = aUseZLP;
   310 	TInt repeats = aNumBytesPerWrite/aData.Length() + 1;
   291 	TInt repeats = aNumBytesPerWrite/aData.Length() + 1;
   311 	repeats *= 2;
   292 	repeats *= 2;
   312 	CreateBigBuffer(aData, repeats);
   293 	CreateBigBuffer(aData, repeats);
   313 	iDataPatternLength = aData.Length();
   294 	iDataPatternLength = aData.Length();
   314 	iTotalNumBytes = aTotalNumBytes;
   295 	iTotalNumBytes = aTotalNumBytes;
   315 	iNumBytesOnCurrentWrite = aNumBytesPerWrite;
   296 	iNumBytesOnCurrentWrite = aNumBytesPerWrite;
   316 	iNumBytesWritten = 0;
   297 	iNumBytesWritten = 0;
   317 	Write(iBufPtr.Mid(iNumBytesWritten%iDataPatternLength, iNumBytesOnCurrentWrite), EFalse, EFalse); //this is not the first 'Write' so do not use a ZLP
   298 	Write(iBufPtr.Mid(iNumBytesWritten%iDataPatternLength, iNumBytesOnCurrentWrite), EFalse, EFalse); //this is not the first 'Write' so do not use a ZLP
   318 	OstTrace1(TRACE_NORMAL, CENDPOINTWRITER_WRITEINPARTSUSINGPATTERNL, "Write %d bytes",iNumBytesOnCurrentWrite);
   299 	RDebug::Printf("Write %d bytes",iNumBytesOnCurrentWrite);
   319 	OstTraceExt2(TRACE_NORMAL, CENDPOINTWRITER_WRITEINPARTSUSINGPATTERNL_DUP01, "Total Bytes = %u, Data Pattern Length = %u", iTotalNumBytes, iDataPatternLength);
   300 	RDebug::Printf("Total Bytes = %d, Data Pattern Length = %d", iTotalNumBytes, iDataPatternLength);
   320 	OstTraceFunctionExit1( CENDPOINTWRITER_WRITEINPARTSUSINGPATTERNL_EXIT, this );
       
   321 	}
   301 	}
   322 
   302 
   323 void CEndpointWriter::CreateBigBuffer(const TDesC8& aData, const TUint aRepeats)
   303 void CEndpointWriter::CreateBigBuffer(const TDesC8& aData, const TUint aRepeats)
   324 /*
   304 /*
   325 Create a payload buffer a section of which can always be used for each cyclic 'Write'.
   305 Create a payload buffer a section of which can always be used for each cyclic 'Write'.
   326 */
   306 */
   327 	{
   307 	{
   328 	OstTraceFunctionEntryExt( CENDPOINTWRITER_CREATEBIGBUFFER_ENTRY, this );
       
   329 	//We require a buffer containing a sufficient number of repeats of the data pattern
   308 	//We require a buffer containing a sufficient number of repeats of the data pattern
   330 	//to allow us simply to use a section of it for any individual 'Write' payload.
   309 	//to allow us simply to use a section of it for any individual 'Write' payload.
   331  	delete iBuffer;
   310  	delete iBuffer;
   332  	iBuffer = NULL;
   311  	iBuffer = NULL;
   333  	OstTraceExt2(TRACE_NORMAL, CENDPOINTWRITER_CREATEBIGBUFFER, "Data buffer is using %u repeats of string starting...\n\"%s\"", aRepeats, aData);
   312  	RDebug::Printf("Data buffer is using %d repeats of string starting...\n\"%S\"", aRepeats, &aData);
   334  	iBuffer = HBufC8::NewL(aRepeats*aData.Length());
   313  	iBuffer = HBufC8::NewL(aRepeats*aData.Length());
   335 	iBufPtr.Set(iBuffer->Des());
   314 	iBufPtr.Set(iBuffer->Des());
   336 	iBufPtr.Zero();
   315 	iBufPtr.Zero();
   337  	for(TUint i =0; i<aRepeats; i++)
   316  	for(TUint i =0; i<aRepeats; i++)
   338   		{
   317   		{
   339   		iBufPtr.Append(aData);
   318   		iBufPtr.Append(aData);
   340   		}
   319   		}
   341 	OstTraceFunctionExit1( CENDPOINTWRITER_CREATEBIGBUFFER_EXIT, this );
   320 	}
   342 	}
   321 
   343 
   322 	}
   344 	}