sl@0
|
1 |
#ifndef __FDF_ACTOR_H
|
sl@0
|
2 |
#define __FDF_ACTOR_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 FDFActor.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 <e32hashtab.h>
|
sl@0
|
28 |
#include <d32usbdescriptors.h>
|
sl@0
|
29 |
#include <d32usbdi_hubdriver.h>
|
sl@0
|
30 |
#include <d32usbdi.h>
|
sl@0
|
31 |
#include <d32otgdi.h>
|
sl@0
|
32 |
#include <e32test.h>
|
sl@0
|
33 |
|
sl@0
|
34 |
extern RTest gtest;
|
sl@0
|
35 |
|
sl@0
|
36 |
namespace NUnitTesting_USBDI
|
sl@0
|
37 |
{
|
sl@0
|
38 |
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
This class describes an observer for USB bus events reported from the acting
|
sl@0
|
41 |
Function Driver Framework (Hub Driver)
|
sl@0
|
42 |
*/
|
sl@0
|
43 |
class MUsbBusObserver
|
sl@0
|
44 |
{
|
sl@0
|
45 |
public:
|
sl@0
|
46 |
|
sl@0
|
47 |
/**
|
sl@0
|
48 |
Called when a usb client device was connected to the host and has a bus address
|
sl@0
|
49 |
@param aDeviceHandle the unique handle to the device
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
virtual void DeviceInsertedL(TUint aDeviceHandle) = 0;
|
sl@0
|
52 |
|
sl@0
|
53 |
/**
|
sl@0
|
54 |
Called when a previously connected usb device has disconnected from the bus
|
sl@0
|
55 |
@param aDeviceHandle the handle to the device that has just disconnected.
|
sl@0
|
56 |
This handle will (after this function) now be void
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
virtual void DeviceRemovedL(TUint aDeviceHandle) = 0;
|
sl@0
|
59 |
|
sl@0
|
60 |
/**
|
sl@0
|
61 |
Called when there has been a error on the bus as seen by the Hub Driver
|
sl@0
|
62 |
@param aError the bus error code
|
sl@0
|
63 |
*/
|
sl@0
|
64 |
virtual void BusErrorL(TInt aError) = 0;
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
Called when the device has changed state
|
sl@0
|
68 |
@param aPreviousState the previous state of the device
|
sl@0
|
69 |
@param aNewState the now new observerd state of the device
|
sl@0
|
70 |
@param aCompletionCode the comletion code of state change
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
virtual void DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState,
|
sl@0
|
73 |
TInt aCompletionCode) = 0;
|
sl@0
|
74 |
};
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
|
sl@0
|
78 |
|
sl@0
|
79 |
/**
|
sl@0
|
80 |
This class represents the host side object for a USB test device. This means a device that
|
sl@0
|
81 |
is connected to the bus.
|
sl@0
|
82 |
*/
|
sl@0
|
83 |
class CUsbTestDevice : public CActive
|
sl@0
|
84 |
{
|
sl@0
|
85 |
public:
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
Construct a USB bus connected device
|
sl@0
|
88 |
@param aHubDriver the USB hub driver object
|
sl@0
|
89 |
@param aDeviceHandle the unique handle value to the device
|
sl@0
|
90 |
@param aObserver the
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
static CUsbTestDevice* NewL(RUsbHubDriver& aHubDriver,TUint aDeviceHandle,MUsbBusObserver& aObserver);
|
sl@0
|
93 |
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
Destructor
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
~CUsbTestDevice();
|
sl@0
|
98 |
|
sl@0
|
99 |
/**
|
sl@0
|
100 |
Obtain the USB specification that this device complies to
|
sl@0
|
101 |
@return the usb compliance specification
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
TUint16 DeviceSpec() const;
|
sl@0
|
104 |
|
sl@0
|
105 |
/**
|
sl@0
|
106 |
Obtain the Identity of the product
|
sl@0
|
107 |
@return the product identity
|
sl@0
|
108 |
*/
|
sl@0
|
109 |
TUint16 ProductId() const;
|
sl@0
|
110 |
|
sl@0
|
111 |
/**
|
sl@0
|
112 |
Obtain the Identity of the vendor
|
sl@0
|
113 |
@return the vendor identity
|
sl@0
|
114 |
*/
|
sl@0
|
115 |
TUint16 VendorId() const;
|
sl@0
|
116 |
|
sl@0
|
117 |
/**
|
sl@0
|
118 |
Obtain the product string for the connected device
|
sl@0
|
119 |
@return the device's product string
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
const TDesC16& Product() const;
|
sl@0
|
122 |
|
sl@0
|
123 |
/**
|
sl@0
|
124 |
Obtani the configuration string for the connected device
|
sl@0
|
125 |
@return the device's configuration string
|
sl@0
|
126 |
*/
|
sl@0
|
127 |
const TDesC16& ConfigurationString() const;
|
sl@0
|
128 |
|
sl@0
|
129 |
/**
|
sl@0
|
130 |
Obtain the serial number of the connected device
|
sl@0
|
131 |
@return the device's serial number
|
sl@0
|
132 |
*/
|
sl@0
|
133 |
const TDesC16& SerialNumber() const;
|
sl@0
|
134 |
|
sl@0
|
135 |
/**
|
sl@0
|
136 |
Obtain the manufacturer of the connected device
|
sl@0
|
137 |
@return the manufacturer as string
|
sl@0
|
138 |
*/
|
sl@0
|
139 |
const TDesC16& Manufacturer() const;
|
sl@0
|
140 |
|
sl@0
|
141 |
/**
|
sl@0
|
142 |
Access the raw referrence to the USB device API object
|
sl@0
|
143 |
@return a referrence to the RUsbDevice object
|
sl@0
|
144 |
*/
|
sl@0
|
145 |
RUsbDevice& Device();
|
sl@0
|
146 |
|
sl@0
|
147 |
/**
|
sl@0
|
148 |
Access the device descriptor
|
sl@0
|
149 |
@return a referrence to the device descriptor
|
sl@0
|
150 |
*/
|
sl@0
|
151 |
const TUsbDeviceDescriptor& DeviceDescriptor() const;
|
sl@0
|
152 |
|
sl@0
|
153 |
/**
|
sl@0
|
154 |
Access the configuration descriptor
|
sl@0
|
155 |
@return a referrence to the configuration descriptor
|
sl@0
|
156 |
*/
|
sl@0
|
157 |
const TUsbConfigurationDescriptor& ConfigurationDescriptor() const;
|
sl@0
|
158 |
|
sl@0
|
159 |
|
sl@0
|
160 |
protected:
|
sl@0
|
161 |
|
sl@0
|
162 |
/**
|
sl@0
|
163 |
Constructor, build a host side usb test object
|
sl@0
|
164 |
@param aHubDriver the USB host hub driver
|
sl@0
|
165 |
@param aHandle the unique handle to the usb device
|
sl@0
|
166 |
@param aObserver the observer of usb host bus events
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
CUsbTestDevice(RUsbHubDriver& aHubDriver,TUint aHandle,MUsbBusObserver& aObserver);
|
sl@0
|
169 |
|
sl@0
|
170 |
/**
|
sl@0
|
171 |
2nd phase construction
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
void ConstructL();
|
sl@0
|
174 |
|
sl@0
|
175 |
protected: // From CActive
|
sl@0
|
176 |
|
sl@0
|
177 |
/**
|
sl@0
|
178 |
Cancels the current asynchronous activity of this test device
|
sl@0
|
179 |
*/
|
sl@0
|
180 |
void DoCancel();
|
sl@0
|
181 |
|
sl@0
|
182 |
/**
|
sl@0
|
183 |
*/
|
sl@0
|
184 |
void RunL();
|
sl@0
|
185 |
|
sl@0
|
186 |
/**
|
sl@0
|
187 |
*/
|
sl@0
|
188 |
TInt RunError(TInt aError);
|
sl@0
|
189 |
|
sl@0
|
190 |
private:
|
sl@0
|
191 |
RUsbHubDriver& iDriver;
|
sl@0
|
192 |
RUsbDevice::TDeviceState iCurrentState;
|
sl@0
|
193 |
TUint iHandle;
|
sl@0
|
194 |
RUsbDevice iDevice;
|
sl@0
|
195 |
TUsbDeviceDescriptor iDeviceDescriptor;
|
sl@0
|
196 |
TUsbConfigurationDescriptor iConfigDescriptor;
|
sl@0
|
197 |
TUint16 iDeviceSpec;
|
sl@0
|
198 |
TUint16 iPid;
|
sl@0
|
199 |
TUint16 iVid;
|
sl@0
|
200 |
|
sl@0
|
201 |
/**
|
sl@0
|
202 |
The observer of events on the bus bus, noticed by the host hub driver
|
sl@0
|
203 |
*/
|
sl@0
|
204 |
MUsbBusObserver& iObserver;
|
sl@0
|
205 |
|
sl@0
|
206 |
/**
|
sl@0
|
207 |
The string for the configuration
|
sl@0
|
208 |
*/
|
sl@0
|
209 |
TUsbStringDescriptor* iConfigStringDesc;
|
sl@0
|
210 |
TBuf8<255> iConfigStringData;
|
sl@0
|
211 |
TBuf16<128> iConfigString;
|
sl@0
|
212 |
|
sl@0
|
213 |
/**
|
sl@0
|
214 |
The string for the manufacturer
|
sl@0
|
215 |
*/
|
sl@0
|
216 |
TUsbStringDescriptor* iManufacturerStringDesc;
|
sl@0
|
217 |
TBuf8<255> iManufacturerStringData;
|
sl@0
|
218 |
TBuf16<128> iManufacturerString;
|
sl@0
|
219 |
|
sl@0
|
220 |
/**
|
sl@0
|
221 |
The string for the product name
|
sl@0
|
222 |
*/
|
sl@0
|
223 |
TUsbStringDescriptor* iProductStringDesc;
|
sl@0
|
224 |
TBuf8<255> iProductStringData;
|
sl@0
|
225 |
TBuf16<128> iProductString;
|
sl@0
|
226 |
|
sl@0
|
227 |
/**
|
sl@0
|
228 |
The string for the serial number
|
sl@0
|
229 |
*/
|
sl@0
|
230 |
TUsbStringDescriptor* iSerialNumberDesc;
|
sl@0
|
231 |
TBuf8<255> iSerialNumberStringData;
|
sl@0
|
232 |
TBuf16<128> iSerialNumber;
|
sl@0
|
233 |
};
|
sl@0
|
234 |
|
sl@0
|
235 |
/**
|
sl@0
|
236 |
This class represents a minimal version of the Function driver framework.
|
sl@0
|
237 |
This will usually manage more than one device but only one device can currently be supported.
|
sl@0
|
238 |
The actual FDF has well defined responsibilities but this actor FDF will be controlled by the
|
sl@0
|
239 |
current test case running.
|
sl@0
|
240 |
*/
|
sl@0
|
241 |
class CActorFDF : public CActive
|
sl@0
|
242 |
{
|
sl@0
|
243 |
public:
|
sl@0
|
244 |
|
sl@0
|
245 |
/**
|
sl@0
|
246 |
Factory construction of the acting Function Driver Framework
|
sl@0
|
247 |
@param aNotifier the notifier
|
sl@0
|
248 |
*/
|
sl@0
|
249 |
static CActorFDF* NewL(MUsbBusObserver& aObserver);
|
sl@0
|
250 |
virtual ~CActorFDF();
|
sl@0
|
251 |
|
sl@0
|
252 |
void Monitor();
|
sl@0
|
253 |
|
sl@0
|
254 |
CUsbTestDevice& DeviceL(TUint aDeviceHandle);
|
sl@0
|
255 |
|
sl@0
|
256 |
private:
|
sl@0
|
257 |
CActorFDF(MUsbBusObserver& aObserver);
|
sl@0
|
258 |
void ConstructL();
|
sl@0
|
259 |
|
sl@0
|
260 |
private:
|
sl@0
|
261 |
void DoCancel();
|
sl@0
|
262 |
void RunL();
|
sl@0
|
263 |
TInt RunError(TInt aError);
|
sl@0
|
264 |
|
sl@0
|
265 |
|
sl@0
|
266 |
private:
|
sl@0
|
267 |
RUsbHubDriver iDriver;
|
sl@0
|
268 |
RHashMap<TUint,CUsbTestDevice*> iDevices;
|
sl@0
|
269 |
RUsbHubDriver::TBusEvent iBusEvent;
|
sl@0
|
270 |
MUsbBusObserver& iObserver;
|
sl@0
|
271 |
RProcess iOtgUsbMan;
|
sl@0
|
272 |
};
|
sl@0
|
273 |
|
sl@0
|
274 |
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
|
sl@0
|
278 |
#endif |