kerneltest/e32test/usbho/t_usbdi/src/TestInterfaceBase.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".
    20 #include "testinterfacebase.h"
    20 #include "testinterfacebase.h"
    21 #include "testinterfacesettingbase.h"
    21 #include "testinterfacesettingbase.h"
    22 #include "testdebug.h"
    22 #include "testdebug.h"
    23 #include "controltransferrequests.h"
    23 #include "controltransferrequests.h"
    24 #include "endpointwriter.h"
    24 #include "endpointwriter.h"
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "TestInterfaceBaseTraces.h"
       
    28 #endif
    25 
    29 
    26 
    30 
    27 namespace NUnitTesting_USBDI
    31 namespace NUnitTesting_USBDI
    28 	{
    32 	{
    29 
    33 
    31 CInterfaceBase::CInterfaceBase(RUsbTestDevice& aTestDevice,const TDesC16& aName)
    35 CInterfaceBase::CInterfaceBase(RUsbTestDevice& aTestDevice,const TDesC16& aName)
    32 :	iDevice(aTestDevice),
    36 :	iDevice(aTestDevice),
    33 	iInterfaceName(aName),
    37 	iInterfaceName(aName),
    34 	iCurrentAlternateInterfaceSetting(0) // The default alternate interface setting will be zero when opened
    38 	iCurrentAlternateInterfaceSetting(0) // The default alternate interface setting will be zero when opened
    35 	{
    39 	{
       
    40 	OstTraceFunctionEntryExt( CINTERFACEBASE_CINTERFACEBASE_ENTRY, this );
       
    41 	OstTraceFunctionExit1( CINTERFACEBASE_CINTERFACEBASE_EXIT, this );
    36 	}
    42 	}
    37 	
    43 	
    38 CInterfaceBase::~CInterfaceBase()
    44 CInterfaceBase::~CInterfaceBase()
    39 	{
    45 	{
    40 	LOG_FUNC
    46 	OstTraceFunctionEntry1( CINTERFACEBASE_CINTERFACEBASE_ENTRY_DUP01, this );
    41 	
    47 	
    42 	delete iAuxBuffer;
    48 	delete iAuxBuffer;
    43 	delete iStallWatcher;
    49 	delete iStallWatcher;
    44 	delete iSelectionWatcher;
    50 	delete iSelectionWatcher;
    45 		
    51 		
    52 	// Destroy interface settings
    58 	// Destroy interface settings
    53 	iAlternateSettings.ResetAndDestroy();
    59 	iAlternateSettings.ResetAndDestroy();
    54 	
    60 	
    55 	// Close the channel to the driver
    61 	// Close the channel to the driver
    56 	iClientDriver.Close();
    62 	iClientDriver.Close();
       
    63 	OstTraceFunctionExit1( CINTERFACEBASE_CINTERFACEBASE_EXIT_DUP01, this );
    57 	}
    64 	}
    58 	
    65 	
    59 	
    66 	
    60 void CInterfaceBase::BaseConstructL()
    67 void CInterfaceBase::BaseConstructL()
    61 	{
    68 	{
    62 	LOG_FUNC
    69 	OstTraceFunctionEntry1( CINTERFACEBASE_BASECONSTRUCTL_ENTRY, this );
    63 	// Open channel to driver
    70 	// Open channel to driver
    64 	TInt err(iClientDriver.Open(0));
    71 	TInt err(iClientDriver.Open(0));
    65 	if(err != KErrNone)
    72 	if(err != KErrNone)
    66 		{
    73 		{
    67 		RDebug::Printf("<Error %d> Unable to open a channel to USB client driver",err);
    74 		OstTrace1(TRACE_NORMAL, CINTERFACEBASE_BASECONSTRUCTL, "<Error %d> Unable to open a channel to USB client driver",err);
    68 		User::Leave(err);
    75 		User::Leave(err);
    69 		}
    76 		}
    70 
    77 
    71 	// Start the watcher for host selecting alternate interface settings
    78 	// Start the watcher for host selecting alternate interface settings
    72 	iSelectionWatcher = CAlternateInterfaceSelectionWatcher::NewL(iClientDriver,*this);
    79 	iSelectionWatcher = CAlternateInterfaceSelectionWatcher::NewL(iClientDriver,*this);
    78 	iEp0Reader = new (ELeave) CControlEndpointReader(iClientDriver,*this);
    85 	iEp0Reader = new (ELeave) CControlEndpointReader(iClientDriver,*this);
    79 	iEp0Writer = new (ELeave) CEndpointWriter(iClientDriver,EEndpoint0);
    86 	iEp0Writer = new (ELeave) CEndpointWriter(iClientDriver,EEndpoint0);
    80 
    87 
    81 	// Hide bus from host while interfaces are being set up
    88 	// Hide bus from host while interfaces are being set up
    82 	iClientDriver.DeviceDisconnectFromHost();
    89 	iClientDriver.DeviceDisconnectFromHost();
       
    90 	OstTraceFunctionExit1( CINTERFACEBASE_BASECONSTRUCTL_EXIT, this );
    83 	}
    91 	}
    84 
    92 
    85 
    93 
    86 void CInterfaceBase::AddInterfaceSettingL(CInterfaceSettingBase* aInterfaceSetting)
    94 void CInterfaceBase::AddInterfaceSettingL(CInterfaceSettingBase* aInterfaceSetting)
    87 	{
    95 	{
    88 	LOG_FUNC
    96 	OstTraceFunctionEntryExt( CINTERFACEBASE_ADDINTERFACESETTINGL_ENTRY, this );
    89 	
    97 	
    90 	// Append to the container
    98 	// Append to the container
    91 	TInt err(iAlternateSettings.Append(aInterfaceSetting));
    99 	TInt err(iAlternateSettings.Append(aInterfaceSetting));
    92 	if(err != KErrNone)
   100 	if(err != KErrNone)
    93 		{
   101 		{
    94 		RDebug::Printf("<Error %d> Unable to add interface setting",err);
   102 		OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL, "<Error %d> Unable to add interface setting",err);
    95 		User::Leave(err);
   103 		User::Leave(err);
    96 		}
   104 		}
    97 	
   105 	
    98 	// Get the current number of alternate interface settings	
   106 	// Get the current number of alternate interface settings	
    99 	TInt alternateSettingNumber(iAlternateSettings.Count()-1);
   107 	TInt alternateSettingNumber(iAlternateSettings.Count()-1);
   100 
   108 
   101 	TUint endpointSettingCount(aInterfaceSetting->iInterfaceInfo().iTotalEndpointsUsed);
   109 	TUint endpointSettingCount(aInterfaceSetting->iInterfaceInfo().iTotalEndpointsUsed);
   102 	
   110 	
   103 	if(endpointSettingCount > 0)
   111 	if(endpointSettingCount > 0)
   104 		{
   112 		{
   105 		RDebug::Printf("%u endpoint(s) to configure for this interface setting",endpointSettingCount);
   113 		OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP01, "%u endpoint(s) to configure for this interface setting",endpointSettingCount);
   106 				
   114 				
   107 		// Device capabilities
   115 		// Device capabilities
   108 		TUsbDeviceCaps devCaps;
   116 		TUsbDeviceCaps devCaps;
   109 		err = iClientDriver.DeviceCaps(devCaps);
   117 		err = iClientDriver.DeviceCaps(devCaps);
   110 		if(err != KErrNone)
   118 		if(err != KErrNone)
   111 			{
   119 			{
   112 			RDebug::Printf("<Error %d> Unable to retrieve device capabilities",err);
   120 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP02, "<Error %d> Unable to retrieve device capabilities",err);
   113 			User::Leave(err);
   121 			User::Leave(err);
   114 			}
   122 			}
   115 
   123 
   116 		// Endpoint capabilities
   124 		// Endpoint capabilities
   117 		TUsbcEndpointData endpointCaps[KUsbcMaxEndpoints];
   125 		TUsbcEndpointData endpointCaps[KUsbcMaxEndpoints];
   118 		TPtr8 dataptr(reinterpret_cast<TUint8*>(endpointCaps), sizeof(endpointCaps), sizeof(endpointCaps));
   126 		TPtr8 dataptr(reinterpret_cast<TUint8*>(endpointCaps), sizeof(endpointCaps), sizeof(endpointCaps));
   119 		err = iClientDriver.EndpointCaps(dataptr);
   127 		err = iClientDriver.EndpointCaps(dataptr);
   120 		if(err != KErrNone)
   128 		if(err != KErrNone)
   121 			{
   129 			{
   122 			RDebug::Printf("<Error %d> Unable to get endpoint capabilities",err);
   130 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP03, "<Error %d> Unable to get endpoint capabilities",err);
   123 			User::Leave(err);
   131 			User::Leave(err);
   124 			}		
   132 			}		
   125 		
   133 		
   126 		TInt totalEndpoints(devCaps().iTotalEndpoints);
   134 		TInt totalEndpoints(devCaps().iTotalEndpoints);
   127 		
   135 		
   131 		TUint epIndex(0);
   139 		TUint epIndex(0);
   132 		TUint epCount(0);
   140 		TUint epCount(0);
   133 		
   141 		
   134 		for(; epIndex<totalEndpoints; epIndex++)
   142 		for(; epIndex<totalEndpoints; epIndex++)
   135 			{
   143 			{
   136 			RDebug::Printf("Examining hardware endpoint %u",epIndex);
   144 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP04, "Examining hardware endpoint %u",epIndex);
   137 			const TUsbcEndpointData ep = endpointCaps[epIndex];
   145 			const TUsbcEndpointData ep = endpointCaps[epIndex];
   138 			
   146 			
   139 			// Check the endpoint index to see if already claimed
   147 			// Check the endpoint index to see if already claimed
   140 			if(!ep.iInUse)
   148 			if(!ep.iInUse)
   141 				{			
   149 				{			
   142 				RDebug::Printf("...its free");
   150 				OstTrace0(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP05, "...its free");
   143 				const TUsbcEndpointCaps caps(ep.iCaps);
   151 				const TUsbcEndpointCaps caps(ep.iCaps);
   144 				
   152 				
   145 				// Information about the endpoint we are looking for	
   153 				// Information about the endpoint we are looking for	
   146 				TUsbcEndpointInfo& endpointSpec = aInterfaceSetting->iInterfaceInfo().iEndpointData[epCount];
   154 				TUsbcEndpointInfo& endpointSpec = aInterfaceSetting->iInterfaceInfo().iEndpointData[epCount];
   147 						
   155 						
   155 					if(endpointSpec.iDir == KUsbEpDirIn)
   163 					if(endpointSpec.iDir == KUsbEpDirIn)
   156 						{
   164 						{
   157 						// Create an endpoint writer for this endpoint
   165 						// Create an endpoint writer for this endpoint
   158 						
   166 						
   159 						aInterfaceSetting->CreateEndpointWriterL(iClientDriver,(epCount+1));
   167 						aInterfaceSetting->CreateEndpointWriterL(iClientDriver,(epCount+1));
   160 						RDebug::Printf("Created endpoint writer for endpoint%d",epCount+1);
   168 						OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP06, "Created endpoint writer for endpoint%d",epCount+1);
   161 						}
   169 						}
   162 					else if(endpointSpec.iDir == KUsbEpDirOut)
   170 					else if(endpointSpec.iDir == KUsbEpDirOut)
   163 						{
   171 						{
   164 						// Create an endpoint reader for this endpoint
   172 						// Create an endpoint reader for this endpoint
   165 												
   173 												
   166 						aInterfaceSetting->CreateEndpointReaderL(iClientDriver,epCount+1);
   174 						aInterfaceSetting->CreateEndpointReaderL(iClientDriver,epCount+1);
   167 						RDebug::Printf("Created endpoint reader for endpoint%d",epCount+1);
   175 						OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP07, "Created endpoint reader for endpoint%d",epCount+1);
   168 						}					
   176 						}					
   169 					
   177 					
   170 					epCount++; // Increment to next endpoint spec
   178 					epCount++; // Increment to next endpoint spec
   171 					RDebug::Printf("Endpoint %u configured",epCount);
   179 					OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP08, "Endpoint %u configured",epCount);
   172 					endpointSpec.iSize = caps.MaxPacketSize();
   180 					endpointSpec.iSize = caps.MaxPacketSize();
   173 					
   181 					
   174 					if(epCount >= endpointSettingCount)
   182 					if(epCount >= endpointSettingCount)
   175 						{
   183 						{
   176 						// Found all desired endpoints
   184 						// Found all desired endpoints
   178 						}
   186 						}
   179 					}
   187 					}
   180 				}
   188 				}
   181 			else
   189 			else
   182 				{
   190 				{
   183 				RDebug::Printf("...its busy");
   191 				OstTrace0(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP09, "...its busy");
   184 				}
   192 				}
   185 			}
   193 			}
   186 		
   194 		
   187 		RDebug::Printf("Configure %u out of %u endpoints",epCount,endpointSettingCount);			
   195 		OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP10, "Configure %u out of %u endpoints",epCount,endpointSettingCount);			
   188 		
   196 		
   189 		if(epCount < endpointSettingCount)
   197 		if(epCount < endpointSettingCount)
   190 			{
   198 			{
   191 			RDebug::Printf("<Error %d> Only managed to configure %u out of %u endpoints",KErrNotFound,epCount,endpointSettingCount);
   199 			OstTraceExt3(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP11, "<Error %d> Only managed to configure %u out of %u endpoints",KErrNotFound,epCount,endpointSettingCount);
   192 			User::Leave(KErrNotFound);
   200 			User::Leave(KErrNotFound);
   193 			}			
   201 			}			
   194 		}
   202 		}
   195 	else
   203 	else
   196 		{
   204 		{
   197 		RDebug::Printf("No endpoints for this interface setting");
   205 		OstTrace0(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP12, "No endpoints for this interface setting");
   198 		}
   206 		}
   199 	
   207 	
   200 	// Add the new setting to the device
   208 	// Add the new setting to the device
   201 	err = iClientDriver.SetInterface(alternateSettingNumber,aInterfaceSetting->iInterfaceInfo);
   209 	err = iClientDriver.SetInterface(alternateSettingNumber,aInterfaceSetting->iInterfaceInfo);
   202 	if(err != KErrNone)
   210 	if(err != KErrNone)
   203 		{
   211 		{
   204 		RDebug::Printf("<Error %d> Unable to set the alternate interface setting %d",err,alternateSettingNumber);
   212 		OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP13, "<Error %d> Unable to set the alternate interface setting %d",err,alternateSettingNumber);
   205 		User::Leave(err);
   213 		User::Leave(err);
   206 		}
   214 		}
   207 	
   215 	
   208 	RDebug::Printf("Alternate interface setting %d set",alternateSettingNumber);
   216 	OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP14, "Alternate interface setting %d set",alternateSettingNumber);
       
   217 	OstTraceFunctionExit1( CINTERFACEBASE_ADDINTERFACESETTINGL_EXIT, this );
   209 	}
   218 	}
   210 
   219 
   211 
   220 
   212 TInt CInterfaceBase::StallEndpoint(TUint16 aEndpointNumber)
   221 TInt CInterfaceBase::StallEndpoint(TUint16 aEndpointNumber)
   213 	{
   222 	{
   214 	LOG_FUNC
   223 	OstTraceFunctionEntryExt( CINTERFACEBASE_STALLENDPOINT_ENTRY, this );
   215 	
   224 	
   216 	RDebug::Printf("Stalling endpoint%d",aEndpointNumber);
   225 	OstTrace1(TRACE_NORMAL, CINTERFACEBASE_STALLENDPOINT, "Stalling endpoint%d",aEndpointNumber);
   217 	return iClientDriver.HaltEndpoint(static_cast<TEndpointNumber>(aEndpointNumber));
   226 	return iClientDriver.HaltEndpoint(static_cast<TEndpointNumber>(aEndpointNumber));
   218 	}
   227 	}
   219 
   228 
   220 	
   229 	
   221 CInterfaceSettingBase& CInterfaceBase::AlternateSetting(TInt aSettingNumber) const
   230 CInterfaceSettingBase& CInterfaceBase::AlternateSetting(TInt aSettingNumber) const
   222 	{
   231 	{
       
   232 	OstTraceFunctionEntryExt( CINTERFACEBASE_ALTERNATESETTING_ENTRY, this );
       
   233 	OstTraceFunctionExit1( CINTERFACEBASE_ALTERNATESETTING_EXIT, this );
   223 	return *iAlternateSettings[aSettingNumber];
   234 	return *iAlternateSettings[aSettingNumber];
   224 	}
   235 	}
   225 
   236 
   226 	
   237 	
   227 TInt CInterfaceBase::InterfaceSettingCount() const
   238 TInt CInterfaceBase::InterfaceSettingCount() const
   228 	{
   239 	{
       
   240 	OstTraceFunctionEntry1( CINTERFACEBASE_INTERFACESETTINGCOUNT_ENTRY, this );
   229 	return iAlternateSettings.Count();
   241 	return iAlternateSettings.Count();
   230 	}
   242 	}
   231 
   243 
   232 
   244 
   233 TUint32 CInterfaceBase::ExtractNumberL(const TDesC8& aPayload)
   245 TUint32 CInterfaceBase::ExtractNumberL(const TDesC8& aPayload)
   234 	{
   246 	{
   235 	LOG_FUNC
   247 OstTraceFunctionEntryExt( CINTERFACEBASE_EXTRACTNUMBERL_ENTRY, this );
   236 
   248 
   237 	// Read the number of repeats and the data supplied by the host, on the specified endpoint
   249 	// Read the number of repeats and the data supplied by the host, on the specified endpoint
   238 	TLex8 lex(aPayload.Left(KNumberStringLength));
   250 	TLex8 lex(aPayload.Left(KNumberStringLength));
   239 	TUint32 numBytes;
   251 	TUint32 numBytes;
   240 	User::LeaveIfError(lex.Val(numBytes, EDecimal));
   252 	User::LeaveIfError(lex.Val(numBytes, EDecimal));
   241 	RDebug::Printf("Writing %d bytes using string pattern below to IN endpoint",numBytes);
   253 	OstTrace1(TRACE_NORMAL, CINTERFACEBASE_EXTRACTNUMBERL, "Writing %d bytes using string pattern below to IN endpoint",numBytes);
   242 	RDebug::RawPrint(aPayload.Mid(KNumberStringLength));
   254 	const TPtrC8& midPayload = aPayload.Mid(KNumberStringLength);
   243 	RDebug::Printf(""); //new line
   255     OstTraceData(TRACE_NORMAL, CINTERFACEBASE_EXTRACTNUMBERL_DUP50, "", midPayload.Ptr(), midPayload.Length());
       
   256 	OstTrace0(TRACE_NORMAL, CINTERFACEBASE_EXTRACTNUMBERL_DUP01, "");
       
   257 	OstTraceFunctionExitExt( CINTERFACEBASE_EXTRACTNUMBERL_EXIT, this, ( TUint )( numBytes ) );
   244 	return numBytes;
   258 	return numBytes;
   245 	}
   259 	}
   246 
   260 
   247 void CInterfaceBase::ExtractTwoNumbersL(const TDesC8& aPayload, TUint32& aFirstNum, TUint32& aSecondNum)
   261 void CInterfaceBase::ExtractTwoNumbersL(const TDesC8& aPayload, TUint32& aFirstNum, TUint32& aSecondNum)
   248 	{
   262 	{
   249 	LOG_FUNC
   263 OstTraceFunctionEntryExt( CINTERFACEBASE_EXTRACTTWONUMBERSL_ENTRY, this );
   250 
   264 
   251 	// Read the number of repeats and the data supplied by the host, on the specified endpoint
   265 	// Read the number of repeats and the data supplied by the host, on the specified endpoint
   252 	TLex8 lex1(aPayload.Left(KNumberStringLength));
   266 	TLex8 lex1(aPayload.Left(KNumberStringLength));
   253 	User::LeaveIfError(lex1.Val(aFirstNum, EDecimal));
   267 	User::LeaveIfError(lex1.Val(aFirstNum, EDecimal));
   254 	TLex8 lex2(aPayload.Mid(KNumberStringLength, KNumberStringLength));
   268 	TLex8 lex2(aPayload.Mid(KNumberStringLength, KNumberStringLength));
   255 	User::LeaveIfError(lex2.Val(aSecondNum, EDecimal));
   269 	User::LeaveIfError(lex2.Val(aSecondNum, EDecimal));
   256 	RDebug::Printf("Writing or Reading a total of %d bytes in repeats of %d bytes using string pattern below to IN endpoint",aFirstNum,aSecondNum);
   270 	OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_EXTRACTTWONUMBERSL, "Writing or Reading a total of %d bytes in repeats of %d bytes using string pattern below to IN endpoint",aFirstNum,aSecondNum);
   257 	RDebug::RawPrint(aPayload.Mid(2*KNumberStringLength));
   271 	const TPtrC8& midPayload = aPayload.Mid(2*KNumberStringLength);
   258 	RDebug::Printf(""); //new line
   272     OstTraceData(TRACE_NORMAL, CINTERFACEBASE_EXTRACTTWONUMBERSL_DUP50, "", midPayload.Ptr(), midPayload.Length());
       
   273 	OstTrace0(TRACE_NORMAL, CINTERFACEBASE_EXTRACTTWONUMBERSL_DUP01, "");
       
   274 	OstTraceFunctionExit1( CINTERFACEBASE_EXTRACTTWONUMBERSL_EXIT, this );
   259 	return;
   275 	return;
   260 	}
   276 	}
   261 
   277 
   262 void CInterfaceBase::AlternateInterfaceSelectedL(TInt aAlternateInterfaceSetting)
   278 void CInterfaceBase::AlternateInterfaceSelectedL(TInt aAlternateInterfaceSetting)
   263 	{
   279 	{
   264 	LOG_FUNC
   280 	OstTraceFunctionEntryExt( CINTERFACEBASE_ALTERNATEINTERFACESELECTEDL_ENTRY, this );
   265 	RDebug::Printf("Interface %S:",&iInterfaceName);	
   281 	OstTraceExt1(TRACE_NORMAL, CINTERFACEBASE_ALTERNATEINTERFACESELECTEDL, "Interface %S:",iInterfaceName);	
   266 	iCurrentAlternateInterfaceSetting = aAlternateInterfaceSetting;
   282 	iCurrentAlternateInterfaceSetting = aAlternateInterfaceSetting;
       
   283 	OstTraceFunctionExit1( CINTERFACEBASE_ALTERNATEINTERFACESELECTEDL_EXIT, this );
   267 	}
   284 	}
   268 
   285 
   269 
   286 
   270 TInt CInterfaceBase::ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex,
   287 TInt CInterfaceBase::ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex,
   271 	TUint16 aDataReqLength,const TDesC8& aPayload)
   288 	TUint16 aDataReqLength,const TDesC8& aPayload)
   272 	{
   289 	{
   273 	LOG_FUNC
   290 	OstTraceFunctionEntryExt( CINTERFACEBASE_PROCESSREQUESTL_ENTRY, this );
   274 	RDebug::Printf("Interface %S:",&iInterfaceName);
   291 	OstTraceExt1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL, "Interface %S:",iInterfaceName);
   275 	
   292 	
   276 	switch(aRequest)
   293 	switch(aRequest)
   277 		{
   294 		{
   278 		case KVendorEmptyRequest:
   295 		case KVendorEmptyRequest:
   279 			// Acknowledge the request and do nothing
   296 			// Acknowledge the request and do nothing
   280 			iEp0Reader->Acknowledge();
   297 			iEp0Reader->Acknowledge();
   281 			
   298 			
   282 			RDebug::Printf("Request: Empty");
   299 			OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP01, "Request: Empty");
   283 			break;
   300 			break;
   284 			
   301 			
   285 		case KVendorPutPayloadRequest:
   302 		case KVendorPutPayloadRequest:
   286 			// Acknowledge the request
   303 			// Acknowledge the request
   287 			iEp0Reader->Acknowledge();
   304 			iEp0Reader->Acknowledge();
   288 			
   305 			
   289 			RDebug::Printf("Put payload");
   306 			OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP02, "Put payload");
   290 			if(aPayload.Compare(_L8("DEADBEEF")) != 0)
   307 			if(aPayload.Compare(_L8("DEADBEEF")) != 0)
   291 				{
   308 				{
   292 				RDebug::Printf("<Error %d> Payload not as expected",KErrCorrupt);
   309 				OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP03, "<Error %d> Payload not as expected",KErrCorrupt);
   293 				iDevice.ReportError(KErrCorrupt);
   310 				iDevice.ReportError(KErrCorrupt);
   294 				}
   311 				}
   295 			break;
   312 			break;
   296 			
   313 			
   297 		case KVendorGetPayloadRequest:
   314 		case KVendorGetPayloadRequest:
   298 			{
   315 			{
   299 			RDebug::Printf("Get payload");
   316 			OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP04, "Get payload");
   300 			__ASSERT_DEBUG(iAuxBuffer, User::Panic(_L("Trying to write non-allocated buffer"), KErrGeneral));
   317 			__ASSERT_DEBUG(iAuxBuffer, User::Panic(_L("Trying to write non-allocated buffer"), KErrGeneral));
   301 			RDebug::Printf("iAuxBuffer = ....");
   318 			OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP05, "iAuxBuffer = ....");
   302 			RDebug::RawPrint(*iAuxBuffer);
   319             OstTraceData(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP55, "", iAuxBuffer->Ptr(), iAuxBuffer->Length());
   303 			RDebug::Printf("\n");
   320 			OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP06, "\n");
   304 			
   321 			
   305 			//Perform synchronous write to EP0
   322 			//Perform synchronous write to EP0
   306 			//This allows the subsequent 'Read' request to
   323 			//This allows the subsequent 'Read' request to
   307 			//take place
   324 			//take place
   308 			TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue);
   325 			TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue);
   309 			RDebug::Printf("Write (from interface callback) executed with error %d", ret);
   326 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP07, "Write (from interface callback) executed with error %d", ret);
   310 			}
   327 			}
   311 			break;
   328 			break;
   312 			
   329 			
   313 		case KVendorGetRecordedNumBytesReadInPayloadRequest:
   330 		case KVendorGetRecordedNumBytesReadInPayloadRequest:
   314 			{
   331 			{
   322 	
   339 	
   323 			//Perform synchronous write to EP0
   340 			//Perform synchronous write to EP0
   324 			//This allows the subsequent 'Read' request to
   341 			//This allows the subsequent 'Read' request to
   325 			//take place
   342 			//take place
   326 			TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue);
   343 			TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue);
   327 			RDebug::Printf("Write (from interface callback) executed with error %d", ret);
   344 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP08, "Write (from interface callback) executed with error %d", ret);
   328 			}
   345 			}
   329 			break;
   346 			break;
   330 			
   347 			
   331 		case KVendorGetRecordedNumBytesWrittenInPayloadRequest:
   348 		case KVendorGetRecordedNumBytesWrittenInPayloadRequest:
   332 			{
   349 			{
   340 	
   357 	
   341 			//Perform synchronous write to EP0
   358 			//Perform synchronous write to EP0
   342 			//This allows the subsequent 'Read' request to
   359 			//This allows the subsequent 'Read' request to
   343 			//take place
   360 			//take place
   344 			TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue);
   361 			TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue);
   345 			RDebug::Printf("Write (from interface callback) executed with error %d", ret);
   362 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP09, "Write (from interface callback) executed with error %d", ret);
   346 			}
   363 			}
   347 			break;
   364 			break;
   348 			
   365 			
   349 		case KVendorWriteToEndpointRequest:
   366 		case KVendorWriteToEndpointRequest:
   350 			// Acknowledge the request
   367 			// Acknowledge the request
   351 			iEp0Reader->Acknowledge();
   368 			iEp0Reader->Acknowledge();
   352 			
   369 			
   353 			RDebug::Printf("Writing %d bytes to IN endpoint (index %d)",aPayload.Length(),aValue);
   370 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP10, "Writing %d bytes to IN endpoint (index %d)",aPayload.Length(),aValue);
   354 			
   371 			
   355 			// Write the data supplied by the host, back to the host though the specified endpoint
   372 			// Write the data supplied by the host, back to the host though the specified endpoint
   356 			
   373 			
   357 			AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSpecifiedDataToEndpointL(aPayload,aValue);
   374 			AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSpecifiedDataToEndpointL(aPayload,aValue);
   358 			break;
   375 			break;
   359 			
   376 			
   360 		case KVendorCancelWriteToEndpointRequest:
   377 		case KVendorCancelWriteToEndpointRequest:
   361 			// Acknowledge the request
   378 			// Acknowledge the request
   362 			iEp0Reader->Acknowledge();
   379 			iEp0Reader->Acknowledge();
   363 			
   380 			
   364 			RDebug::Printf("CANCEL Writing to IN endpoint (index %d)",aValue);
   381 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP11, "CANCEL Writing to IN endpoint (index %d)",aValue);
   365 			
   382 			
   366 			// CANCEL writing the data supplied by the host, back to the host though the specified endpoint
   383 			// CANCEL writing the data supplied by the host, back to the host though the specified endpoint
   367 			
   384 			
   368 			AlternateSetting(iCurrentAlternateInterfaceSetting).CancelWriteDataToEndpointL(aValue);
   385 			AlternateSetting(iCurrentAlternateInterfaceSetting).CancelWriteDataToEndpointL(aValue);
   369 			break;
   386 			break;
   414 			
   431 			
   415 			// Read the number of bytes to read in total and per individual 'Read' together with the data supplied by the host, on the specified endpoint
   432 			// Read the number of bytes to read in total and per individual 'Read' together with the data supplied by the host, on the specified endpoint
   416 			TUint32 numBytesPerRead = 0;
   433 			TUint32 numBytesPerRead = 0;
   417 			TUint32 totalNumBytes = 0;
   434 			TUint32 totalNumBytes = 0;
   418 			ExtractTwoNumbersL(aPayload, numBytesPerRead, totalNumBytes);
   435 			ExtractTwoNumbersL(aPayload, numBytesPerRead, totalNumBytes);
   419 			RDebug::Printf("Extracted: Number of Bytes per Read = %d, Total Number of Bytes = %d",numBytesPerRead,totalNumBytes);
   436 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP12, "Extracted: Number of Bytes per Read = %d, Total Number of Bytes = %d",numBytesPerRead,totalNumBytes);
   420 			
   437 			
   421 			// Write the data supplied by the host, back to the host though the specified endpoint
   438 			// Write the data supplied by the host, back to the host though the specified endpoint
   422 			AlternateSetting(iCurrentAlternateInterfaceSetting).RepeatedReadAndValidateFromEndpointL(aPayload.Mid(KTwoNumberStringLength),numBytesPerRead,totalNumBytes,aValue);
   439 			AlternateSetting(iCurrentAlternateInterfaceSetting).RepeatedReadAndValidateFromEndpointL(aPayload.Mid(KTwoNumberStringLength),numBytesPerRead,totalNumBytes,aValue);
   423 			}
   440 			}
   424 			break;
   441 			break;
   430 			
   447 			
   431 			// Read the number of bytes to write in total and per individual 'Write' together with the data supplied by the host, on the specified endpoint
   448 			// Read the number of bytes to write in total and per individual 'Write' together with the data supplied by the host, on the specified endpoint
   432 			TUint32 numBytesPerWrite = 0;
   449 			TUint32 numBytesPerWrite = 0;
   433 			TUint32 totalNumBytes = 0;
   450 			TUint32 totalNumBytes = 0;
   434 			ExtractTwoNumbersL(aPayload, numBytesPerWrite, totalNumBytes);
   451 			ExtractTwoNumbersL(aPayload, numBytesPerWrite, totalNumBytes);
   435 			RDebug::Printf("Extracted: Number of Bytes per Read = %d, Total Number of Bytes = %d",numBytesPerWrite,totalNumBytes);
   452 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP13, "Extracted: Number of Bytes per Read = %d, Total Number of Bytes = %d",numBytesPerWrite,totalNumBytes);
   436 			
   453 			
   437 			// Write the data supplied by the host, back to the host though the specified endpoint
   454 			// Write the data supplied by the host, back to the host though the specified endpoint
   438 			AlternateSetting(iCurrentAlternateInterfaceSetting).RepeatedWriteSpecifiedDataToEndpointL(aPayload.Mid(KTwoNumberStringLength),numBytesPerWrite,totalNumBytes,aValue);
   455 			AlternateSetting(iCurrentAlternateInterfaceSetting).RepeatedWriteSpecifiedDataToEndpointL(aPayload.Mid(KTwoNumberStringLength),numBytesPerWrite,totalNumBytes,aValue);
   439 			}
   456 			}
   440 			break;
   457 			break;
   445 			iEp0Reader->Acknowledge();
   462 			iEp0Reader->Acknowledge();
   446 			
   463 			
   447 			TUint16 readEndpoint = aValue >> 8; //HI 8 buts
   464 			TUint16 readEndpoint = aValue >> 8; //HI 8 buts
   448 			TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits
   465 			TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits
   449 			
   466 			
   450 			RDebug::Printf("Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d)",readEndpoint,writeEndpoint);
   467 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP14, "Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d)",readEndpoint,writeEndpoint);
   451 			
   468 			
   452 			// Write the data supplied by the host, back to the host though the specified endpoint
   469 			// Write the data supplied by the host, back to the host though the specified endpoint
   453 			
   470 			
   454 			AlternateSetting(iCurrentAlternateInterfaceSetting).WriteCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint);
   471 			AlternateSetting(iCurrentAlternateInterfaceSetting).WriteCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint);
   455 			}
   472 			}
   461 			iEp0Reader->Acknowledge();
   478 			iEp0Reader->Acknowledge();
   462 			
   479 			
   463 			TUint16 readEndpoint = aValue >> 8; //HI 8 buts
   480 			TUint16 readEndpoint = aValue >> 8; //HI 8 buts
   464 			TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits
   481 			TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits
   465 			
   482 			
   466 			RDebug::Printf("Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d)",readEndpoint,writeEndpoint);
   483 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP15, "Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d)",readEndpoint,writeEndpoint);
   467 			
   484 			
   468 			// Write the data supplied by the host, back to the host though the specified endpoint
   485 			// Write the data supplied by the host, back to the host though the specified endpoint
   469 			
   486 			
   470 			AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint);
   487 			AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint);
   471 			}
   488 			}
   476 			// Acknowledge the request
   493 			// Acknowledge the request
   477 			iEp0Reader->Acknowledge();
   494 			iEp0Reader->Acknowledge();
   478 			
   495 			
   479 			TUint16 readEndpoint = aValue >> 8; //HI 8 buts
   496 			TUint16 readEndpoint = aValue >> 8; //HI 8 buts
   480 			TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits
   497 			TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits
   481 			RDebug::Printf("Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d) in sections of....",readEndpoint,writeEndpoint);
   498 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP16, "Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d) in sections of....",readEndpoint,writeEndpoint);
   482 			
   499 			
   483 			// Read the number of bytes to use for each Write
   500 			// Read the number of bytes to use for each Write
   484 			TUint numBytes[KNumSplitWriteSections];
   501 			TUint numBytes[KNumSplitWriteSections];
   485 			TUint numBytesWritten = 0;
   502 			TUint numBytesWritten = 0;
   486 			for(TUint i=0; i<KNumSplitWriteSections; ++i)
   503 			for(TUint i=0; i<KNumSplitWriteSections; ++i)
   487 				{
   504 				{
   488 				TLex8 lex(aPayload.Mid(i*KNumberStringLength, KNumberStringLength));
   505 				TLex8 lex(aPayload.Mid(i*KNumberStringLength, KNumberStringLength));
   489 				User::LeaveIfError(lex.Val(numBytes[i], EDecimal));
   506 				User::LeaveIfError(lex.Val(numBytes[i], EDecimal));
   490 				RDebug::Printf("%d bytes", numBytes[i]);
   507 				OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP17, "%d bytes", numBytes[i]);
   491 				// Write the data supplied by the host, back to the host though the specified endpoint
   508 				// Write the data supplied by the host, back to the host though the specified endpoint
   492 				AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint,numBytesWritten,numBytes[i]);
   509 				AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint,numBytesWritten,numBytes[i]);
   493 				// Updates bytes written for next round of 'for'loop
   510 				// Updates bytes written for next round of 'for'loop
   494 				numBytesWritten += numBytes[i];
   511 				numBytesWritten += numBytes[i];
   495 				}
   512 				}
   503 			
   520 			
   504 			// Read the amount of data supplied by the host, on the specified endpoint
   521 			// Read the amount of data supplied by the host, on the specified endpoint
   505 			TLex8 lex(aPayload);
   522 			TLex8 lex(aPayload);
   506 			TUint32 numBytes;
   523 			TUint32 numBytes;
   507 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   524 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   508 			RDebug::Printf("Reading %d bytes on OUT endpoint (index %d)",numBytes,aValue);
   525 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP18, "Reading %u bytes on OUT endpoint (index %u)",numBytes,(TUint32)aValue);
   509 			AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataFromEndpointL(numBytes,aValue);
   526 			AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataFromEndpointL(numBytes,aValue);
   510 			}
   527 			}
   511 			break;
   528 			break;
   512 			
   529 			
   513 		case KVendorReadFromAndHaltEndpointRequest:
   530 		case KVendorReadFromAndHaltEndpointRequest:
   517 			
   534 			
   518 			// Read the amount of data supplied by the host, on the specified endpoint
   535 			// Read the amount of data supplied by the host, on the specified endpoint
   519 			TLex8 lex(aPayload);
   536 			TLex8 lex(aPayload);
   520 			TUint32 numBytes;
   537 			TUint32 numBytes;
   521 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   538 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   522 			RDebug::Printf("Reading %d bytes on OUT endpoint (index %d) ... then halting endpoint",numBytes,aValue);
   539 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP19, "Reading %u bytes on OUT endpoint (index %u) ... then halting endpoint",numBytes,(TUint32)aValue);
   523 			AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataFromAndHaltEndpointL(numBytes,aValue);
   540 			AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataFromAndHaltEndpointL(numBytes,aValue);
   524 			}
   541 			}
   525 			break;
   542 			break;
   526 			
   543 			
   527 		case KVendorCancelAnyReadFromEndpointRequest:
   544 		case KVendorCancelAnyReadFromEndpointRequest:
   528 			{
   545 			{
   529 			// Acknowledge the request
   546 			// Acknowledge the request
   530 			iEp0Reader->Acknowledge();
   547 			iEp0Reader->Acknowledge();
   531 			
   548 			
   532 			RDebug::Printf("CANCEL Reading on OUT endpoint (index %d)",aValue);
   549 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP20, "CANCEL Reading on OUT endpoint (index %u)",(TUint32)aValue);
   533 			AlternateSetting(iCurrentAlternateInterfaceSetting).CancelAnyReadDataFromEndpointL(aValue);
   550 			AlternateSetting(iCurrentAlternateInterfaceSetting).CancelAnyReadDataFromEndpointL(aValue);
   534 			}
   551 			}
   535 			break;
   552 			break;
   536 			
   553 			
   537 		case KVendorReadUntilShortFromEndpointRequest:
   554 		case KVendorReadUntilShortFromEndpointRequest:
   541 			
   558 			
   542 			// Read the amount of data supplied by the host, on the specified endpoint
   559 			// Read the amount of data supplied by the host, on the specified endpoint
   543 			TLex8 lex(aPayload);
   560 			TLex8 lex(aPayload);
   544 			TUint32 numBytes;
   561 			TUint32 numBytes;
   545 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   562 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   546 			RDebug::Printf("Reading %d bytes on OUT endpoint (index %d)",numBytes,aValue);
   563 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP21, "Reading %u bytes on OUT endpoint (index %u)",numBytes,(TUint32)aValue);
   547 			AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataUntilShortFromEndpointL(numBytes,aValue);
   564 			AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataUntilShortFromEndpointL(numBytes,aValue);
   548 			}
   565 			}
   549 			break;
   566 			break;
   550 			
   567 			
   551 		case KVendorStringValidationRequest:
   568 		case KVendorStringValidationRequest:
   553 			// Acknowledge the request
   570 			// Acknowledge the request
   554 			iEp0Reader->Acknowledge();
   571 			iEp0Reader->Acknowledge();
   555 			
   572 			
   556 			// Read the number of repeats and the data supplied by the host, on the specified endpoint
   573 			// Read the number of repeats and the data supplied by the host, on the specified endpoint
   557 			TLex8 lex(aPayload.Left(KNumberStringLength));
   574 			TLex8 lex(aPayload.Left(KNumberStringLength));
   558 			RDebug::Printf("NUMBER STRING LENGTH CALCULATED AS %d",KNumberStringLength);
   575 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP22, "NUMBER STRING LENGTH CALCULATED AS %d",KNumberStringLength);
   559 			TUint32 numBytes;
   576 			TUint32 numBytes;
   560 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   577 			User::LeaveIfError(lex.Val(numBytes, EDecimal));
   561 			RDebug::Printf("Validation");
   578 			OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP23, "Validation");
   562 			RDebug::Printf("Checking %d bytes using string pattern below exist in the buffer for endpoint %d",numBytes,aValue);
   579 			OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP24, "Checking %u bytes using string pattern below exist in the buffer for endpoint %u",numBytes,(TUint32)aValue);
   563 			RDebug::RawPrint(aPayload.Mid(KNumberStringLength));
   580             const TPtrC8& midPayload = aPayload.Mid(KNumberStringLength);
       
   581             OstTraceData(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP54, "", midPayload.Ptr(), midPayload.Length());
   564 			
   582 			
   565 			delete iAuxBuffer;
   583 			delete iAuxBuffer;
   566 			iAuxBuffer = HBufC8::NewL(KPassFailStringLength);
   584 			iAuxBuffer = HBufC8::NewL(KPassFailStringLength);
   567 			TPtr8 ptr(iAuxBuffer->Des());
   585 			TPtr8 ptr(iAuxBuffer->Des());
   568 			if(AlternateSetting(iCurrentAlternateInterfaceSetting).ValidateCachedEndpointDataL(aPayload.Mid(KNumberStringLength),numBytes,aValue))
   586 			if(AlternateSetting(iCurrentAlternateInterfaceSetting).ValidateCachedEndpointDataL(aPayload.Mid(KNumberStringLength),numBytes,aValue))
   596 			break;
   614 			break;
   597 			
   615 			
   598 		case KVendorUnrespondRequest:
   616 		case KVendorUnrespondRequest:
   599 			// Do not acknowledge this request
   617 			// Do not acknowledge this request
   600 			
   618 			
   601 			RDebug::Printf("Unrespond request: continually NAK the host");
   619 			OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP25, "Unrespond request: continually NAK the host");
   602 			break;
   620 			break;
   603 			
   621 			
   604 		case KVendorStallRequest:
   622 		case KVendorStallRequest:
   605 			{
   623 			{
   606 			// Stall the specified endpoint		
   624 			// Stall the specified endpoint		
   607 			iEp0Reader->Acknowledge();
   625 			iEp0Reader->Acknowledge();
   608 			RDebug::Printf("Stalling endpoint%d",aValue);
   626 			OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP26, "Stalling endpoint%d",aValue);
   609 			TInt err = StallEndpoint(aValue);
   627 			TInt err = StallEndpoint(aValue);
   610 			if(err != KErrNone)
   628 			if(err != KErrNone)
   611 				{
   629 				{
   612 				RDebug::Printf("<Error %d> unable to stall endpoint index %d",err,aValue);
   630 				OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP27, "<Error %d> unable to stall endpoint index %d",err,aValue);
   613 				iDevice.ReportError(err);
   631 				iDevice.ReportError(err);
   614 				}
   632 				}
   615 			}
   633 			}
   616 
   634 
   617 		default:
   635 		default:
   618 			// Maybe forward to derived classes
   636 			// Maybe forward to derived classes
   619 			break;
   637 			break;
   620 		}
   638 		}
   621 
   639 
       
   640 	OstTraceFunctionExitExt( CINTERFACEBASE_PROCESSREQUESTL_EXIT, this, KErrNone );
   622 	return KErrNone;
   641 	return KErrNone;
   623 	}
   642 	}
   624 	
   643 	
   625 
   644 
   626 void CInterfaceBase::StartEp0Reading()
   645 void CInterfaceBase::StartEp0Reading()
   627 	{
   646 	{
   628 	LOG_FUNC
   647 	OstTraceFunctionEntry1( CINTERFACEBASE_STARTEP0READING_ENTRY, this );
   629 	
   648 	
   630 	iEp0Reader->ReadRequestsL();
   649 	iEp0Reader->ReadRequestsL();
       
   650 	OstTraceFunctionExit1( CINTERFACEBASE_STARTEP0READING_EXIT, this );
   631 	}
   651 	}
   632 	
   652 	
   633 
   653 
   634 void CInterfaceBase::StopEp0Reading()
   654 void CInterfaceBase::StopEp0Reading()
   635 	{
   655 	{
   636 	LOG_FUNC
   656 	OstTraceFunctionEntry1( CINTERFACEBASE_STOPEP0READING_ENTRY, this );
   637 	
   657 	
   638 	iEp0Reader->Cancel();		
   658 	iEp0Reader->Cancel();		
   639 	}
   659 	OstTraceFunctionExit1( CINTERFACEBASE_STOPEP0READING_EXIT, this );
   640 
   660 	}
   641 	}
   661 
   642 
   662 	}
   643 
   663 
       
   664