First public contribution.
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.
27 #include <e32hashtab.h>
28 #include <d32usbdescriptors.h>
29 #include <d32usbdi_hubdriver.h>
36 namespace NUnitTesting_USBDI
40 This class describes an observer for USB bus events reported from the acting
41 Function Driver Framework (Hub Driver)
48 Called when a usb client device was connected to the host and has a bus address
49 @param aDeviceHandle the unique handle to the device
51 virtual void DeviceInsertedL(TUint aDeviceHandle) = 0;
54 Called when a previously connected usb device has disconnected from the bus
55 @param aDeviceHandle the handle to the device that has just disconnected.
56 This handle will (after this function) now be void
58 virtual void DeviceRemovedL(TUint aDeviceHandle) = 0;
61 Called when there has been a error on the bus as seen by the Hub Driver
62 @param aError the bus error code
64 virtual void BusErrorL(TInt aError) = 0;
67 Called when the device has changed state
68 @param aPreviousState the previous state of the device
69 @param aNewState the now new observerd state of the device
70 @param aCompletionCode the comletion code of state change
72 virtual void DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState,
73 TInt aCompletionCode) = 0;
80 This class represents the host side object for a USB test device. This means a device that
81 is connected to the bus.
83 class CUsbTestDevice : public CActive
87 Construct a USB bus connected device
88 @param aHubDriver the USB hub driver object
89 @param aDeviceHandle the unique handle value to the device
92 static CUsbTestDevice* NewL(RUsbHubDriver& aHubDriver,TUint aDeviceHandle,MUsbBusObserver& aObserver);
100 Obtain the USB specification that this device complies to
101 @return the usb compliance specification
103 TUint16 DeviceSpec() const;
106 Obtain the Identity of the product
107 @return the product identity
109 TUint16 ProductId() const;
112 Obtain the Identity of the vendor
113 @return the vendor identity
115 TUint16 VendorId() const;
118 Obtain the product string for the connected device
119 @return the device's product string
121 const TDesC16& Product() const;
124 Obtani the configuration string for the connected device
125 @return the device's configuration string
127 const TDesC16& ConfigurationString() const;
130 Obtain the serial number of the connected device
131 @return the device's serial number
133 const TDesC16& SerialNumber() const;
136 Obtain the manufacturer of the connected device
137 @return the manufacturer as string
139 const TDesC16& Manufacturer() const;
142 Access the raw referrence to the USB device API object
143 @return a referrence to the RUsbDevice object
145 RUsbDevice& Device();
148 Access the device descriptor
149 @return a referrence to the device descriptor
151 const TUsbDeviceDescriptor& DeviceDescriptor() const;
154 Access the configuration descriptor
155 @return a referrence to the configuration descriptor
157 const TUsbConfigurationDescriptor& ConfigurationDescriptor() const;
163 Constructor, build a host side usb test object
164 @param aHubDriver the USB host hub driver
165 @param aHandle the unique handle to the usb device
166 @param aObserver the observer of usb host bus events
168 CUsbTestDevice(RUsbHubDriver& aHubDriver,TUint aHandle,MUsbBusObserver& aObserver);
171 2nd phase construction
175 protected: // From CActive
178 Cancels the current asynchronous activity of this test device
188 TInt RunError(TInt aError);
191 RUsbHubDriver& iDriver;
192 RUsbDevice::TDeviceState iCurrentState;
195 TUsbDeviceDescriptor iDeviceDescriptor;
196 TUsbConfigurationDescriptor iConfigDescriptor;
202 The observer of events on the bus bus, noticed by the host hub driver
204 MUsbBusObserver& iObserver;
207 The string for the configuration
209 TUsbStringDescriptor* iConfigStringDesc;
210 TBuf8<255> iConfigStringData;
211 TBuf16<128> iConfigString;
214 The string for the manufacturer
216 TUsbStringDescriptor* iManufacturerStringDesc;
217 TBuf8<255> iManufacturerStringData;
218 TBuf16<128> iManufacturerString;
221 The string for the product name
223 TUsbStringDescriptor* iProductStringDesc;
224 TBuf8<255> iProductStringData;
225 TBuf16<128> iProductString;
228 The string for the serial number
230 TUsbStringDescriptor* iSerialNumberDesc;
231 TBuf8<255> iSerialNumberStringData;
232 TBuf16<128> iSerialNumber;
236 This class represents a minimal version of the Function driver framework.
237 This will usually manage more than one device but only one device can currently be supported.
238 The actual FDF has well defined responsibilities but this actor FDF will be controlled by the
239 current test case running.
241 class CActorFDF : public CActive
246 Factory construction of the acting Function Driver Framework
247 @param aNotifier the notifier
249 static CActorFDF* NewL(MUsbBusObserver& aObserver);
250 virtual ~CActorFDF();
254 CUsbTestDevice& DeviceL(TUint aDeviceHandle);
257 CActorFDF(MUsbBusObserver& aObserver);
263 TInt RunError(TInt aError);
267 RUsbHubDriver iDriver;
268 RHashMap<TUint,CUsbTestDevice*> iDevices;
269 RUsbHubDriver::TBusEvent iBusEvent;
270 MUsbBusObserver& iObserver;