Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // @file controlendpointreader.cpp
19 #include "controlendpointreader.h"
20 #include "testdebug.h"
22 namespace NUnitTesting_USBDI
25 CControlEndpointReader::CControlEndpointReader(RDevUsbcClient& aClientDriver,MRequestHandler& aRequestHandler)
26 : CEndpointReader(aClientDriver,EEndpoint0),
27 iDeviceToHost(EFalse),
29 iRequestHandler(aRequestHandler)
34 CControlEndpointReader::~CControlEndpointReader()
40 void CControlEndpointReader::ReadRequestsL()
44 // Read a packet from endpoint 0 (this should incorporate a request)
50 void CControlEndpointReader::EndpointReadError(TEndpointNumber aEndpointNumber,TInt aErrorCode)
54 RDebug::Printf("<Error %d> Asynchronous read on endpoint %d",aErrorCode,aEndpointNumber);
58 void CControlEndpointReader::DataReceivedFromEndpointL(TEndpointNumber aEndpointNumber,const TDesC8& aData)
62 RDebug::Printf("ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength);
63 RDebug::Printf("iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase);
64 if(iDeviceToHost && iDataPhase)
66 TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,aData);
67 RDebug::Printf("ProdessRequestL returned %d",err);
71 iDeviceToHost = EFalse;
74 // After processing the request keep reading for more requests
81 // Understand the setup packet
82 ibRequestType = aData[0];
83 iDeviceToHost = (ibRequestType & 0x80) == 0x00;
88 // The request parameter
89 TUint8* p = reinterpret_cast<TUint8*>(&iwValue);
93 // The index for the request
94 p = reinterpret_cast<TUint8*>(&iwIndex);
98 // The length of data transfer
99 p = reinterpret_cast<TUint8*>(&iwLength);
103 iDataPhase = (iwLength > 0);
105 // Read all information about the request sent by the host
106 // i.e. any DATA1 packets sent after the setup DATA0 packet
107 RDebug::Printf("AFTER UPDATES");
108 RDebug::Printf("ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength);
109 RDebug::Printf("iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase);
110 if(iDeviceToHost && iDataPhase)
112 RDebug::Printf("Issuing another read of %d bytes",iwLength);
117 TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,KNullDesC8);
121 // After processing the request keep reading for more requests