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