First public contribution.
1 #ifndef __TEST_INTERFACE_BASE_H
2 #define __TEST_INTERFACE_BASE_H
5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
7 * This component and the accompanying materials are made available
8 * under the terms of the License "Eclipse Public License v1.0"
9 * which accompanies this distribution, and is available
10 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
12 * Initial Contributors:
13 * Nokia Corporation - initial contribution.
18 * @file testinterfacebase.h
27 #include "usbclientstatewatcher.h"
28 #include "controlendpointreader.h"
29 #include "endpointwriter.h"
30 #include "endpointstallwatcher.h"
33 namespace NUnitTesting_USBDI
36 // Forward declarations
39 class CInterfaceSettingBase;
42 This class represents a test USB interface for the test USB device
45 class CInterfaceBase : public CBase, public MAlternateSettingObserver, public MRequestHandler
49 Constructor, build an interface for a USB modelled device
50 @param aTestDevice the device that this is an interface for
51 @param aName the name given to the interface
54 CInterfaceBase(RUsbTestDevice& aTestDevice,const TDesC16& aName);
57 Base class 2nd phase construction
60 void BaseConstructL();
66 virtual ~CInterfaceBase();
69 Adds an alternate interface setting for this interface
70 @param aInterface an alternate interface setting associated with this interface
73 void AddInterfaceSettingL(CInterfaceSettingBase* aInterfaceSetting);
76 Accesses an alternate interface setting with the specified setting number
77 @param aSettingNumber the alternate interface setting number
78 @return a referrence to the alternate setting
81 CInterfaceSettingBase& AlternateSetting(TInt aSettingNumber) const;
84 Query the number of alternate interface settings for this interface
85 @return the number of alternate interface settings
88 TInt InterfaceSettingCount() const;
91 Start the interface reading interface directed control transfers on endpoint 0
94 void StartEp0Reading();
97 Stop the interface from reading interface directed control transfers on endpoint 0
100 void StopEp0Reading();
103 Stall the specified endpoint
104 @param aEndpointNumber the endpoint to stall
105 @return KErrNone if successful
108 TInt StallEndpoint(TUint16 aEndpointNumber);
110 public: // From MAlternateSettingObserver
113 Get notification when the host selects an alternate interface setting on this interface
114 @param aAlternateInterfaceSetting the alternate interface setting number
116 virtual void AlternateInterfaceSelectedL(TInt aAlternateInterfaceSetting);
118 public: // From MEndpointDataHandler
121 Process any Ep0 control transfer requests that are interface directed
122 @param aRequest the request number (id)
123 @param aValue the parameter to the request
124 @param aIndex the interface number that the request is directed at
125 @param aDataReqLength the data size in the transfer DATA1 packet(s)
126 @param aPayload the request content data (i.e. all the data from DATA1 packets)
128 virtual TInt ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex,TUint16 aDataReqLength,const TDesC8& aPayload);
131 TUint32 ExtractNumberL(const TDesC8& aPayload);
132 void ExtractTwoNumbersL(const TDesC8& aPayload, TUint32& aFirstNum, TUint32& aSecondNum);
136 The test device object that owns this interface
138 RUsbTestDevice& iDevice;
141 The USB client driver
142 Only use interface related API
144 RDevUsbcClient iClientDriver;
147 The alternate settings for this interface
149 RPointerArray<CInterfaceSettingBase> iAlternateSettings;
152 The watcher of alternate interface selection by host
154 CAlternateInterfaceSelectionWatcher* iSelectionWatcher;
157 The watcher of endpoint stalling
159 CEndpointStallWatcher* iStallWatcher;
162 The reader of interface control endpoint 0
164 CControlEndpointReader* iEp0Reader;
167 The writer of interface control endpoint 0
169 CEndpointWriter* iEp0Writer;
173 TBuf16<64> iInterfaceName;
176 An Auxiliary buffer, to be used for anything temporary
181 The current alternate interface setting that is selected (defaults to zero)
183 TInt iCurrentAlternateInterfaceSetting;