kerneltest/e32test/usbho/t_usbdi/src/controlendpointreader.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".
    16 // 
    16 // 
    17 //
    17 //
    18 
    18 
    19 #include "controlendpointreader.h"
    19 #include "controlendpointreader.h"
    20 #include "testdebug.h"
    20 #include "testdebug.h"
       
    21 #include "OstTraceDefinitions.h"
       
    22 #ifdef OST_TRACE_COMPILER_IN_USE
       
    23 #include "controlendpointreaderTraces.h"
       
    24 #endif
    21 
    25 
    22 namespace NUnitTesting_USBDI
    26 namespace NUnitTesting_USBDI
    23 	{	
    27 	{	
    24 	
    28 	
    25 CControlEndpointReader::CControlEndpointReader(RDevUsbcClient& aClientDriver,MRequestHandler& aRequestHandler)
    29 CControlEndpointReader::CControlEndpointReader(RDevUsbcClient& aClientDriver,MRequestHandler& aRequestHandler)
    26 :	CEndpointReader(aClientDriver,EEndpoint0),
    30 :	CEndpointReader(aClientDriver,EEndpoint0),
    27 	iDeviceToHost(EFalse),
    31 	iDeviceToHost(EFalse),
    28 	iDataPhase(EFalse),
    32 	iDataPhase(EFalse),
    29 	iRequestHandler(aRequestHandler)
    33 	iRequestHandler(aRequestHandler)
    30 	{
    34 	{
       
    35 	OstTraceFunctionEntryExt( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_ENTRY, this );
       
    36 	OstTraceFunctionExit1( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_EXIT, this );
    31 	}
    37 	}
    32 	
    38 	
    33 	
    39 	
    34 CControlEndpointReader::~CControlEndpointReader()
    40 CControlEndpointReader::~CControlEndpointReader()
    35 	{
    41 	{
    36 	LOG_FUNC
    42 	OstTraceFunctionEntry1( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_ENTRY_DUP01, this );
       
    43 	OstTraceFunctionExit1( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_EXIT_DUP01, this );
    37 	}
    44 	}
    38 
    45 
    39 
    46 
    40 void CControlEndpointReader::ReadRequestsL()
    47 void CControlEndpointReader::ReadRequestsL()
    41 	{
    48 	{
    42 	LOG_FUNC
    49 	OstTraceFunctionEntry1( CCONTROLENDPOINTREADER_READREQUESTSL_ENTRY, this );
    43 	
    50 	
    44 	// Read a packet from endpoint 0 (this should incorporate a request)
    51 	// Read a packet from endpoint 0 (this should incorporate a request)
    45 	
    52 	
    46 	ReadPacketL(this);
    53 	ReadPacketL(this);
       
    54 	OstTraceFunctionExit1( CCONTROLENDPOINTREADER_READREQUESTSL_EXIT, this );
    47 	}
    55 	}
    48 	
    56 	
    49 
    57 
    50 void CControlEndpointReader::EndpointReadError(TEndpointNumber aEndpointNumber,TInt aErrorCode)
    58 void CControlEndpointReader::EndpointReadError(TEndpointNumber aEndpointNumber,TInt aErrorCode)
    51 	{
    59 	{
    52 	LOG_FUNC
    60 	OstTraceFunctionEntryExt( CCONTROLENDPOINTREADER_ENDPOINTREADERROR_ENTRY, this );
    53 	
    61 	
    54 	RDebug::Printf("<Error %d> Asynchronous read on endpoint %d",aErrorCode,aEndpointNumber);
    62 	OstTraceExt2(TRACE_NORMAL, CCONTROLENDPOINTREADER_ENDPOINTREADERROR, "<Error %d> Asynchronous read on endpoint %d",aErrorCode,aEndpointNumber);
       
    63 	OstTraceFunctionExit1( CCONTROLENDPOINTREADER_ENDPOINTREADERROR_EXIT, this );
    55 	}
    64 	}
    56 	
    65 	
    57 	
    66 	
    58 void CControlEndpointReader::DataReceivedFromEndpointL(TEndpointNumber aEndpointNumber,const TDesC8& aData)
    67 void CControlEndpointReader::DataReceivedFromEndpointL(TEndpointNumber aEndpointNumber,const TDesC8& aData)
    59 	{
    68 	{
    60 	LOG_FUNC
    69 	OstTraceFunctionEntryExt( CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_ENTRY, this );
    61 	
    70 	
    62 	RDebug::Printf("ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength);
    71 	OstTraceExt5(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL, "ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength);
    63 	RDebug::Printf("iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase);
    72 	OstTraceExt2(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP01, "iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase);
    64 	if(iDeviceToHost && iDataPhase)
    73 	if(iDeviceToHost && iDataPhase)
    65 		{
    74 		{
    66 		TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,aData);
    75 		TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,aData);
    67 		RDebug::Printf("ProdessRequestL returned %d",err);
    76 		OstTrace1(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP02, "ProdessRequestL returned %d",err);
    68 		
    77 		
    69 		if(err != KErrAbort)
    78 		if(err != KErrAbort)
    70 			{
    79 			{
    71 			iDeviceToHost = EFalse;
    80 			iDeviceToHost = EFalse;
    72 			iDataPhase = EFalse;
    81 			iDataPhase = EFalse;
   102 		
   111 		
   103 		iDataPhase = (iwLength > 0);
   112 		iDataPhase = (iwLength > 0);
   104 		
   113 		
   105 		// Read all information about the request sent by the host
   114 		// Read all information about the request sent by the host
   106 		// i.e. any DATA1 packets sent after the setup DATA0 packet
   115 		// i.e. any DATA1 packets sent after the setup DATA0 packet
   107 		RDebug::Printf("AFTER UPDATES");
   116 		OstTrace0(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP03, "AFTER UPDATES");
   108 		RDebug::Printf("ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength);
   117 		OstTraceExt5(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP04, "ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength);
   109 		RDebug::Printf("iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase);
   118 		OstTraceExt2(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP05, "iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase);
   110 		if(iDeviceToHost && iDataPhase)
   119 		if(iDeviceToHost && iDataPhase)
   111 			{
   120 			{
   112 			RDebug::Printf("Issuing another read of %d bytes",iwLength);
   121 			OstTrace1(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP06, "Issuing another read of %d bytes",iwLength);
   113 			ReadL(iwLength);
   122 			ReadL(iwLength);
   114 			}
   123 			}
   115 		else
   124 		else
   116 			{
   125 			{
   117 			TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,KNullDesC8);
   126 			TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,KNullDesC8);
   122 				// from the host
   131 				// from the host
   123 				ReadPacketL(this);
   132 				ReadPacketL(this);
   124 				}
   133 				}
   125 			}
   134 			}
   126 		}
   135 		}
       
   136 	OstTraceFunctionExit1( CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_EXIT, this );
   127 	}
   137 	}
   128 	
   138 	
   129 	
   139 	
   130 	}
   140 	}