253
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file fdfactor.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "FDFActor.h"
|
|
20 |
#include "testdebug.h"
|
|
21 |
#include <Usb.h>
|
|
22 |
#include "UsbDescriptorOffsets.h"
|
|
23 |
#include "BaseTestCase.h"
|
253
|
24 |
#include "OstTraceDefinitions.h"
|
|
25 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
26 |
#include "FDFActorTraces.h"
|
|
27 |
#endif
|
0
|
28 |
#include <e32property.h>
|
|
29 |
|
|
30 |
extern RTest gtest;
|
|
31 |
|
|
32 |
namespace NUnitTesting_USBDI
|
|
33 |
{
|
|
34 |
static const TUid KWordOfDeathCat = {0x01066600};
|
|
35 |
static const TInt KWordOfDeathKey = 0x01066601;
|
|
36 |
|
|
37 |
static const TInt KNonExistantStringNumber = 97; //the device does not have a string descriptor associated with the number 97
|
|
38 |
|
|
39 |
CActorFDF* CActorFDF::NewL(MUsbBusObserver& aObserver)
|
|
40 |
{
|
253
|
41 |
OstTraceFunctionEntry1( CACTORFDF_NEWL_ENTRY, ( TUint )&( aObserver ) );
|
0
|
42 |
CActorFDF* self = new (ELeave) CActorFDF(aObserver);
|
|
43 |
CleanupStack::PushL(self);
|
|
44 |
self->ConstructL();
|
|
45 |
CleanupStack::Pop(self);
|
253
|
46 |
OstTraceFunctionExit1( CACTORFDF_NEWL_EXIT, ( TUint )( self ) );
|
0
|
47 |
return self;
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
CActorFDF::CActorFDF(MUsbBusObserver& aObserver)
|
|
52 |
: CActive(EPriorityStandard),
|
|
53 |
iObserver(aObserver)
|
|
54 |
{
|
253
|
55 |
OstTraceFunctionEntryExt( CACTORFDF_CACTORFDF_ENTRY, this );
|
|
56 |
OstTraceFunctionExit1( CACTORFDF_CACTORFDF_EXIT, this );
|
0
|
57 |
}
|
|
58 |
|
|
59 |
|
|
60 |
void CActorFDF::ConstructL()
|
|
61 |
{
|
253
|
62 |
OstTraceFunctionEntry1( CACTORFDF_CONSTRUCTL_ENTRY, this );
|
0
|
63 |
CActiveScheduler::Add(this);
|
|
64 |
|
|
65 |
TInt err(iDriver.Open());
|
|
66 |
if(err != KErrNone)
|
|
67 |
{
|
253
|
68 |
OstTrace1(TRACE_NORMAL, CACTORFDF_CONSTRUCTL, "<Error %d> Unable to open driver channel",err);
|
0
|
69 |
User::Leave(err);
|
|
70 |
}
|
|
71 |
|
253
|
72 |
OstTrace0(TRACE_NORMAL, CACTORFDF_CONSTRUCTL_DUP01, "PBASE-T_USBDI-xxxx: Stack starting");
|
0
|
73 |
/*
|
|
74 |
@SYMTestCaseID PBASE-T_USBDI-xxxx
|
|
75 |
@SYMTestCaseDesc Test for host stack initiation
|
|
76 |
@SYMFssID
|
|
77 |
@SYMPREQ 1782
|
|
78 |
@SYMREQ 7097 [USBMAN : Activation and deactivation of USB Host functionality]
|
|
79 |
@SYMTestType UT
|
|
80 |
@SYMTestPriority 1
|
|
81 |
@SYMTestActions
|
|
82 |
@SYMTestExpectedResults KErrNone from RUsbHubDriver::StartHost()
|
|
83 |
@SYMTestStatus Implemented
|
|
84 |
*/
|
|
85 |
err = iDriver.StartHost();
|
|
86 |
if(err != KErrNone)
|
|
87 |
{
|
|
88 |
// Test case did not run successfully
|
253
|
89 |
OstTrace1(TRACE_NORMAL, CACTORFDF_CONSTRUCTL_DUP02, "<Error %d> USB Host stack not starting",err);
|
0
|
90 |
gtest(EFalse);
|
|
91 |
}
|
|
92 |
|
253
|
93 |
OstTrace0(TRACE_NORMAL, CACTORFDF_CONSTRUCTL_DUP03, "starting t_usbhost_usbman.exe");
|
0
|
94 |
TInt r = iOtgUsbMan.Create(_L("t_usbhost_usbman.exe"), KNullDesC); //LIT does not seem to work here
|
|
95 |
if(r != KErrNone && r != KErrAlreadyExists)
|
|
96 |
{
|
253
|
97 |
OstTrace0(TRACE_NORMAL, CACTORFDF_CONSTRUCTL_DUP04, "can't start t_usbhost_usbman.exe");
|
0
|
98 |
gtest(EFalse);
|
|
99 |
}
|
|
100 |
|
|
101 |
// create a publish/subscribe key to allow usbhost_usbman to be killed
|
|
102 |
// cleanly
|
|
103 |
static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
|
|
104 |
r = RProperty::Define(KWordOfDeathCat, KWordOfDeathKey, RProperty::EInt,KAllowAllPolicy, KAllowAllPolicy, 0);
|
|
105 |
if(r != KErrNone && r != KErrAlreadyExists)
|
|
106 |
{
|
253
|
107 |
OstTrace1(TRACE_NORMAL, CACTORFDF_CONSTRUCTL_DUP05, "Could not create the WordOfDeath P&S (%d)", r);
|
0
|
108 |
gtest(EFalse);
|
|
109 |
}
|
|
110 |
|
|
111 |
iOtgUsbMan.Resume();
|
|
112 |
|
|
113 |
User::After(1500000); //allow time for t_usbhost_usbman.exe to start
|
253
|
114 |
OstTraceFunctionExit1( CACTORFDF_CONSTRUCTL_EXIT, this );
|
0
|
115 |
}
|
|
116 |
|
|
117 |
void KillTest()
|
|
118 |
{
|
253
|
119 |
OstTraceFunctionEntry0( _KILLTEST_ENTRY );
|
|
120 |
OstTrace0(TRACE_NORMAL, KILLTEST_KILLTEST, "BEFORE gtest(EFalse)");
|
0
|
121 |
gtest(EFalse);
|
253
|
122 |
OstTrace0(TRACE_NORMAL, KILLTEST_KILLTEST_DUP01, "AFTER gtest(EFalse)");
|
|
123 |
OstTraceFunctionExit0( _KILLTEST_EXIT );
|
0
|
124 |
}
|
|
125 |
|
|
126 |
CActorFDF::~CActorFDF()
|
|
127 |
{
|
253
|
128 |
OstTraceFunctionEntry1( CACTORFDF_CACTORFDF_ENTRY_DUP01, this );
|
0
|
129 |
Cancel();
|
|
130 |
|
|
131 |
// Destroy all test device objects that represented connected devices
|
|
132 |
|
|
133 |
RHashMap<TUint,CUsbTestDevice*>::TIter it(iDevices);
|
|
134 |
TInt count(0);
|
|
135 |
for(count=0; count<iDevices.Count(); count++)
|
|
136 |
{
|
|
137 |
delete *it.NextValue();
|
|
138 |
}
|
|
139 |
|
253
|
140 |
OstTrace0(TRACE_NORMAL, CACTORFDF_DCACTORFDF, "killing t_usbhost_usbman.exe");
|
0
|
141 |
TInt r = RProperty::Set(KWordOfDeathCat, KWordOfDeathKey, KErrAbort); // Send the word of death
|
|
142 |
if(r != KErrNone)
|
|
143 |
{
|
253
|
144 |
OstTrace1(TRACE_NORMAL, CACTORFDF_DCACTORFDF_DUP01, "failed to kill t_usbhost-usbhan (%d)", r);
|
0
|
145 |
RProperty::Delete(KWordOfDeathCat, KWordOfDeathKey); //try to clean this up ready for next test
|
|
146 |
User::After(1000000); //allow time for property to clean up
|
|
147 |
gtest(EFalse);
|
|
148 |
}
|
|
149 |
User::After(1000000); //allow time for t_usbhost_usbman.exe to clean up
|
|
150 |
|
|
151 |
// Stop the USB Hub driver
|
|
152 |
|
253
|
153 |
OstTrace0(TRACE_NORMAL, CACTORFDF_DCACTORFDF_DUP02, "UT-USBD-P1782-TN0001: Hub driver stopping...");
|
0
|
154 |
|
|
155 |
// Close the channel to the USB Hub driver
|
|
156 |
iDriver.Close();
|
|
157 |
|
|
158 |
User::After(500000);
|
|
159 |
|
|
160 |
// delete word of death P&S
|
|
161 |
r = RProperty::Delete(KWordOfDeathCat, KWordOfDeathKey);
|
|
162 |
if(r != KErrNone)
|
|
163 |
{
|
|
164 |
//try again
|
|
165 |
User::After(1000000); //allow time for property to clean up
|
|
166 |
r = RProperty::Delete(KWordOfDeathCat, KWordOfDeathKey);
|
|
167 |
if(r != KErrNone)
|
|
168 |
//give up
|
|
169 |
{
|
|
170 |
User::After(1000000); //allow time for property to clean up JUST IN CASE it can despite returning an error!
|
253
|
171 |
OstTrace1(TRACE_NORMAL, CACTORFDF_DCACTORFDF_DUP03, "failed to delete wordofdeath P&S (%d)", r);
|
0
|
172 |
gtest(EFalse);
|
|
173 |
}
|
|
174 |
}
|
|
175 |
|
253
|
176 |
OstTraceFunctionExit1( CACTORFDF_CACTORFDF_EXIT_DUP01, this );
|
0
|
177 |
}
|
|
178 |
|
|
179 |
void CActorFDF::DoCancel()
|
|
180 |
{
|
253
|
181 |
OstTraceFunctionEntry1( CACTORFDF_DOCANCEL_ENTRY, this );
|
0
|
182 |
|
|
183 |
|
253
|
184 |
OstTrace0(TRACE_NORMAL, CACTORFDF_DOCANCEL, "Cancelling bus event notifications");
|
0
|
185 |
iDriver.CancelWaitForBusEvent();
|
|
186 |
gtest((iStatus == KErrCancel) || (iStatus == KErrNone));
|
253
|
187 |
OstTrace0(TRACE_NORMAL, CACTORFDF_DOCANCEL_DUP01, "Bus event notifications successfully cancelled");
|
|
188 |
OstTraceFunctionExit1( CACTORFDF_DOCANCEL_EXIT, this );
|
0
|
189 |
}
|
|
190 |
|
|
191 |
void CActorFDF::Monitor()
|
|
192 |
{
|
253
|
193 |
OstTraceFunctionEntry1( CACTORFDF_MONITOR_ENTRY, this );
|
0
|
194 |
|
253
|
195 |
OstTrace0(TRACE_NORMAL, CACTORFDF_MONITOR, "Monitoring bus events");
|
0
|
196 |
iDriver.WaitForBusEvent(iBusEvent,iStatus);
|
|
197 |
SetActive();
|
253
|
198 |
OstTraceFunctionExit1( CACTORFDF_MONITOR_EXIT, this );
|
0
|
199 |
}
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
CUsbTestDevice& CActorFDF::DeviceL(TUint aDeviceHandle)
|
|
204 |
{
|
253
|
205 |
OstTraceFunctionEntryExt( CACTORFDF_DEVICEL_ENTRY, this );
|
0
|
206 |
return *iDevices.FindL(aDeviceHandle);
|
|
207 |
}
|
|
208 |
|
|
209 |
void CActorFDF::RunL()
|
|
210 |
{
|
253
|
211 |
OstTraceFunctionEntry1( CACTORFDF_RUNL_ENTRY, this );
|
0
|
212 |
|
|
213 |
// Obtain completion code
|
|
214 |
TInt completionCode(iStatus.Int());
|
253
|
215 |
OstTrace1(TRACE_NORMAL, CACTORFDF_RUNL, "Completion code : %d",completionCode);
|
0
|
216 |
|
|
217 |
if(completionCode == KErrNone)
|
|
218 |
{
|
|
219 |
if(iBusEvent.iEventType == RUsbHubDriver::TBusEvent::EDeviceAttached)
|
|
220 |
{
|
|
221 |
// Device Attached
|
253
|
222 |
OstTrace1(TRACE_NORMAL, CACTORFDF_RUNL_DUP01, "Usb device attached: %d",iBusEvent.iDeviceHandle);
|
0
|
223 |
|
|
224 |
// Create the test device object
|
|
225 |
iDevices.InsertL(iBusEvent.iDeviceHandle,CUsbTestDevice::NewL(iDriver,iBusEvent.iDeviceHandle,iObserver));
|
|
226 |
|
|
227 |
// Notify observer
|
|
228 |
iObserver.DeviceInsertedL(iBusEvent.iDeviceHandle);
|
|
229 |
}
|
|
230 |
else if(iBusEvent.iEventType == RUsbHubDriver::TBusEvent::EDeviceRemoved)
|
|
231 |
{
|
|
232 |
// Device Removed
|
253
|
233 |
OstTrace1(TRACE_NORMAL, CACTORFDF_RUNL_DUP02, "Usb device removed: %d",iBusEvent.iDeviceHandle);
|
0
|
234 |
|
|
235 |
// Notify observer
|
|
236 |
iObserver.DeviceRemovedL(iBusEvent.iDeviceHandle);
|
|
237 |
|
|
238 |
// Destroy the device for the handle and remove from the map
|
|
239 |
delete iDevices.FindL(iBusEvent.iDeviceHandle);
|
|
240 |
iDevices.Remove(iBusEvent.iDeviceHandle);
|
|
241 |
}
|
|
242 |
else
|
|
243 |
{
|
|
244 |
// TODO: Upcall for USB Man etc
|
253
|
245 |
OstTraceExt2(TRACE_NORMAL, CACTORFDF_RUNL_DUP03, "<Warning> Bus event %d occured, still monitoring, reason = %d",iBusEvent.iEventType, iBusEvent.iReason);
|
0
|
246 |
iDriver.WaitForBusEvent(iBusEvent,iStatus);
|
|
247 |
SetActive();
|
|
248 |
}
|
|
249 |
}
|
|
250 |
else
|
|
251 |
{
|
253
|
252 |
OstTraceExt2(TRACE_NORMAL, CACTORFDF_RUNL_DUP04, "<Error %d> Bus event %d",completionCode,iBusEvent.iEventType);
|
0
|
253 |
iObserver.BusErrorL(completionCode);
|
|
254 |
}
|
253
|
255 |
OstTraceFunctionExit1( CACTORFDF_RUNL_EXIT, this );
|
0
|
256 |
}
|
|
257 |
|
|
258 |
|
|
259 |
TInt CActorFDF::RunError(TInt aError)
|
|
260 |
{
|
253
|
261 |
OstTraceFunctionEntryExt( CACTORFDF_RUNERROR_ENTRY, this );
|
0
|
262 |
|
253
|
263 |
OstTrace1(TRACE_NORMAL, CACTORFDF_RUNERROR, "<Error %d> CActorFDF::RunError",aError);
|
|
264 |
OstTraceFunctionExitExt( CACTORFDF_RUNERROR_EXIT, this, KErrNone );
|
0
|
265 |
return KErrNone;
|
|
266 |
}
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
CUsbTestDevice* CUsbTestDevice::NewL(RUsbHubDriver& aHubDriver,TUint aDeviceHandle,MUsbBusObserver& aObserver)
|
|
279 |
{
|
253
|
280 |
OstTraceFunctionEntryExt( CUSBTESTDEVICE_NEWL_ENTRY, 0 );
|
0
|
281 |
CUsbTestDevice* self = new (ELeave) CUsbTestDevice(aHubDriver,aDeviceHandle,aObserver);
|
|
282 |
CleanupStack::PushL(self);
|
|
283 |
self->ConstructL();
|
|
284 |
CleanupStack::Pop(self);
|
253
|
285 |
OstTraceFunctionExit1( CUSBTESTDEVICE_NEWL_EXIT, ( TUint )( self ) );
|
0
|
286 |
return self;
|
|
287 |
}
|
|
288 |
|
|
289 |
CUsbTestDevice::CUsbTestDevice(RUsbHubDriver& aHubDriver,TUint aHandle,MUsbBusObserver& aObserver)
|
|
290 |
: CActive(EPriorityUserInput),
|
|
291 |
iDriver(aHubDriver),
|
|
292 |
iHandle(aHandle),
|
|
293 |
iObserver(aObserver)
|
|
294 |
{
|
253
|
295 |
OstTraceFunctionEntryExt( CUSBTESTDEVICE_CUSBTESTDEVICE_ENTRY, this );
|
0
|
296 |
|
|
297 |
CActiveScheduler::Add(this);
|
253
|
298 |
OstTraceFunctionExit1( CUSBTESTDEVICE_CUSBTESTDEVICE_EXIT, this );
|
0
|
299 |
}
|
|
300 |
|
|
301 |
CUsbTestDevice::~CUsbTestDevice()
|
|
302 |
{
|
253
|
303 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_CUSBTESTDEVICE_ENTRY_DUP01, this );
|
0
|
304 |
Cancel();
|
|
305 |
iDevice.Close();
|
253
|
306 |
OstTraceFunctionExit1( CUSBTESTDEVICE_CUSBTESTDEVICE_EXIT_DUP01, this );
|
0
|
307 |
}
|
|
308 |
|
|
309 |
void CUsbTestDevice::ConstructL()
|
|
310 |
{
|
253
|
311 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_CONSTRUCTL_ENTRY, this );
|
0
|
312 |
|
|
313 |
// Open the usb device object
|
|
314 |
User::LeaveIfError(iDevice.Open(iDriver,iHandle));
|
|
315 |
|
|
316 |
TInt err(iDevice.GetDeviceDescriptor(iDeviceDescriptor));
|
|
317 |
if(err != KErrNone)
|
|
318 |
{
|
253
|
319 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL, "<Error %d> Getting device (%u) descriptor",err,iHandle);
|
0
|
320 |
User::Leave(err);
|
|
321 |
}
|
|
322 |
|
|
323 |
err = iDevice.GetConfigurationDescriptor(iConfigDescriptor);
|
|
324 |
if(err != KErrNone)
|
|
325 |
{
|
253
|
326 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP01, "<Error %d> Getting device (%u) configuration descriptor",err,iHandle);
|
0
|
327 |
User::Leave(err);
|
|
328 |
}
|
|
329 |
|
|
330 |
iDeviceSpec = iDeviceDescriptor.USBBcd();
|
|
331 |
iPid = iDeviceDescriptor.ProductId();
|
|
332 |
iVid = iDeviceDescriptor.VendorId();
|
|
333 |
|
253
|
334 |
OstTrace1(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP02, "%dmA configuration maximum power consumption",iConfigDescriptor.MaxPower()*2);
|
|
335 |
OstTrace1(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP03, "%d number of interface(s)",iConfigDescriptor.NumInterfaces());
|
|
336 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP04, "Product Id=0x%04x, Vendor Id=0x%04x",(TUint32)iPid,(TUint32)iVid);
|
|
337 |
OstTrace1(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP05, "TotalLength() = %d",iConfigDescriptor.TotalLength());
|
0
|
338 |
|
|
339 |
// The manufacturer string
|
|
340 |
err = iDevice.GetStringDescriptor(iManufacturerStringDesc,iManufacturerStringData,iDeviceDescriptor.ManufacturerIndex());
|
|
341 |
if(err != KErrNone)
|
|
342 |
{
|
253
|
343 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP06, "<Error %d> Getting device (%u) manufacturer string descriptor",err,iHandle);
|
0
|
344 |
User::Leave(err);
|
|
345 |
}
|
|
346 |
iManufacturerStringDesc->StringData(iManufacturerString);
|
|
347 |
|
|
348 |
// The product string
|
|
349 |
err = iDevice.GetStringDescriptor(iProductStringDesc,iProductStringData,iDeviceDescriptor.ProductIndex());
|
|
350 |
if(err != KErrNone)
|
|
351 |
{
|
253
|
352 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP07, "<Error %d> Getting device (%u) product string descriptor",err,iHandle);
|
0
|
353 |
User::Leave(err);
|
|
354 |
}
|
|
355 |
iProductStringDesc->StringData(iProductString);
|
|
356 |
|
|
357 |
// The serial number
|
|
358 |
err = iDevice.GetStringDescriptor(iSerialNumberDesc,iSerialNumberStringData,iDeviceDescriptor.SerialNumberIndex());
|
|
359 |
if(err != KErrNone)
|
|
360 |
{
|
253
|
361 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP08, "<Error %d> Getting device (%u) serial number string descriptor",err,iHandle);
|
0
|
362 |
User::Leave(err);
|
|
363 |
}
|
|
364 |
iSerialNumberDesc->StringData(iSerialNumber);
|
|
365 |
|
|
366 |
// The configuration string
|
|
367 |
err = iDevice.GetStringDescriptor(iConfigStringDesc,iConfigStringData,iConfigDescriptor.ConfigurationIndex());
|
|
368 |
if(err != KErrNone)
|
|
369 |
{
|
253
|
370 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP09, "<Error %d> Getting device (%u) configuration string descriptor",err,iHandle);
|
0
|
371 |
User::Leave(err);
|
|
372 |
}
|
|
373 |
iConfigStringDesc->StringData(iConfigString);
|
|
374 |
|
|
375 |
// Trying to obtain a string descriptor that is not present, expecting a stall
|
|
376 |
TBuf8<255> nonExistentString;
|
|
377 |
TUsbStringDescriptor* unusedStringDescriptor = NULL;
|
|
378 |
err = iDevice.GetStringDescriptor(unusedStringDescriptor,nonExistentString,KNonExistantStringNumber);
|
|
379 |
if(err != KErrUsbStalled)
|
|
380 |
{
|
|
381 |
delete unusedStringDescriptor; //in case 'err == KErrNone', in which case this will need freeing
|
253
|
382 |
OstTraceExt2(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP10, "GetStringDescriptor with %d Handle %u",err,iHandle);
|
0
|
383 |
User::Leave(err);
|
|
384 |
}
|
253
|
385 |
OstTrace1(TRACE_NORMAL, CUSBTESTDEVICE_CONSTRUCTL_DUP11, "String not present error(%d)",err);
|
0
|
386 |
|
|
387 |
// Get changes in device state
|
|
388 |
iDevice.QueueDeviceStateChangeNotification(iCurrentState,iStatus); // iCurrentState now holds the current device state
|
|
389 |
SetActive();
|
253
|
390 |
OstTraceFunctionExit1( CUSBTESTDEVICE_CONSTRUCTL_EXIT, this );
|
0
|
391 |
}
|
|
392 |
|
|
393 |
RUsbDevice& CUsbTestDevice::Device()
|
|
394 |
{
|
253
|
395 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_DEVICE_ENTRY, this );
|
|
396 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_DEVICE_EXIT, this, ( TUint )&( iDevice ) );
|
0
|
397 |
return iDevice;
|
|
398 |
}
|
|
399 |
|
|
400 |
TUint16 CUsbTestDevice::DeviceSpec() const
|
|
401 |
{
|
253
|
402 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_DEVICESPEC_ENTRY, this );
|
|
403 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_DEVICESPEC_EXIT, this, ( TUint16 )( iDeviceSpec ) );
|
0
|
404 |
return iDeviceSpec;
|
|
405 |
}
|
|
406 |
|
|
407 |
TUint16 CUsbTestDevice::ProductId() const
|
|
408 |
{
|
253
|
409 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_PRODUCTID_ENTRY, this );
|
|
410 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_PRODUCTID_EXIT, this, ( TUint16 )( iPid ) );
|
0
|
411 |
return iPid;
|
|
412 |
}
|
|
413 |
|
|
414 |
TUint16 CUsbTestDevice::VendorId() const
|
|
415 |
{
|
253
|
416 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_VENDORID_ENTRY, this );
|
|
417 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_VENDORID_EXIT, this, ( TUint16 )( iVid ) );
|
0
|
418 |
return iVid;
|
|
419 |
}
|
|
420 |
|
|
421 |
const TDesC16& CUsbTestDevice::SerialNumber() const
|
|
422 |
{
|
253
|
423 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_SERIALNUMBER_ENTRY, this );
|
|
424 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_SERIALNUMBER_EXIT, this, ( TUint )&( iSerialNumber ) );
|
0
|
425 |
return iSerialNumber;
|
|
426 |
}
|
|
427 |
|
|
428 |
const TDesC16& CUsbTestDevice::Manufacturer() const
|
|
429 |
{
|
253
|
430 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_MANUFACTURER_ENTRY, this );
|
|
431 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_MANUFACTURER_EXIT, this, ( TUint )&( iManufacturerString ) );
|
0
|
432 |
return iManufacturerString;
|
|
433 |
}
|
|
434 |
|
|
435 |
const TDesC16& CUsbTestDevice::Product() const
|
|
436 |
{
|
253
|
437 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_PRODUCT_ENTRY, this );
|
|
438 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_PRODUCT_EXIT, this, ( TUint )&( iProductString ) );
|
0
|
439 |
return iProductString;
|
|
440 |
}
|
|
441 |
|
|
442 |
const TDesC16& CUsbTestDevice::ConfigurationString() const
|
|
443 |
{
|
253
|
444 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_CONFIGURATIONSTRING_ENTRY, this );
|
|
445 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_CONFIGURATIONSTRING_EXIT, this, ( TUint )&( iConfigString ) );
|
0
|
446 |
return iConfigString;
|
|
447 |
}
|
|
448 |
|
|
449 |
const TUsbConfigurationDescriptor& CUsbTestDevice::ConfigurationDescriptor() const
|
|
450 |
{
|
253
|
451 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_CONFIGURATIONDESCRIPTOR_ENTRY, this );
|
|
452 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_CONFIGURATIONDESCRIPTOR_EXIT, this, ( TUint )&( iConfigDescriptor ) );
|
0
|
453 |
return iConfigDescriptor;
|
|
454 |
}
|
|
455 |
|
|
456 |
const TUsbDeviceDescriptor& CUsbTestDevice::DeviceDescriptor() const
|
|
457 |
{
|
253
|
458 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_DEVICEDESCRIPTOR_ENTRY, this );
|
|
459 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_DEVICEDESCRIPTOR_EXIT, this, ( TUint )&( iDeviceDescriptor ) );
|
0
|
460 |
return iDeviceDescriptor;
|
|
461 |
}
|
|
462 |
|
|
463 |
void CUsbTestDevice::DoCancel()
|
|
464 |
{
|
253
|
465 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_DOCANCEL_ENTRY, this );
|
0
|
466 |
|
|
467 |
iDevice.CancelDeviceStateChangeNotification();
|
253
|
468 |
OstTraceFunctionExit1( CUSBTESTDEVICE_DOCANCEL_EXIT, this );
|
0
|
469 |
}
|
|
470 |
|
|
471 |
|
|
472 |
void CUsbTestDevice::RunL()
|
|
473 |
{
|
253
|
474 |
OstTraceFunctionEntry1( CUSBTESTDEVICE_RUNL_ENTRY, this );
|
0
|
475 |
|
|
476 |
TInt completionCode(iStatus.Int());
|
253
|
477 |
OstTrace1(TRACE_NORMAL, CUSBTESTDEVICE_RUNL, "CUsbTestDevice::RunL completionCode(%d)",completionCode);
|
0
|
478 |
|
|
479 |
if(completionCode == KErrNone)
|
|
480 |
{
|
|
481 |
RUsbDevice::TDeviceState newState;
|
|
482 |
iDevice.QueueDeviceStateChangeNotification(newState,iStatus);
|
|
483 |
SetActive();
|
|
484 |
iObserver.DeviceStateChangeL(iCurrentState,newState,completionCode);
|
|
485 |
iCurrentState = newState;
|
|
486 |
}
|
253
|
487 |
OstTraceFunctionExit1( CUSBTESTDEVICE_RUNL_EXIT, this );
|
0
|
488 |
}
|
|
489 |
|
|
490 |
|
|
491 |
TInt CUsbTestDevice::RunError(TInt aError)
|
|
492 |
{
|
253
|
493 |
OstTraceFunctionEntryExt( CUSBTESTDEVICE_RUNERROR_ENTRY, this );
|
0
|
494 |
|
253
|
495 |
OstTrace1(TRACE_NORMAL, CUSBTESTDEVICE_RUNERROR, "<Error %d>",aError);
|
|
496 |
OstTraceFunctionExitExt( CUSBTESTDEVICE_RUNERROR_EXIT, this, KErrNone );
|
0
|
497 |
return KErrNone;
|
|
498 |
}
|
|
499 |
|
|
500 |
}
|
|
501 |
|