sl@0
|
1 |
#ifndef __TEST_INTERFACE_BASE_H
|
sl@0
|
2 |
#define __TEST_INTERFACE_BASE_H
|
sl@0
|
3 |
|
sl@0
|
4 |
/*
|
sl@0
|
5 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
6 |
* All rights reserved.
|
sl@0
|
7 |
* This component and the accompanying materials are made available
|
sl@0
|
8 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
9 |
* which accompanies this distribution, and is available
|
sl@0
|
10 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Initial Contributors:
|
sl@0
|
13 |
* Nokia Corporation - initial contribution.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* Contributors:
|
sl@0
|
16 |
*
|
sl@0
|
17 |
* Description:
|
sl@0
|
18 |
* @file testinterfacebase.h
|
sl@0
|
19 |
* @internalComponent
|
sl@0
|
20 |
*
|
sl@0
|
21 |
*
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#include <e32base.h>
|
sl@0
|
27 |
#include "usbclientstatewatcher.h"
|
sl@0
|
28 |
#include "controlendpointreader.h"
|
sl@0
|
29 |
#include "endpointwriter.h"
|
sl@0
|
30 |
#include "endpointstallwatcher.h"
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
namespace NUnitTesting_USBDI
|
sl@0
|
34 |
{
|
sl@0
|
35 |
|
sl@0
|
36 |
// Forward declarations
|
sl@0
|
37 |
|
sl@0
|
38 |
class RUsbTestDevice;
|
sl@0
|
39 |
class CInterfaceSettingBase;
|
sl@0
|
40 |
|
sl@0
|
41 |
/**
|
sl@0
|
42 |
This class represents a test USB interface for the test USB device
|
sl@0
|
43 |
|
sl@0
|
44 |
*/
|
sl@0
|
45 |
class CInterfaceBase : public CBase, public MAlternateSettingObserver, public MRequestHandler
|
sl@0
|
46 |
{
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
Constructor, build an interface for a USB modelled device
|
sl@0
|
50 |
@param aTestDevice the device that this is an interface for
|
sl@0
|
51 |
@param aName the name given to the interface
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
|
sl@0
|
54 |
CInterfaceBase(RUsbTestDevice& aTestDevice,const TDesC16& aName);
|
sl@0
|
55 |
|
sl@0
|
56 |
/**
|
sl@0
|
57 |
Base class 2nd phase construction
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
|
sl@0
|
60 |
void BaseConstructL();
|
sl@0
|
61 |
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
Destructor
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
|
sl@0
|
66 |
virtual ~CInterfaceBase();
|
sl@0
|
67 |
|
sl@0
|
68 |
/**
|
sl@0
|
69 |
Adds an alternate interface setting for this interface
|
sl@0
|
70 |
@param aInterface an alternate interface setting associated with this interface
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
|
sl@0
|
73 |
void AddInterfaceSettingL(CInterfaceSettingBase* aInterfaceSetting);
|
sl@0
|
74 |
|
sl@0
|
75 |
/**
|
sl@0
|
76 |
Accesses an alternate interface setting with the specified setting number
|
sl@0
|
77 |
@param aSettingNumber the alternate interface setting number
|
sl@0
|
78 |
@return a referrence to the alternate setting
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
|
sl@0
|
81 |
CInterfaceSettingBase& AlternateSetting(TInt aSettingNumber) const;
|
sl@0
|
82 |
|
sl@0
|
83 |
/**
|
sl@0
|
84 |
Query the number of alternate interface settings for this interface
|
sl@0
|
85 |
@return the number of alternate interface settings
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
|
sl@0
|
88 |
TInt InterfaceSettingCount() const;
|
sl@0
|
89 |
|
sl@0
|
90 |
/**
|
sl@0
|
91 |
Start the interface reading interface directed control transfers on endpoint 0
|
sl@0
|
92 |
*/
|
sl@0
|
93 |
|
sl@0
|
94 |
void StartEp0Reading();
|
sl@0
|
95 |
|
sl@0
|
96 |
/**
|
sl@0
|
97 |
Stop the interface from reading interface directed control transfers on endpoint 0
|
sl@0
|
98 |
*/
|
sl@0
|
99 |
|
sl@0
|
100 |
void StopEp0Reading();
|
sl@0
|
101 |
|
sl@0
|
102 |
/**
|
sl@0
|
103 |
Stall the specified endpoint
|
sl@0
|
104 |
@param aEndpointNumber the endpoint to stall
|
sl@0
|
105 |
@return KErrNone if successful
|
sl@0
|
106 |
*/
|
sl@0
|
107 |
|
sl@0
|
108 |
TInt StallEndpoint(TUint16 aEndpointNumber);
|
sl@0
|
109 |
|
sl@0
|
110 |
public: // From MAlternateSettingObserver
|
sl@0
|
111 |
|
sl@0
|
112 |
/**
|
sl@0
|
113 |
Get notification when the host selects an alternate interface setting on this interface
|
sl@0
|
114 |
@param aAlternateInterfaceSetting the alternate interface setting number
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
virtual void AlternateInterfaceSelectedL(TInt aAlternateInterfaceSetting);
|
sl@0
|
117 |
|
sl@0
|
118 |
public: // From MEndpointDataHandler
|
sl@0
|
119 |
|
sl@0
|
120 |
/**
|
sl@0
|
121 |
Process any Ep0 control transfer requests that are interface directed
|
sl@0
|
122 |
@param aRequest the request number (id)
|
sl@0
|
123 |
@param aValue the parameter to the request
|
sl@0
|
124 |
@param aIndex the interface number that the request is directed at
|
sl@0
|
125 |
@param aDataReqLength the data size in the transfer DATA1 packet(s)
|
sl@0
|
126 |
@param aPayload the request content data (i.e. all the data from DATA1 packets)
|
sl@0
|
127 |
*/
|
sl@0
|
128 |
virtual TInt ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex,TUint16 aDataReqLength,const TDesC8& aPayload);
|
sl@0
|
129 |
|
sl@0
|
130 |
private:
|
sl@0
|
131 |
TUint32 ExtractNumberL(const TDesC8& aPayload);
|
sl@0
|
132 |
void ExtractTwoNumbersL(const TDesC8& aPayload, TUint32& aFirstNum, TUint32& aSecondNum);
|
sl@0
|
133 |
|
sl@0
|
134 |
private:
|
sl@0
|
135 |
/**
|
sl@0
|
136 |
The test device object that owns this interface
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
RUsbTestDevice& iDevice;
|
sl@0
|
139 |
|
sl@0
|
140 |
/**
|
sl@0
|
141 |
The USB client driver
|
sl@0
|
142 |
Only use interface related API
|
sl@0
|
143 |
*/
|
sl@0
|
144 |
RDevUsbcClient iClientDriver;
|
sl@0
|
145 |
|
sl@0
|
146 |
/**
|
sl@0
|
147 |
The alternate settings for this interface
|
sl@0
|
148 |
*/
|
sl@0
|
149 |
RPointerArray<CInterfaceSettingBase> iAlternateSettings;
|
sl@0
|
150 |
|
sl@0
|
151 |
/**
|
sl@0
|
152 |
The watcher of alternate interface selection by host
|
sl@0
|
153 |
*/
|
sl@0
|
154 |
CAlternateInterfaceSelectionWatcher* iSelectionWatcher;
|
sl@0
|
155 |
|
sl@0
|
156 |
/**
|
sl@0
|
157 |
The watcher of endpoint stalling
|
sl@0
|
158 |
*/
|
sl@0
|
159 |
CEndpointStallWatcher* iStallWatcher;
|
sl@0
|
160 |
|
sl@0
|
161 |
/**
|
sl@0
|
162 |
The reader of interface control endpoint 0
|
sl@0
|
163 |
*/
|
sl@0
|
164 |
CControlEndpointReader* iEp0Reader;
|
sl@0
|
165 |
|
sl@0
|
166 |
/**
|
sl@0
|
167 |
The writer of interface control endpoint 0
|
sl@0
|
168 |
*/
|
sl@0
|
169 |
CEndpointWriter* iEp0Writer;
|
sl@0
|
170 |
|
sl@0
|
171 |
/**
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
TBuf16<64> iInterfaceName;
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
An Auxiliary buffer, to be used for anything temporary
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
HBufC8* iAuxBuffer;
|
sl@0
|
179 |
|
sl@0
|
180 |
/**
|
sl@0
|
181 |
The current alternate interface setting that is selected (defaults to zero)
|
sl@0
|
182 |
*/
|
sl@0
|
183 |
TInt iCurrentAlternateInterfaceSetting;
|
sl@0
|
184 |
};
|
sl@0
|
185 |
|
sl@0
|
186 |
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
#endif
|
sl@0
|
190 |
|