kerneltest/e32test/usbho/t_usbdi/src/testinterfacesettingbase.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".
    17 //
    17 //
    18 
    18 
    19 #include "testinterfacesettingbase.h"
    19 #include "testinterfacesettingbase.h"
    20 #include "testinterfacebase.h"
    20 #include "testinterfacebase.h"
    21 #include "controltransferrequests.h"
    21 #include "controltransferrequests.h"
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "testinterfacesettingbaseTraces.h"
       
    25 #endif
    22  
    26  
    23  
    27  
    24 namespace NUnitTesting_USBDI
    28 namespace NUnitTesting_USBDI
    25 	{	
    29 	{	
    26 	
    30 	
    27 CInterfaceSettingBase::CInterfaceSettingBase(const TDesC& aString)
    31 CInterfaceSettingBase::CInterfaceSettingBase(const TDesC& aString)
    28 :	iHashEndpointFunction(EndpointNumberHash),
    32 :	iHashEndpointFunction(EndpointNumberHash),
    29 	iIdRelEndpoint(EndpointIdentityRelationship),
    33 	iIdRelEndpoint(EndpointIdentityRelationship),
    30 	iEndpoints(iHashEndpointFunction,iIdRelEndpoint)
    34 	iEndpoints(iHashEndpointFunction,iIdRelEndpoint)
    31 	{	
    35 	{	
       
    36 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_ENTRY, this );
    32 	// Set the name of this interface setting
    37 	// Set the name of this interface setting
    33 	iSettingString.Copy(aString);
    38 	iSettingString.Copy(aString);
    34 	iInterfaceInfo().iString = &iSettingString;
    39 	iInterfaceInfo().iString = &iSettingString;
    35 	
    40 	
    36 	// Zero count the number of endpoints used for this setting
    41 	// Zero count the number of endpoints used for this setting
    37 	iInterfaceInfo().iTotalEndpointsUsed = 0;
    42 	iInterfaceInfo().iTotalEndpointsUsed = 0;
       
    43 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_EXIT, this );
    38 	}
    44 	}
    39 
    45 
    40 	
    46 	
    41 CInterfaceSettingBase::~CInterfaceSettingBase()
    47 CInterfaceSettingBase::~CInterfaceSettingBase()
    42 	{
    48 	{
    43 	LOG_FUNC
    49 	OstTraceFunctionEntry1( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_ENTRY_DUP01, this );
    44 	
    50 	
    45 	iEndpointReaders.ResetAndDestroy();
    51 	iEndpointReaders.ResetAndDestroy();
    46 	iEndpointWriters.ResetAndDestroy();
    52 	iEndpointWriters.ResetAndDestroy();
       
    53 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_EXIT_DUP01, this );
    47 	}
    54 	}
    48 	
    55 	
    49 
    56 
    50 const TDesC& CInterfaceSettingBase::Name() const
    57 const TDesC& CInterfaceSettingBase::Name() const
    51 	{
    58 	{
       
    59 	OstTraceFunctionEntry1( CINTERFACESETTINGBASE_NAME_ENTRY, this );
       
    60 	OstTraceFunctionExitExt( CINTERFACESETTINGBASE_NAME_EXIT, this, ( TUint )&( iSettingString ) );
    52 	return iSettingString;
    61 	return iSettingString;
    53 	}
    62 	}
    54 
    63 
    55 
    64 
    56 void CInterfaceSettingBase::SetClassCodeL(TUint8 aClassCode,TUint8 aSubClassCode,TUint8 aDeviceProtocol)
    65 void CInterfaceSettingBase::SetClassCodeL(TUint8 aClassCode,TUint8 aSubClassCode,TUint8 aDeviceProtocol)
    57 	{
    66 	{
       
    67 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_SETCLASSCODEL_ENTRY, this );
    58 	// Set class specific information
    68 	// Set class specific information
    59 	iInterfaceInfo().iClass = TUsbcClassInfo(aClassCode,aSubClassCode,aDeviceProtocol);
    69 	iInterfaceInfo().iClass = TUsbcClassInfo(aClassCode,aSubClassCode,aDeviceProtocol);
       
    70 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_SETCLASSCODEL_EXIT, this );
    60 	}
    71 	}
    61 
    72 
    62 
    73 
    63 TInt CInterfaceSettingBase::AddEndpoint(TEndpoint& aEndpoint)
    74 TInt CInterfaceSettingBase::AddEndpoint(TEndpoint& aEndpoint)
    64 	{
    75 	{
    65 	LOG_FUNC
    76 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_ADDENDPOINT_ENTRY, this );
    66 	
    77 	
    67 	if(aEndpoint.iEndpointNumber == EEndpoint0)
    78 	if(aEndpoint.iEndpointNumber == EEndpoint0)
    68 		{
    79 		{
       
    80 		OstTraceFunctionExitExt( CINTERFACESETTINGBASE_ADDENDPOINT_EXIT, this, KErrInUse );
    69 		return KErrInUse;
    81 		return KErrInUse;
    70 		}
    82 		}
    71 	
    83 	
    72 	if(iEndpoints.Count() < KMaxEndpointsPerClient)
    84 	if(iEndpoints.Count() < KMaxEndpointsPerClient)
    73 		{
    85 		{
    76 		iEndpoints.Insert(aEndpoint.iEndpointNumber,aEndpoint);
    88 		iEndpoints.Insert(aEndpoint.iEndpointNumber,aEndpoint);
    77 		
    89 		
    78 		// Update the total endpoints used on this interface
    90 		// Update the total endpoints used on this interface
    79 		iInterfaceInfo().iTotalEndpointsUsed = iEndpoints.Count();
    91 		iInterfaceInfo().iTotalEndpointsUsed = iEndpoints.Count();
    80 		
    92 		
       
    93 		OstTraceFunctionExitExt( CINTERFACESETTINGBASE_ADDENDPOINT_EXIT_DUP01, this, KErrNone );
    81 		return KErrNone;
    94 		return KErrNone;
    82 		}
    95 		}
    83 	else
    96 	else
    84 		{
    97 		{
       
    98 		OstTraceFunctionExitExt( CINTERFACESETTINGBASE_ADDENDPOINT_EXIT_DUP02, this, KErrOverflow );
    85 		return KErrOverflow;
    99 		return KErrOverflow;
    86 		}
   100 		}
    87 	}
   101 	}
    88 
   102 
    89 
   103 
    90 void CInterfaceSettingBase::CreateEndpointReaderL(RDevUsbcClient& aClientDriver,TUint aEndpoint)
   104 void CInterfaceSettingBase::CreateEndpointReaderL(RDevUsbcClient& aClientDriver,TUint aEndpoint)
    91 	{
   105 	{
    92 	LOG_FUNC	
   106 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CREATEENDPOINTREADERL_ENTRY, this );
    93 	// Create the reader for this endpoint and store in the container	
   107 	// Create the reader for this endpoint and store in the container	
    94 	CEndpointReader* epReader = new (ELeave) CEndpointReader(aClientDriver,
   108 	CEndpointReader* epReader = new (ELeave) CEndpointReader(aClientDriver,
    95 	iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber);
   109 	iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber);
    96 	CleanupStack::PushL(epReader);
   110 	CleanupStack::PushL(epReader);
    97 	iEndpointReaders.AppendL(epReader);
   111 	iEndpointReaders.AppendL(epReader);
    98 	CleanupStack::Pop(epReader);
   112 	CleanupStack::Pop(epReader);
       
   113 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_CREATEENDPOINTREADERL_EXIT, this );
    99 	}
   114 	}
   100 
   115 
   101 
   116 
   102 void CInterfaceSettingBase::CreateEndpointWriterL(RDevUsbcClient& aClientDriver,TUint aEndpoint)
   117 void CInterfaceSettingBase::CreateEndpointWriterL(RDevUsbcClient& aClientDriver,TUint aEndpoint)
   103 	{
   118 	{
   104 	LOG_FUNC	
   119 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CREATEENDPOINTWRITERL_ENTRY, this );
   105 	// Create the writer for this endpoint and store in the container	
   120 	// Create the writer for this endpoint and store in the container	
   106 	CEndpointWriter* epWriter = new (ELeave) CEndpointWriter(aClientDriver,
   121 	CEndpointWriter* epWriter = new (ELeave) CEndpointWriter(aClientDriver,
   107 	iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber);
   122 	iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber);
   108 	CleanupStack::PushL(epWriter);
   123 	CleanupStack::PushL(epWriter);
   109 	iEndpointWriters.AppendL(epWriter);
   124 	iEndpointWriters.AppendL(epWriter);
   110 	CleanupStack::Pop(epWriter);
   125 	CleanupStack::Pop(epWriter);
       
   126 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_CREATEENDPOINTWRITERL_EXIT, this );
   111 	}
   127 	}
   112 
   128 
   113 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aData,TUint16 aEndpointNumber)
   129 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aData,TUint16 aEndpointNumber)
   114 	{
   130 	{
   115 	LOG_FUNC	
   131 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_ENTRY, this );
   116 	// Access the correct writer for the given endpoint
   132 	// Access the correct writer for the given endpoint
   117 	// and write the data to the host			
   133 	// and write the data to the host			
   118 	iEndpointWriters[aEndpointNumber-1]->Write(aData, ETrue);
   134 	iEndpointWriters[aEndpointNumber-1]->Write(aData, ETrue);
       
   135 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_EXIT, this );
   119 	}
   136 	}
   120 
   137 
   121 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber)
   138 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber)
   122 	{
   139 	{
   123 	LOG_FUNC	
   140 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_ENTRY_DUP01, this );
   124 	// Access the correct writer for the given endpoint
   141 	// Access the correct writer for the given endpoint
   125 	// and write the data to the host
   142 	// and write the data to the host
   126 	iEndpointWriters[aEndpointNumber-1]->WriteUsingPatternL(aDataPattern,aNumBytes,ETrue);
   143 	iEndpointWriters[aEndpointNumber-1]->WriteUsingPatternL(aDataPattern,aNumBytes,ETrue);
       
   144 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_EXIT_DUP01, this );
   127 	}
   145 	}
   128 
   146 
   129 void CInterfaceSettingBase::RepeatedWriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerWrite, TUint aTotalNumBytes, TUint16 aEndpointNumber)
   147 void CInterfaceSettingBase::RepeatedWriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerWrite, TUint aTotalNumBytes, TUint16 aEndpointNumber)
   130 	{
   148 	{
   131 	LOG_FUNC	
   149 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_REPEATEDWRITESPECIFIEDDATATOENDPOINTL_ENTRY, this );
   132 	// Access the correct writer for the given endpoint
   150 	// Access the correct writer for the given endpoint
   133 	// and write the data to the host
   151 	// and write the data to the host
   134 	iEndpointWriters[aEndpointNumber-1]->WriteInPartsUsingPatternL(aDataPattern,aNumBytesPerWrite,aTotalNumBytes,ETrue);
   152 	iEndpointWriters[aEndpointNumber-1]->WriteInPartsUsingPatternL(aDataPattern,aNumBytesPerWrite,aTotalNumBytes,ETrue);
       
   153 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_REPEATEDWRITESPECIFIEDDATATOENDPOINTL_EXIT, this );
   135 	}
   154 	}
   136 
   155 
   137 void CInterfaceSettingBase::WriteCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber)
   156 void CInterfaceSettingBase::WriteCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber)
   138 	{
   157 	{
   139 	LOG_FUNC
   158 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITECACHEDENDPOINTDATATOENDPOINTL_ENTRY, this );
   140 	
   159 	
   141 	iEndpointWriters[aWriteEndpointNumber-1]->Write(iEndpointReaders[aReadEndpointNumber-1]->Buffer(), ETrue);
   160 	iEndpointWriters[aWriteEndpointNumber-1]->Write(iEndpointReaders[aReadEndpointNumber-1]->Buffer(), ETrue);
       
   161 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITECACHEDENDPOINTDATATOENDPOINTL_EXIT, this );
   142 	}
   162 	}
   143 
   163 
   144 void CInterfaceSettingBase::CancelWriteDataToEndpointL(TUint16 aEndpointNumber)
   164 void CInterfaceSettingBase::CancelWriteDataToEndpointL(TUint16 aEndpointNumber)
   145 	{
   165 	{
   146 	LOG_FUNC	
   166 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CANCELWRITEDATATOENDPOINTL_ENTRY, this );
   147 	// Access the correct writer for the given endpoint
   167 	// Access the correct writer for the given endpoint
   148 	// and cancel any outstanding write. This will not of course work for 'synchronous' writes.			
   168 	// and cancel any outstanding write. This will not of course work for 'synchronous' writes.			
   149 	iEndpointWriters[aEndpointNumber-1]->Cancel();
   169 	iEndpointWriters[aEndpointNumber-1]->Cancel();
       
   170 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_CANCELWRITEDATATOENDPOINTL_EXIT, this );
   150 	}
   171 	}
   151 
   172 
   152 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber)
   173 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber)
   153 	{
   174 	{
   154 	LOG_FUNC	
   175 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOENDPOINTL_ENTRY, this );
   155 	// Access the correct writer for the given endpoint
   176 	// Access the correct writer for the given endpoint
   156 	// and write the data to the host
   177 	// and write the data to the host
   157 	iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternL(aDataPattern,aNumBytes,ETrue);
   178 	iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternL(aDataPattern,aNumBytes,ETrue);
       
   179 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOENDPOINTL_EXIT, this );
   158 	}
   180 	}
   159 
   181 
   160 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToAndHaltEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber)
   182 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToAndHaltEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber)
   161 	{
   183 	{
   162 	LOG_FUNC	
   184 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOANDHALTENDPOINTL_ENTRY, this );
   163 	// Access the correct writer for the given endpoint
   185 	// Access the correct writer for the given endpoint
   164 	// and write the data to the host
   186 	// and write the data to the host
   165 	iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternAndHaltL(aDataPattern,aNumBytes);
   187 	iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternAndHaltL(aDataPattern,aNumBytes);
       
   188 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOANDHALTENDPOINTL_EXIT, this );
   166 	}
   189 	}
   167 
   190 
   168 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber)
   191 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber)
   169 	{
   192 	{
   170 	LOG_FUNC
   193 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_ENTRY, this );
   171 	
   194 	
   172 	//Attempt to write the complete cached buffer by starting at zero and choosing the max length posible
   195 	//Attempt to write the complete cached buffer by starting at zero and choosing the max length posible
   173 	WriteSynchronousCachedEndpointDataToEndpointL(aReadEndpointNumber, aWriteEndpointNumber, 0, KMaxTInt);
   196 	WriteSynchronousCachedEndpointDataToEndpointL(aReadEndpointNumber, aWriteEndpointNumber, 0, KMaxTInt);
       
   197 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_EXIT, this );
   174 	}
   198 	}
   175 
   199 
   176 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber, TUint aStartPoint, TUint aLength)
   200 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber, TUint aStartPoint, TUint aLength)
   177 	{
   201 	{
   178 	LOG_FUNC	
   202 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_ENTRY_DUP01, this );
   179 	// Access the correct writer for the given endpoint
   203 	// Access the correct writer for the given endpoint
   180 	// Access the 'source' endpoint buffer. This contains data from that endpoint's last read.
   204 	// Access the 'source' endpoint buffer. This contains data from that endpoint's last read.
   181 	// Write this data to the host using 'write' endpoint.
   205 	// Write this data to the host using 'write' endpoint.
   182 	
   206 	
   183 	// Check data
   207 	// Check data
   191 		}
   215 		}
   192 	
   216 	
   193 	// Do the 'Write'
   217 	// Do the 'Write'
   194 	// Note we need a synchronous 'Write' here
   218 	// Note we need a synchronous 'Write' here
   195 	iEndpointWriters[aWriteEndpointNumber-1]->WriteSynchronous(iEndpointReaders[aReadEndpointNumber-1]->Buffer().Mid(aStartPoint, aLength), ETrue);
   219 	iEndpointWriters[aWriteEndpointNumber-1]->WriteSynchronous(iEndpointReaders[aReadEndpointNumber-1]->Buffer().Mid(aStartPoint, aLength), ETrue);
       
   220 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_EXIT_DUP01, this );
   196 	}
   221 	}
   197 
   222 
   198 TBool CInterfaceSettingBase::CachedEndpointResultL(const TUint16 aEndpointNumber)
   223 TBool CInterfaceSettingBase::CachedEndpointResultL(const TUint16 aEndpointNumber)
   199 	{
   224 	{
   200 	LOG_FUNC	
   225 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CACHEDENDPOINTRESULTL_ENTRY, this );
   201 	// Access endpoint buffer containing data from the endpoint's last read
   226 	// Access endpoint buffer containing data from the endpoint's last read
   202 	// and validate with the supplied data pattern
   227 	// and validate with the supplied data pattern
   203 
   228 
   204 	return iEndpointReaders[aEndpointNumber-1]->IsValid();
   229 	return iEndpointReaders[aEndpointNumber-1]->IsValid();
   205 	}
   230 	}
   206 
   231 
   207 TInt CInterfaceSettingBase::NumBytesReadSoFarL(const TUint16 aEndpointNumber)
   232 TInt CInterfaceSettingBase::NumBytesReadSoFarL(const TUint16 aEndpointNumber)
   208 	{
   233 	{
   209 	LOG_FUNC	
   234 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_NUMBYTESREADSOFARL_ENTRY, this );
   210 	// Access endpoint buffer containing data from the endpoint's last read
   235 	// Access endpoint buffer containing data from the endpoint's last read
   211 	// and validate with the supplied data pattern
   236 	// and validate with the supplied data pattern
   212 
   237 
   213 	return iEndpointReaders[aEndpointNumber-1]->NumBytesReadSoFar();
   238 	return iEndpointReaders[aEndpointNumber-1]->NumBytesReadSoFar();
   214 	}
   239 	}
   215 
   240 
   216 TInt CInterfaceSettingBase::NumBytesWrittenSoFarL(const TUint16 aEndpointNumber)
   241 TInt CInterfaceSettingBase::NumBytesWrittenSoFarL(const TUint16 aEndpointNumber)
   217 	{
   242 	{
   218 	LOG_FUNC	
   243 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_NUMBYTESWRITTENSOFARL_ENTRY, this );
   219 	// Access endpoint buffer containing data from the endpoint's last read
   244 	// Access endpoint buffer containing data from the endpoint's last read
   220 	// and validate with the supplied data pattern
   245 	// and validate with the supplied data pattern
   221 
   246 
   222 	return iEndpointWriters[aEndpointNumber-1]->NumBytesWrittenSoFar();
   247 	return iEndpointWriters[aEndpointNumber-1]->NumBytesWrittenSoFar();
   223 	}
   248 	}
   224 
   249 
   225 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aNumBytes, const TUint16 aEndpointNumber)
   250 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aNumBytes, const TUint16 aEndpointNumber)
   226 	{
   251 	{
   227 	LOG_FUNC	
   252 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_ENTRY, this );
   228 	// Access endpoint buffer containing data from the endpoint's last read
   253 	// Access endpoint buffer containing data from the endpoint's last read
   229 	// and validate with the supplied data pattern
   254 	// and validate with the supplied data pattern
   230 
   255 
   231 	return ValidateCachedEndpointDataL(aDataPattern, 0, aNumBytes, aEndpointNumber);
   256 	return ValidateCachedEndpointDataL(aDataPattern, 0, aNumBytes, aEndpointNumber);
   232 	}
   257 	}
   233 
   258 
   234 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aStartPoint, const TUint aNumBytes, const TUint16 aEndpointNumber)
   259 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aStartPoint, const TUint aNumBytes, const TUint16 aEndpointNumber)
   235 	{
   260 	{
   236 	LOG_FUNC	
   261 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_ENTRY_DUP01, this );
   237 	__ASSERT_DEBUG(aDataPattern.Length()!=0, User::Panic(_L("Trying to validate with ZERO LENGTH STRING"), KErrArgument));
   262 	__ASSERT_DEBUG(aDataPattern.Length()!=0, User::Panic(_L("Trying to validate with ZERO LENGTH STRING"), KErrArgument));
   238 
   263 
   239 	//Check data in endpoint buffer
   264 	//Check data in endpoint buffer
   240 	TPtr8 dataToValidate(iEndpointReaders[aEndpointNumber-1]->Buffer());
   265 	TPtr8 dataToValidate(iEndpointReaders[aEndpointNumber-1]->Buffer());
   241 	User::LeaveIfError(dataToValidate.MaxLength() == 0);
   266 	User::LeaveIfError(dataToValidate.MaxLength() == 0);
   248 	TUint numEndBytes = aNumBytes - startEndPoint;//fullRepeats*aDataPattern.Length() - numStartBytes;
   273 	TUint numEndBytes = aNumBytes - startEndPoint;//fullRepeats*aDataPattern.Length() - numStartBytes;
   249 	if(numStartBytes)
   274 	if(numStartBytes)
   250 		{
   275 		{
   251 		if(dataToValidate.Left(numStartBytes).Compare(aDataPattern.Mid(startPoint, numStartBytes)) != 0)
   276 		if(dataToValidate.Left(numStartBytes).Compare(aDataPattern.Mid(startPoint, numStartBytes)) != 0)
   252 			{
   277 			{
   253 			RDebug::Printf("ROUND TRIP VALIDATION: Start Bytes Match Failure");
   278 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL, "ROUND TRIP VALIDATION: Start Bytes Match Failure");
   254 			RDebug::Printf("ROUND TRIP VALIDATION: numStartBytes = %d", numStartBytes);
   279 			OstTrace1(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP01, "ROUND TRIP VALIDATION: numStartBytes = %d", numStartBytes);
   255 			RDebug::Printf("Start of sent data ...");
   280 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP02, "Start of sent data ...");
   256 			RDebug::RawPrint(aDataPattern.Mid(startPoint, numStartBytes));
   281             const TPtrC8& midDataPattern = aDataPattern.Mid(startPoint, numStartBytes);
   257 			RDebug::Printf("\n");
   282             OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP52, "", midDataPattern.Ptr(), midDataPattern.Length());
   258 			RDebug::Printf("ROUND TRIP VALIDATION: Start of returned data ...");				
   283 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP03, "\n");
   259 			RDebug::RawPrint(dataToValidate.Left(numStartBytes));
   284 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP04, "ROUND TRIP VALIDATION: Start of returned data ...");
   260 			RDebug::Printf("\n");
   285             const TPtrC8& leftDataToValidate = dataToValidate.Left(numStartBytes);
       
   286             OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP54, "", leftDataToValidate.Ptr(), leftDataToValidate.Length());
       
   287 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP05, "\n");
       
   288 			OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT, this, EFalse );
   261 			return EFalse;
   289 			return EFalse;
   262 			}
   290 			}
   263 		}
   291 		}
   264 	if(numEndBytes)
   292 	if(numEndBytes)
   265 		{
   293 		{
   266 		if(dataToValidate.Mid(startEndPoint,numEndBytes).Compare(aDataPattern.Left(numEndBytes)) != 0)
   294 		if(dataToValidate.Mid(startEndPoint,numEndBytes).Compare(aDataPattern.Left(numEndBytes)) != 0)
   267 			{
   295 			{
   268 			RDebug::Printf("ROUND TRIP VALIDATION: End Bytes Match Failure");
   296 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP06, "ROUND TRIP VALIDATION: End Bytes Match Failure");
   269 			RDebug::Printf("ROUND TRIP VALIDATION: startEndPoint = %d, numEndBytes = %d", startEndPoint, numEndBytes);
   297 			OstTraceExt2(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP07, "ROUND TRIP VALIDATION: startEndPoint = %u, numEndBytes = %u", startEndPoint, numEndBytes);
   270 			RDebug::Printf("End of sent data ...");
   298 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP08, "End of sent data ...");
   271 			RDebug::RawPrint(aDataPattern.Left(numEndBytes));
   299             const TPtrC8& leftDataPattern = aDataPattern.Left(numEndBytes);
   272 			RDebug::Printf("\n");
   300             OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP58, "", leftDataPattern.Ptr(), leftDataPattern.Length());
   273 			RDebug::Printf("ROUND TRIP VALIDATION: End of returned data ...");				
   301 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP09, "\n");
   274 			RDebug::RawPrint(dataToValidate.Mid(startEndPoint,numEndBytes));
   302 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP10, "ROUND TRIP VALIDATION: End of returned data ...");
   275 			RDebug::Printf("\n");
   303             const TPtrC8& midDataToValidate = dataToValidate.Mid(startEndPoint,numEndBytes);
       
   304             OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP60, "", midDataToValidate.Ptr(), midDataToValidate.Length());
       
   305 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP11, "\n");
       
   306 			OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT_DUP01, this, EFalse );
   276 			return EFalse;
   307 			return EFalse;
   277 			}
   308 			}
   278 		}
   309 		}
   279 	for(TInt i=0; i<fullRepeats; i++)
   310 	for(TInt i=0; i<fullRepeats; i++)
   280 		{
   311 		{
   281 		if(dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()).Compare(aDataPattern) != 0)
   312 		if(dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()).Compare(aDataPattern) != 0)
   282 			{
   313 			{
   283 			RDebug::Printf("ROUND TRIP VALIDATION: Repeated Bytes Match Failure, Repeat %d",i);
   314 			OstTrace1(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP12, "ROUND TRIP VALIDATION: Repeated Bytes Match Failure, Repeat %d",i);
   284 			RDebug::Printf("sent data middle block ...");
   315 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP13, "sent data middle block ...");
   285 			RDebug::RawPrint(aDataPattern);
   316             OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP53, "", aDataPattern.Ptr(), aDataPattern.Length());
   286 			RDebug::Printf("\n");
   317 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP14, "\n");
   287 			RDebug::Printf("ROUND TRIP VALIDATION: Middle block of returned data ...");
   318 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP15, "ROUND TRIP VALIDATION: Middle block of returned data ...");
   288 			RDebug::RawPrint(dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()));
   319             const TPtrC8& midDataToValidate = dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length());
   289 			RDebug::Printf("\n");
   320             OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP55, "", midDataToValidate.Ptr(), midDataToValidate.Length());
       
   321 			OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP16, "\n");
       
   322 			OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT_DUP02, this, EFalse );
   290 			return EFalse; //from 'for' loop
   323 			return EFalse; //from 'for' loop
   291 			}
   324 			}
   292 		}
   325 		}
       
   326 	OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT_DUP03, this, ETrue );
   293 	return ETrue;
   327 	return ETrue;
   294 	}
   328 	}
   295 
   329 
   296 
   330 
   297 void CInterfaceSettingBase::ReadDataFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber)	
   331 void CInterfaceSettingBase::ReadDataFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber)	
   298 	{
   332 	{
   299 	LOG_FUNC	
   333 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_READDATAFROMENDPOINTL_ENTRY, this );
   300 	// Access the correct readerer for the given endpoint
   334 	// Access the correct readerer for the given endpoint
   301 	// and prepare to read the data to be sent by the host			
   335 	// and prepare to read the data to be sent by the host			
   302 	iEndpointReaders[aEndpointNumber-1]->ReadL(aNumBytes);
   336 	iEndpointReaders[aEndpointNumber-1]->ReadL(aNumBytes);
       
   337 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_READDATAFROMENDPOINTL_EXIT, this );
   303 	}
   338 	}
   304 
   339 
   305 void CInterfaceSettingBase::CancelAnyReadDataFromEndpointL(TUint16 aEndpointNumber)
   340 void CInterfaceSettingBase::CancelAnyReadDataFromEndpointL(TUint16 aEndpointNumber)
   306 	{
   341 	{
   307 	LOG_FUNC	
   342 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CANCELANYREADDATAFROMENDPOINTL_ENTRY, this );
   308 	// Access the correct writer for the given endpoint
   343 	// Access the correct writer for the given endpoint
   309 	// and cancel any outstanding write. This will not of course work for 'synchronous' writes.			
   344 	// and cancel any outstanding write. This will not of course work for 'synchronous' writes.			
   310 	iEndpointReaders[aEndpointNumber-1]->Cancel();
   345 	iEndpointReaders[aEndpointNumber-1]->Cancel();
       
   346 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_CANCELANYREADDATAFROMENDPOINTL_EXIT, this );
   311 	}
   347 	}
   312 
   348 
   313 void CInterfaceSettingBase::ReadDataFromAndHaltEndpointL(TUint aNumBytes, TUint16 aEndpointNumber)	
   349 void CInterfaceSettingBase::ReadDataFromAndHaltEndpointL(TUint aNumBytes, TUint16 aEndpointNumber)	
   314 	{
   350 	{
   315 	LOG_FUNC	
   351 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_READDATAFROMANDHALTENDPOINTL_ENTRY, this );
   316 	// Access the correct reader for the given endpoint
   352 	// Access the correct reader for the given endpoint
   317 	// and prepare to read the data to be sent by the host			
   353 	// and prepare to read the data to be sent by the host			
   318 	iEndpointReaders[aEndpointNumber-1]->ReadAndHaltL(aNumBytes);
   354 	iEndpointReaders[aEndpointNumber-1]->ReadAndHaltL(aNumBytes);
       
   355 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_READDATAFROMANDHALTENDPOINTL_EXIT, this );
   319 	}
   356 	}
   320 
   357 
   321 void CInterfaceSettingBase::RepeatedReadAndValidateFromEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerRead, TUint aTotalNumBytes, TUint16 aEndpointNumber)
   358 void CInterfaceSettingBase::RepeatedReadAndValidateFromEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerRead, TUint aTotalNumBytes, TUint16 aEndpointNumber)
   322 	{
   359 	{
   323 	LOG_FUNC	
   360 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_REPEATEDREADANDVALIDATEFROMENDPOINTL_ENTRY, this );
   324 	// Access the correct reader for the given endpoint
   361 	// Access the correct reader for the given endpoint
   325 	// and prepare to read the data to be sent by the host
   362 	// and prepare to read the data to be sent by the host
   326 	// using multiple 'Reads'
   363 	// using multiple 'Reads'
   327 	iEndpointReaders[aEndpointNumber-1]->RepeatedReadAndValidateL(aDataPattern, aNumBytesPerRead, aTotalNumBytes);
   364 	iEndpointReaders[aEndpointNumber-1]->RepeatedReadAndValidateL(aDataPattern, aNumBytesPerRead, aTotalNumBytes);
       
   365 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_REPEATEDREADANDVALIDATEFROMENDPOINTL_EXIT, this );
   328 	}
   366 	}
   329 
   367 
   330 void CInterfaceSettingBase::ReadDataUntilShortFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber)	
   368 void CInterfaceSettingBase::ReadDataUntilShortFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber)	
   331 	{
   369 	{
   332 	LOG_FUNC	
   370 	OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_READDATAUNTILSHORTFROMENDPOINTL_ENTRY, this );
   333 	// Access the correct reader for the given endpoint
   371 	// Access the correct reader for the given endpoint
   334 	// and prepare to read the data to be sent by the host			
   372 	// and prepare to read the data to be sent by the host			
   335 	iEndpointReaders[aEndpointNumber-1]->ReadUntilShortL(aNumBytes);
   373 	iEndpointReaders[aEndpointNumber-1]->ReadUntilShortL(aNumBytes);
   336 	}
   374 	OstTraceFunctionExit1( CINTERFACESETTINGBASE_READDATAUNTILSHORTFROMENDPOINTL_EXIT, this );
   337 	}
   375 	}
   338 
   376 	}
   339 	
   377 
       
   378