usbmgmt/usbmgrtest/usbtestconsole/usbtestconsole.cpp
changeset 0 c9bc50fca66e
child 9 6ba7b7d87ab3
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "usbtestconsole.h"
       
    19 
       
    20 #include <e32cons.h>
       
    21 #include <e32debug.h>
       
    22 
       
    23 #include <d32otgdi_errors.h>
       
    24 #include <d32usbdi_errors.h>
       
    25 #include <d32usbdi.h>
       
    26 
       
    27 #include <usb/usbshared.h>
       
    28 
       
    29 static TBool verbose = EFalse;
       
    30 
       
    31 const TUint KTimerAWaitBConnect = 30*1000000;  
       
    32 
       
    33 #define PANIC Panic(__LINE__)
       
    34 
       
    35 #define LOG(A,B) if (verbose) RDebug::Print(_L("UsbTestConsole: " L##A),B)
       
    36 
       
    37 #define PNT(A)	 if (verbose) RDebug::Print(_L("UsbTestConsole: " L##A))
       
    38 
       
    39 void Panic(TInt aLine)
       
    40 	{
       
    41 	if (verbose) RDebug::Printf("UsbTestConsole: PANIC line=%d", aLine);
       
    42 	User::Panic(_L("USBTESTCONSOLE"), aLine);
       
    43 	}
       
    44 
       
    45 _LIT(KArgVerbose, "VERBOSE");
       
    46 
       
    47 void RunConsoleL()
       
    48 	{
       
    49 	TInt cmdLineLength(User::CommandLineLength());
       
    50 	HBufC* cmdLine = HBufC::NewMaxLC(cmdLineLength);
       
    51 	TPtr cmdLinePtr = cmdLine->Des();
       
    52 	User::CommandLine(cmdLinePtr);
       
    53 
       
    54 	TLex args(*cmdLine);
       
    55 	args.SkipSpace(); // args are separated by spaces
       
    56 	
       
    57 	// first arg is the exe name, skip it
       
    58 	TPtrC cmdToken = args.NextToken();
       
    59 	HBufC* tc = HBufC::NewLC(80);
       
    60 	*tc = cmdToken;
       
    61 	
       
    62 	while (tc->Length())
       
    63 		{
       
    64 		TInt pos = tc->FindF(KArgVerbose);
       
    65 		
       
    66 		if ( pos != KErrNotFound )
       
    67 			{ 
       
    68 			verbose = ETrue;
       
    69 			}
       
    70 		
       
    71 		// next parameter
       
    72 		*tc = args.NextToken();
       
    73 		}
       
    74 	CleanupStack::PopAndDestroy(tc);
       
    75 	CleanupStack::PopAndDestroy(cmdLine);
       
    76 
       
    77 	CUsbTestConsole* console = CUsbTestConsole::NewLC();
       
    78 	console->StartL();
       
    79 	CleanupStack::PopAndDestroy(console);
       
    80 	}
       
    81 
       
    82 TInt E32Main()
       
    83 	{
       
    84 	__UHEAP_MARK;
       
    85 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    86 	CActiveScheduler* activeScheduler = new CActiveScheduler;
       
    87 	TInt err = KErrNoMemory;
       
    88 	if(cleanup && activeScheduler)
       
    89 		{
       
    90 		CActiveScheduler::Install(activeScheduler);
       
    91 
       
    92 		TRAP(err,RunConsoleL());
       
    93 		}
       
    94 	delete activeScheduler;
       
    95 	delete cleanup;
       
    96 	__UHEAP_MARKEND;
       
    97 	return err;
       
    98 	}
       
    99 
       
   100 XUsbTestConsoleEvent::~XUsbTestConsoleEvent()
       
   101 	{
       
   102 	iLink.Deque();
       
   103 	iEvent.Close();
       
   104 	}
       
   105 	
       
   106 	
       
   107 	
       
   108 	
       
   109 CUsbTestConsoleKeys* CUsbTestConsoleKeys::NewL(CUsbTestConsole& aTestConsole)
       
   110 	{
       
   111 	CUsbTestConsoleKeys* self = new(ELeave) CUsbTestConsoleKeys(aTestConsole);
       
   112 	CleanupStack::PushL(self);
       
   113 	self->ConstructL();
       
   114 	CleanupStack::Pop(self);
       
   115 	return self;
       
   116 	}
       
   117 
       
   118 CUsbTestConsoleKeys::~CUsbTestConsoleKeys()
       
   119 	{
       
   120 	Cancel();
       
   121 
       
   122 	TDblQueIter<CUsbTestConsoleTextEntryBase> iter(iEntryConsoles);
       
   123 	CUsbTestConsoleTextEntryBase* event = NULL;
       
   124 	while((event = iter++) != NULL)
       
   125 		{
       
   126 		delete event;
       
   127 		}
       
   128 		
       
   129 	delete iUsbManStarter;
       
   130 	delete iUsbManStoper;
       
   131 	delete iUsbManTryStarter;
       
   132 	delete iUsbManTryStoper;
       
   133 	}
       
   134 
       
   135 CUsbTestConsoleKeys::CUsbTestConsoleKeys(CUsbTestConsole& aTestConsole)
       
   136 	: CActive(EPriorityStandard)
       
   137 	, iTestConsole(aTestConsole)
       
   138 	, iEntryConsoles(_FOFF(CUsbTestConsoleTextEntryBase, iLink))
       
   139 	{
       
   140 	CActiveScheduler::Add(this);
       
   141 	}
       
   142 
       
   143 void CUsbTestConsoleKeys::ConstructL()
       
   144 	{
       
   145 	iTestConsole.iConsole->Read(iStatus);
       
   146 	SetActive();
       
   147 	}
       
   148 
       
   149 void CUsbTestConsoleKeys::DoCancel()
       
   150 	{
       
   151 	iTestConsole.iConsole->ReadCancel();
       
   152 	}
       
   153 
       
   154 void CUsbTestConsoleKeys::RunL()
       
   155 	{
       
   156 	User::LeaveIfError(iStatus.Int());
       
   157 	
       
   158 	switch(iTestConsole.iConsole->KeyCode())
       
   159 		{
       
   160 	case '[':
       
   161 		{
       
   162 		RUsb sess;
       
   163 		TInt err = sess.Connect();
       
   164 		sess.Close();
       
   165 		
       
   166 		User::After(4000000);
       
   167 		
       
   168 		err = sess.Connect(); 
       
   169 
       
   170 		XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   171 		event->iEvent.AppendFormat(_L("T:USBMAN Test Err[%d]"), err);
       
   172 		iTestConsole.NotifyEvent(event);
       
   173 		
       
   174 		sess.Close();
       
   175 		}
       
   176 		break;
       
   177 	case 'm':
       
   178 		{
       
   179 		TInt val = 1;
       
   180 		TInt err = RProperty::Set(KUidUsbManCategory,KUsbRequestSessionProperty,val);
       
   181 		XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   182 		event->iEvent.AppendFormat(_L("T:USBMAN VBus marshalling - err=[%d]"),err);
       
   183 		iTestConsole.NotifyEvent(event);
       
   184 		}
       
   185 		break;
       
   186 	case 'H': case 'h': case '?': 
       
   187 
       
   188 		iTestConsole.ScheduleDraw('H');
       
   189 		break;
       
   190 
       
   191 	case 'q': case 'Q':
       
   192 		iTestConsole.Stop();
       
   193 		return;
       
   194 		
       
   195 	case 's':
       
   196 		// Toggle Start
       
   197 		if(!iUsbManStarter)
       
   198 			{
       
   199 			CUsbManStarter::NewL(iUsbManStarter, iTestConsole);
       
   200 			}
       
   201 		else
       
   202 			{
       
   203 			iUsbManStarter->DestroyL();
       
   204 			}
       
   205 		break;
       
   206 		
       
   207 	case 'S':
       
   208 		// Toggle Stop
       
   209 		if(!iUsbManStoper)
       
   210 			{
       
   211 			// Because we cannot tell query the actual state of Function Driver loading
       
   212 			// when we shutdown we also automatically disable loading.
       
   213 			iTestConsole.Usb().DisableFunctionDriverLoading();
       
   214 			iFunctionDriverLoading = EFalse;
       
   215 			iTestConsole.SetDriverLoading(CUsbTestConsole::EDisabled);
       
   216 
       
   217 			CUsbManStoper::NewL(iUsbManStoper, iTestConsole);
       
   218 			}
       
   219 		else
       
   220 			{
       
   221 			iUsbManStoper->DestroyL();
       
   222 			}
       
   223 		break;
       
   224 		
       
   225 	case 't':
       
   226 		// Toggle TryStart
       
   227 		if(!iUsbManTryStarter)
       
   228 			{
       
   229 			CUsbManTryStarter::NewL(iUsbManTryStarter, iTestConsole, iPersonalityId);
       
   230 			}
       
   231 		else
       
   232 			{
       
   233 			iUsbManTryStarter->DestroyL();
       
   234 			}
       
   235 		break;
       
   236 
       
   237 	case 'T':
       
   238 		// Toggle TryStop
       
   239 		if(!iUsbManTryStoper)
       
   240 			{
       
   241 			// Because we cannot tell query the actual state of Function Driver loading
       
   242 			// when we shutdown we also automatically disable loading.
       
   243 			iTestConsole.Usb().DisableFunctionDriverLoading();
       
   244 			iFunctionDriverLoading = EFalse;
       
   245 			iTestConsole.SetDriverLoading(CUsbTestConsole::EDisabled);
       
   246 
       
   247 			CUsbManTryStoper::NewL(iUsbManTryStoper, iTestConsole);
       
   248 			}
       
   249 		else
       
   250 			{
       
   251 			iUsbManTryStoper->DestroyL();
       
   252 			}
       
   253 		break;
       
   254 		
       
   255 	case 'p': case 'P':
       
   256 		// Enter personality id
       
   257 			{
       
   258 			CUsbTestConsoleTextEntryBase* entry = CUsbTestConsoleTextEntry<TInt>::NewL(iPersonalityId, _L("Personality Id"));
       
   259 			iEntryConsoles.AddLast(*entry);
       
   260 			}
       
   261 		break;
       
   262 		
       
   263 	case 'c': case 'C':
       
   264 		// Toggle Control Session
       
   265 			{
       
   266 			iControlSession = !iControlSession;
       
   267 			TInt err = iTestConsole.Usb().SetCtlSessionMode(iControlSession);
       
   268 			if(err != KErrNone)
       
   269 				{
       
   270 				iControlSession = !iControlSession;
       
   271 				}
       
   272 			else
       
   273 				{
       
   274 				iTestConsole.SetControlSession(iControlSession);
       
   275 				if(!iControlSession)
       
   276 					{
       
   277 					// This is set to unknown because as soon as we relinquish the controlling session
       
   278 					// someone else could be altering the state.
       
   279 					iFunctionDriverLoading = EFalse;
       
   280                     iTestConsole.SetDriverLoading(CUsbTestConsole::EUnknown);
       
   281 					}
       
   282 				}
       
   283 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   284 			event->iEvent.AppendFormat(_L("G:SetControlSession:Err[%d]"), err);
       
   285 			iTestConsole.NotifyEvent(event);
       
   286 			}
       
   287 		break;
       
   288 
       
   289 	case 'b':
       
   290 		// Bus Request
       
   291 			{
       
   292 			TInt err = iTestConsole.Usb().BusRequest();
       
   293 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   294 			event->iEvent.AppendFormat(_L("G:BusRequest:Err[%d]"), err);
       
   295 			iTestConsole.NotifyEvent(event);
       
   296 			}
       
   297 		break;
       
   298 
       
   299 	case 'r':
       
   300 	    // Respond to SRP
       
   301 			{
       
   302 			TInt err = iTestConsole.Usb().BusRespondSrp();
       
   303 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   304 			event->iEvent.AppendFormat(_L("G:BusRespondSrp:Err[%d]"), err);
       
   305 			iTestConsole.NotifyEvent(event);
       
   306 			}
       
   307 			break;
       
   308 
       
   309 	case 'R':
       
   310 		// Auto-respond to SRP
       
   311 			{
       
   312 			iTestConsole.SetAutoSrpResponseState( !iTestConsole.GetAutoSrpResponseState() );
       
   313 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   314 			event->iEvent.AppendFormat(_L("G:Auto-Respond to SRP (%d)"), iTestConsole.GetAutoSrpResponseState());
       
   315 			iTestConsole.NotifyEvent(event);
       
   316 			}
       
   317 			break;
       
   318 			
       
   319 	case 'x': case 'X':
       
   320 	    // Clear Bus Error State
       
   321 			{
       
   322 			TInt err = iTestConsole.Usb().BusClearError();
       
   323 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   324 			event->iEvent.AppendFormat(_L("G:BusClearError:Err[%d]"), err);
       
   325 			iTestConsole.NotifyEvent(event);
       
   326 			}
       
   327 			break;
       
   328 
       
   329 	case 'B':
       
   330 		// Bus Drop
       
   331 			{
       
   332 			TInt err = iTestConsole.Usb().BusDrop();
       
   333 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   334 			event->iEvent.AppendFormat(_L("G:BusDrop:Err[%d]"), err);
       
   335 			iTestConsole.NotifyEvent(event);
       
   336 			}
       
   337 		break;
       
   338 		
       
   339 	case 'e': case 'E':
       
   340 			{
       
   341 			TBool functionDriverLoading = !iFunctionDriverLoading;
       
   342 			CUsbTestConsole::TFdfDriverLoadingState state = functionDriverLoading ? CUsbTestConsole::EEnabled : CUsbTestConsole::EDisabled;
       
   343 			TInt err = KErrNone;
       
   344 			if(functionDriverLoading)
       
   345 				{
       
   346 				err = iTestConsole.Usb().EnableFunctionDriverLoading();
       
   347 				}
       
   348 			else
       
   349 				{
       
   350 				iTestConsole.Usb().DisableFunctionDriverLoading();
       
   351 				}
       
   352 
       
   353 			if(err == KErrNone)
       
   354 				{
       
   355 				iFunctionDriverLoading = functionDriverLoading;
       
   356 				iTestConsole.SetDriverLoading(state);
       
   357 				}
       
   358 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   359 			event->iEvent.AppendFormat(_L("H:FunctionDriverLoading[%d] Err[%d]"), functionDriverLoading, err);
       
   360 			iTestConsole.NotifyEvent(event);
       
   361 			}
       
   362 		break;
       
   363 
       
   364 		case 'A': case 'a': 
       
   365 			{
       
   366 			XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   367 			switch( iTestConsole.iDeviceType )
       
   368 				{
       
   369 				case CUsbTestConsole::ELogitechHeadset:
       
   370 					{
       
   371 												// 12345678901234567890123456789012345678901234567890123
       
   372 					event->iEvent.AppendFormat(_L("G:Audio will play OK on this Logitech headset"));
       
   373 					}
       
   374 					break;
       
   375 				case CUsbTestConsole::EGenericDevice:
       
   376 					{
       
   377 												// 12345678901234567890123456789012345678901234567890123
       
   378 					event->iEvent.AppendFormat(_L("G:Audio on this device is not supported"));
       
   379 					}
       
   380 					break;
       
   381 				case CUsbTestConsole::ENoDevice:
       
   382 					{
       
   383 												// 12345678901234567890123456789012345678901234567890123
       
   384 					event->iEvent.AppendFormat(_L("G:There is no device connected!"));
       
   385 					}
       
   386 					break;
       
   387 				}
       
   388 			iTestConsole.NotifyEvent(event);
       
   389 			}
       
   390 		break;
       
   391 		
       
   392 	case 'v': case 'V':
       
   393 		{
       
   394 		TBool oldVerbose = verbose;
       
   395 		
       
   396 		verbose = ETrue;
       
   397 		
       
   398 		if (oldVerbose)
       
   399 			{
       
   400 			PNT("Switching Logging Off");
       
   401 			}
       
   402 		else
       
   403 			{
       
   404 			PNT("Switching Logging On");
       
   405 			}
       
   406 		
       
   407 		verbose = !oldVerbose;
       
   408 
       
   409 		break;
       
   410 		}
       
   411 		
       
   412 	default:
       
   413 		// Unrecognised key
       
   414 		XUsbTestConsoleEvent* event = NewConsoleEventL();
       
   415 		event->iEvent.AppendFormat(_L("G:Unknown:Key[%c]"), iTestConsole.iConsole->KeyCode());
       
   416 		iTestConsole.NotifyEvent(event);
       
   417 		break;
       
   418 		}
       
   419 	iTestConsole.iConsole->Read(iStatus);
       
   420 	SetActive();
       
   421 	}
       
   422 	
       
   423 XUsbTestConsoleEvent* CUsbTestConsoleKeys::NewConsoleEventL()
       
   424 	{
       
   425 	XUsbTestConsoleEvent* event = new(ELeave) XUsbTestConsoleEvent;
       
   426 	CleanupStack::PushL(event);
       
   427 	User::LeaveIfError(event->iEvent.Create(CUsbTestConsole::KNumCharactersOnLine-1));
       
   428 	CleanupStack::Pop();
       
   429 	return event;
       
   430 	}
       
   431 	
       
   432 
       
   433 
       
   434 CUsbTestConsole* CUsbTestConsole::NewLC()
       
   435 	{
       
   436 	CUsbTestConsole* self = new(ELeave) CUsbTestConsole;
       
   437 	CleanupStack::PushL(self);
       
   438 	self->ConstructL();
       
   439 	return self;
       
   440 	}
       
   441 	
       
   442 CUsbTestConsole::~CUsbTestConsole()
       
   443 	{
       
   444 	PNT("Closing Console");
       
   445 
       
   446 	delete iKeys;
       
   447 
       
   448 	TDblQueIter<XUsbTestConsoleEvent> iter(iEventList);
       
   449 	XUsbTestConsoleEvent* event = NULL;
       
   450 	while((event = iter++) != NULL)
       
   451 		{
       
   452 		delete event;
       
   453 		}
       
   454 
       
   455 	delete iMessageWatcher;
       
   456 	delete iHostEventWatcher;
       
   457 	delete iOtgStateWatcher;
       
   458 	delete iVBusWatcher;
       
   459 	delete iIdPinWatcher;
       
   460 	delete iDeviceStateWatcher;
       
   461 	delete iServiceStateWatcher;
       
   462 	delete iTimer;  
       
   463 
       
   464 	Cancel();
       
   465 
       
   466 	PNT("Closing USB Session");
       
   467 
       
   468 	iUsb.Close();
       
   469 	
       
   470 	delete iConsole;
       
   471 	}
       
   472 
       
   473 CUsbTestConsole::CUsbTestConsole()
       
   474 	: CActive(EPriorityLow) // Low so all notifications that want to be serviced will be done first
       
   475 	, iHelp(EFalse)
       
   476 	, iAutoSrpResponse(EFalse)
       
   477 	, iDeviceType(ENoDevice)
       
   478 	, iEventList(_FOFF(XUsbTestConsoleEvent, iLink))
       
   479 	{
       
   480 	CActiveScheduler::Add(this);
       
   481 	}
       
   482 
       
   483 void CUsbTestConsole::ConstructL()
       
   484 	{
       
   485 	iConsole = Console::NewL(KUsbTestConsoleTitle, TSize(-1,-1));
       
   486 	User::LeaveIfError(iUsb.Connect());
       
   487 	
       
   488 	for(TInt i=0; i<KNumEventsOnScreen; ++i)
       
   489 		{
       
   490         XUsbTestConsoleEvent* nullEvent = new(ELeave) XUsbTestConsoleEvent;
       
   491 		iEventList.AddFirst(*nullEvent);
       
   492 		}
       
   493 
       
   494 	iServiceStateWatcher = CServiceStateWatcher::NewL(*this);
       
   495 	iDeviceStateWatcher = CDeviceStateWatcher::NewL(*this);
       
   496 	iIdPinWatcher = CIdPinWatcher::NewL(*this);
       
   497 	iVBusWatcher = CVBusWatcher::NewL(*this);
       
   498     iConnectionIdleWatcher = CConnectionIdleWatcher::NewL(*this);
       
   499 	iOtgStateWatcher = COtgStateWatcher::NewL(*this);
       
   500 	iHostEventWatcher = CHostEventWatcher::NewL(*this);
       
   501 	iMessageWatcher = CMessageWatcher::NewL(*this);
       
   502 	iTimer = CUsbTestTimer::NewL(*this);  
       
   503 	SetDriverLoading(EUnknown);
       
   504 	SetDeviceType(ENoDevice);
       
   505 	SetAutoSrpResponseState(EFalse);
       
   506 
       
   507 	// After everything else, enable interactivity.
       
   508 	iKeys = CUsbTestConsoleKeys::NewL(*this);
       
   509 	}
       
   510 CUsbTestTimer* CUsbTestConsole::Timer() const
       
   511 	{
       
   512 	return iTimer;
       
   513 	}
       
   514 
       
   515 
       
   516 void CUsbTestConsole::StartL()
       
   517 	{
       
   518 	// Get everything running
       
   519 	CActiveScheduler::Start();
       
   520 	}
       
   521 	
       
   522 void CUsbTestConsole::Stop() const
       
   523 	{
       
   524 	CActiveScheduler::Stop();
       
   525 	}
       
   526 
       
   527 void CUsbTestConsole::DoCancel()
       
   528 	{
       
   529 	// Don't need to do anything as the AO is completed straight away.
       
   530 	}
       
   531 
       
   532 void CUsbTestConsole::RunL()
       
   533 	{
       
   534 	__ASSERT_ALWAYS(iStatus.Int() == KErrNone, PANIC);
       
   535 	Draw();
       
   536 	}
       
   537 
       
   538 void CUsbTestConsole::ScheduleDraw(TUint aKey)
       
   539 	{
       
   540 	if(!IsActive())
       
   541 		{
       
   542 		iHelp = (aKey=='H') ? !iHelp : EFalse;
       
   543 		SetActive();
       
   544 		TRequestStatus* status = &iStatus;
       
   545 		User::RequestComplete(status, KErrNone);
       
   546 
       
   547 		TSize size = iConsole->ScreenSize();
       
   548 		iConsole->SetCursorPosAbs(TPoint(size.iWidth-1, 0));
       
   549 		iConsole->Write(_L("*"));
       
   550 		}
       
   551 	}
       
   552 	
       
   553 RUsb& CUsbTestConsole::Usb()
       
   554 	{
       
   555 	return iUsb;
       
   556 	}
       
   557 	
       
   558 void CUsbTestConsole::SetServiceState(TUsbServiceState aServiceState)
       
   559 	{
       
   560 	switch(aServiceState)
       
   561 		{
       
   562     case EUsbServiceIdle:
       
   563     	iServStatus =
       
   564     		//  12345678901
       
   565 			_L("Idle       ");
       
   566     	break;
       
   567 
       
   568 	case EUsbServiceStarting:
       
   569     	iServStatus =
       
   570     		//  12345678901
       
   571 			_L("Starting   ");
       
   572 		break;
       
   573 
       
   574 	case EUsbServiceStarted:
       
   575 	    iServStatus =
       
   576     		//  12345678901
       
   577 			_L("Started    ");
       
   578 		break;
       
   579 
       
   580 	case EUsbServiceStopping:
       
   581     	iServStatus =
       
   582     		//  12345678901
       
   583 			_L("Stopping   ");
       
   584 		break;
       
   585 
       
   586 	case EUsbServiceFatalError:
       
   587     	iServStatus =
       
   588     		//  12345678901
       
   589 			_L("Error      ");
       
   590 		break;
       
   591 
       
   592 	default:
       
   593 		PANIC;
       
   594 		break;
       
   595 		}
       
   596 	LOG("Service State => %S", &iServStatus);
       
   597 	ScheduleDraw('E');
       
   598 	}
       
   599 	
       
   600 void CUsbTestConsole::SetDeviceState(TUsbDeviceState aDeviceState)
       
   601 	{
       
   602 	switch(aDeviceState)
       
   603 		{
       
   604 	case EUsbDeviceStateUndefined:
       
   605 		iDevStatus =
       
   606     		//  12345678901
       
   607 			_L("Undefined  ");
       
   608 		break;
       
   609 
       
   610 	case EUsbDeviceStateDefault:
       
   611 		iDevStatus =
       
   612     		//  12345678901
       
   613 			_L("Default    ");
       
   614 		break;
       
   615 
       
   616 	case EUsbDeviceStateAttached:
       
   617 		iDevStatus =
       
   618     		//  12345678901
       
   619 			_L("Attached   ");
       
   620 		break;
       
   621 
       
   622 	case EUsbDeviceStatePowered:
       
   623 		iDevStatus =
       
   624     		//  12345678901
       
   625 			_L("Powered    ");
       
   626 		break;
       
   627 
       
   628 	case EUsbDeviceStateConfigured:
       
   629 		iDevStatus =
       
   630     		//  12345678901
       
   631 			_L("Configured ");
       
   632 		break;
       
   633 
       
   634 	case EUsbDeviceStateAddress:
       
   635 		iDevStatus =
       
   636     		//  12345678901
       
   637 			_L("Address    ");
       
   638 		break;
       
   639 
       
   640 	case EUsbDeviceStateSuspended:
       
   641 		iDevStatus =
       
   642     		//  12345678901
       
   643 			_L("Suspended  ");
       
   644 		break;
       
   645 
       
   646 	default:
       
   647 		PANIC;
       
   648 		break;
       
   649 		}
       
   650 	LOG("Device State => %S", &iDevStatus);
       
   651 	ScheduleDraw('E');
       
   652 	}
       
   653 	
       
   654 void CUsbTestConsole::SetConnectionIdle(TInt aConnectionIdle)
       
   655 	{
       
   656 	switch(aConnectionIdle)
       
   657 		{
       
   658 	case 0:
       
   659 		iConnectionIdle =
       
   660     		//  12345
       
   661 			_L("Busy ");
       
   662 		break;
       
   663 
       
   664 	case 1:
       
   665 		iConnectionIdle =
       
   666     		//  12345
       
   667 			_L("Idle ");
       
   668 		break;
       
   669 
       
   670 	default:
       
   671 		PANIC;
       
   672 		break;
       
   673 		}
       
   674 	LOG("ConnectionIdle => %S", &iConnectionIdle);
       
   675 	ScheduleDraw('E');
       
   676 	}
       
   677 
       
   678 void CUsbTestConsole::SetIdPin(TInt aIdPin)
       
   679 	{
       
   680 	switch(aIdPin)
       
   681 		{
       
   682     case 0:
       
   683         iIdPin =
       
   684     		//  12345
       
   685 			_L("-    ");
       
   686 		break;
       
   687 
       
   688 	case 1:
       
   689 		iIdPin =
       
   690     		//  12345
       
   691 			_L("+    ");
       
   692 		break;
       
   693 
       
   694 	default:
       
   695 		PANIC;
       
   696 		break;
       
   697 		}
       
   698 	LOG("Id Pin => %S", &iIdPin);
       
   699 	ScheduleDraw('E');
       
   700 	}
       
   701 	
       
   702 void CUsbTestConsole::SetVBus(TInt aVBus)
       
   703 	{
       
   704 	switch(aVBus)
       
   705 		{
       
   706 	case 0:
       
   707 		iVBus =
       
   708     		//  12345
       
   709 			_L("-    ");
       
   710 		break;
       
   711 
       
   712 	case 1:
       
   713 		iVBus =
       
   714     		//  12345
       
   715 			_L("+    ");
       
   716 		break;
       
   717 
       
   718 	default:
       
   719 		PANIC;
       
   720 		break;
       
   721 		}
       
   722 	LOG("VBus => %S", &iVBus);
       
   723 	ScheduleDraw('E');
       
   724 	}
       
   725 
       
   726 void CUsbTestConsole::SetOtgState(TInt aOtgState)
       
   727 	{
       
   728 	switch(aOtgState)
       
   729 		{
       
   730 	case 0x01:
       
   731 		iOtgState =
       
   732     		//  123456789012
       
   733 			_L("Reset       ");
       
   734 		break;
       
   735 
       
   736 	case 0x02:
       
   737 		iOtgState =
       
   738     		//  123456789012
       
   739 			_L("A-Idle      ");
       
   740 		break;
       
   741 
       
   742 	case 0x04:
       
   743 		iOtgState =
       
   744     		//  123456789012
       
   745 			_L("A-Host      ");
       
   746 		break;
       
   747 
       
   748 	case 0x08:
       
   749 		iOtgState =
       
   750     		//  1234567890123
       
   751 			_L("A-Peripheral");
       
   752 		break;
       
   753 
       
   754 	case 0x10:
       
   755 		iOtgState =
       
   756     		//  123456789012
       
   757 			_L("A-Vbus Error");
       
   758 		break;
       
   759 
       
   760 	case 0x20:
       
   761 		iOtgState =
       
   762     		//  123456789012
       
   763 			_L("B-Idle      ");
       
   764 		break;
       
   765 
       
   766 	case 0x40:
       
   767 		iOtgState =
       
   768     		//  1234567890123
       
   769 			_L("B-Peripheral");
       
   770 		break;
       
   771 
       
   772 	case 0x80:
       
   773 		iOtgState =
       
   774     		//  1234567890123
       
   775 			_L("B-Host      ");
       
   776 		break;
       
   777 		
       
   778 	default:
       
   779 		iOtgState =
       
   780     		//  1234567890123
       
   781 			_L("Don't Panic!");
       
   782 		break;
       
   783 		}
       
   784 	LOG("OTG State => %S", &iOtgState);
       
   785 	ScheduleDraw('E');
       
   786 	}
       
   787 
       
   788 void CUsbTestConsole::SetDriverLoading(TFdfDriverLoadingState aDriverLoading)
       
   789 	{
       
   790 	switch(aDriverLoading)
       
   791 		{
       
   792 	case EUnknown:
       
   793 		iDriverLoading =
       
   794 			//  123
       
   795 			_L("???");
       
   796 		break;
       
   797 	case EDisabled:
       
   798 		iDriverLoading =
       
   799 			//  123
       
   800 			_L("Off");
       
   801 		break;
       
   802 	case EEnabled:
       
   803 		iDriverLoading =
       
   804 			//  123
       
   805 			_L("On ");
       
   806 		break;
       
   807 	default:
       
   808 		PANIC;
       
   809 		break;
       
   810 		}
       
   811 	LOG("Driver Loading => %S", &iDriverLoading);
       
   812 	ScheduleDraw('E');
       
   813 	}
       
   814 	
       
   815 void CUsbTestConsole::SetAttachedDevices(TUint aAttachedDevices)
       
   816 	{
       
   817 	if(aAttachedDevices > 999)
       
   818 		{
       
   819 		iAttachedDevices =
       
   820 			//  123
       
   821 			_L("xxx");
       
   822 		}
       
   823 	else
       
   824 		{
       
   825 		iAttachedDevices.NumFixedWidthUC(aAttachedDevices, EDecimal, 3);
       
   826 		}
       
   827 	LOG("Attached Devices => %S", &iAttachedDevices);
       
   828 	ScheduleDraw('E');
       
   829 	}
       
   830 	
       
   831 void CUsbTestConsole::SetControlSession(TBool aControl)
       
   832 	{
       
   833 	if(aControl)
       
   834 		{
       
   835 		iControlSession =
       
   836 			//  1234567
       
   837 			_L("Control");
       
   838 		}
       
   839 	else
       
   840 		{
       
   841 		iControlSession =
       
   842 			//  1234567
       
   843 			_L("       ");
       
   844 		}
       
   845 	LOG("Control Session => [%d]", aControl);
       
   846 	ScheduleDraw('E');
       
   847 	}
       
   848 
       
   849 void CUsbTestConsole::SetDeviceType(TDeviceType aDeviceType)
       
   850 	{
       
   851 	iDeviceType = aDeviceType;
       
   852 
       
   853 	switch ( aDeviceType )
       
   854 		{
       
   855 	case ENoDevice:
       
   856 		iAttachedDevice =
       
   857 			//  12345
       
   858 			_L("     ");
       
   859 		break;
       
   860 	case EGenericDevice:
       
   861 		iAttachedDevice =
       
   862 			//  12345
       
   863 			_L("<   >");
       
   864 		break;
       
   865 	case ELogitechHeadset:
       
   866 		iAttachedDevice =
       
   867 			//  12345
       
   868 			_L("<<A>>");
       
   869 		break;
       
   870 		}
       
   871 	LOG("Audio Device => [%S]", &iAttachedDevice);
       
   872 	ScheduleDraw('E');
       
   873 	}
       
   874 	
       
   875 TBool CUsbTestConsole::GetAutoSrpResponseState()
       
   876 	{
       
   877 	return iAutoSrpResponse;
       
   878 	}
       
   879 	
       
   880 void CUsbTestConsole::SetAutoSrpResponseState(TBool aAutoSrpResponse)
       
   881 	{
       
   882 	iAutoSrpResponse = aAutoSrpResponse;
       
   883 	
       
   884 	if ( aAutoSrpResponse )
       
   885 		{
       
   886 		iSrpState = _L("Auto");
       
   887 		}
       
   888 	else
       
   889 		{
       
   890 		iSrpState = _L("    ");
       
   891 		}
       
   892 	}
       
   893 
       
   894 void CUsbTestConsole::NotifyEvent(XUsbTestConsoleEvent* aEvent)
       
   895 	{
       
   896 	__ASSERT_ALWAYS(aEvent, PANIC);
       
   897 	__ASSERT_ALWAYS(aEvent->iEvent.Length() <= KNumCharactersOnLine, PANIC);
       
   898 
       
   899 	iEventList.AddFirst(*aEvent);
       
   900 	delete iEventList.Last();
       
   901 	LOG("Event => %S", &(aEvent->iEvent));
       
   902 	ScheduleDraw('E');
       
   903 	}
       
   904 
       
   905 void CUsbTestConsole::Draw()
       
   906 	{
       
   907 	iConsole->ClearScreen();
       
   908 	
       
   909 	// First line is the server version number (and session state)
       
   910 	TVersionName versionName = iVersion.Name();
       
   911 	iConsole->Printf(_L(
       
   912 //          1         2         3         4         5
       
   913 // 12345678901234567890123456789012345678901234567890123
       
   914   "Server Version: %S   %S\n"
       
   915 	),
       
   916 	&versionName, &iControlSession
       
   917 	);
       
   918 
       
   919 	// Print "dash board"
       
   920 	iConsole->Printf(_L(
       
   921 //          1         2         3         4         5
       
   922 // 12345678901234567890123456789012345678901234567890123
       
   923   "Device              OTG          Host          "L"%S\n"
       
   924 //          12345678901        12345                123
       
   925  L"Service: %S"      L"Id Pin: %S"L"Driver Loading: %S\n"
       
   926  L"Device:  %S"      L"V. Bus: %S"L"Attached Devs:  %S\n"
       
   927  //           1234567890123           12345
       
   928  L"OTG State: %S "        L"Device: %S " L"SRP: %S\n"
       
   929 	),
       
   930 	&iConnectionIdle,
       
   931     &iServStatus, &iIdPin, &iDriverLoading,
       
   932 	&iDevStatus, &iVBus, &iAttachedDevices,
       
   933 	&iOtgState, &iAttachedDevice, &iSrpState
       
   934 	);
       
   935 
       
   936 	if (iHelp)
       
   937 		{
       
   938 		//                     12345678901234567890123456789012345678901234567890123
       
   939 		iConsole->Printf(_L("\nHelp:Available Command Selections"));
       
   940 		iConsole->Printf(_L("\n"));
       
   941 		iConsole->Printf(_L("\n '?'/'h'/'H' = Help (show these menu commands)"));
       
   942 		iConsole->Printf(_L("\n 'v'/'V' = Toggle 'verbose' logging"));
       
   943 		iConsole->Printf(_L("\n 'q'/'Q' = Quit application"));
       
   944 		iConsole->Printf(_L("\n 'c'/'C' = Toggle control session"));
       
   945 		iConsole->Printf(_L("\n 's' = Start()           'S' = Stop()"));
       
   946 		iConsole->Printf(_L("\n 't' = TryStart()        'T' = TryStop()"));
       
   947 		iConsole->Printf(_L("\n 'p'/'P' = Enter personality number (for TryStart())"));
       
   948 		iConsole->Printf(_L("\n 'e'/'E' = Toggle 'enable driver loading'"));
       
   949 		iConsole->Printf(_L("\n 'b' = BusRequest()      'B' = BusDrop()"));
       
   950 		iConsole->Printf(_L("\n 'r' = Respond (positively) to SRP"));
       
   951 		iConsole->Printf(_L("\n 'R' = Toggle SRP Auto-Response"));
       
   952 		iConsole->Printf(_L("\n 'x'/'X' = Clear Bus Error (A_VBUS_ERR)"));
       
   953 		iConsole->Printf(_L("\n 'a'/'A' = Check audio capability"));
       
   954 		iConsole->Printf(_L("\n '[' = Perform USBMAN test"));
       
   955 		}
       
   956 	else
       
   957 		{
       
   958 		// Events...
       
   959 		TDblQueIter<XUsbTestConsoleEvent> iter(iEventList);
       
   960 		XUsbTestConsoleEvent* event = NULL;
       
   961 		while((event = iter++) != NULL)
       
   962 			{
       
   963 			iConsole->Printf(_L("\n"));
       
   964 			iConsole->Printf(event->iEvent.Left(KNumCharactersOnLine-1));
       
   965 			}
       
   966 		}
       
   967 	}
       
   968 	
       
   969 	
       
   970 
       
   971 CUsbTestConsoleTextEntryBase::CUsbTestConsoleTextEntryBase()
       
   972 	: CActive(EPriorityNormal)
       
   973 	{
       
   974 	CActiveScheduler::Add(this);
       
   975 	}
       
   976 
       
   977 CUsbTestConsoleTextEntryBase::~CUsbTestConsoleTextEntryBase()
       
   978 	{
       
   979 	Cancel();
       
   980 	iLink.Deque();
       
   981 	delete iEntryConsole;
       
   982 	iChars.Close();
       
   983 	}
       
   984 
       
   985 void CUsbTestConsoleTextEntryBase::ConstructL(const TDesC& aEntryField)
       
   986 	{
       
   987 	User::LeaveIfError(iChars.Create(KMaxNumOfChars));
       
   988 	iEntryConsole = Console::NewL(_L("UsbTestConsole Entry Console"), TSize(-1,-1));
       
   989 	iEntryConsole->Printf(aEntryField);
       
   990 	iEntryConsole->Printf(_L(": "));
       
   991 	iEntryConsole->Read(iStatus);
       
   992 	SetActive();
       
   993 	}
       
   994 
       
   995 void CUsbTestConsoleTextEntryBase::DoCancel()
       
   996 	{
       
   997 	iEntryConsole->ReadCancel();
       
   998 	}
       
   999 
       
  1000 void CUsbTestConsoleTextEntryBase::RunL()
       
  1001 	{
       
  1002 	TKeyCode code = iEntryConsole->KeyCode();
       
  1003 	switch(code)
       
  1004 		{
       
  1005 		case EKeyEnter:
       
  1006 				{
       
  1007 				TRAPD(err, ConvertAndSetL());
       
  1008 				if(err == KErrNone)
       
  1009 					{
       
  1010 					delete this;
       
  1011 					return;
       
  1012 					}
       
  1013 				}
       
  1014 			break;
       
  1015 		case EKeyEscape:
       
  1016 			delete this;
       
  1017 			return;
       
  1018 		case EKeyBackspace:
       
  1019 			if(iChars.Length() > 0)
       
  1020 				{
       
  1021 				iEntryConsole->SetCursorPosRel(TPoint(-1, 0));
       
  1022 				iEntryConsole->ClearToEndOfLine();
       
  1023 				iChars.SetLength(iChars.Length()-1);
       
  1024 				}
       
  1025 			break;
       
  1026 		default:
       
  1027 			iChars.Append(code);
       
  1028 			iEntryConsole->Printf(_L("%c"), code);
       
  1029 			break;
       
  1030 		}
       
  1031 	iEntryConsole->Read(iStatus);
       
  1032 	SetActive();
       
  1033 	}
       
  1034 
       
  1035 
       
  1036 template<typename T>
       
  1037 CUsbTestConsoleTextEntry<T>* CUsbTestConsoleTextEntry<T>::NewL(T& aValue, const TDesC& aEntryField)
       
  1038 	{
       
  1039 	CUsbTestConsoleTextEntry<T>* self = new(ELeave) CUsbTestConsoleTextEntry<T>(aValue);
       
  1040 	CleanupStack::PushL(self);
       
  1041 	self->ConstructL(aEntryField);
       
  1042 	CleanupStack::Pop(self);
       
  1043 	return self;
       
  1044 	}
       
  1045 
       
  1046 template<typename T>
       
  1047 CUsbTestConsoleTextEntry<T>::~CUsbTestConsoleTextEntry()
       
  1048 	{
       
  1049 	}
       
  1050 
       
  1051 template<typename T>
       
  1052 CUsbTestConsoleTextEntry<T>::CUsbTestConsoleTextEntry(T& aValue)
       
  1053 	: CUsbTestConsoleTextEntryBase()
       
  1054 	, iValue(aValue)
       
  1055 	{
       
  1056 	}
       
  1057 
       
  1058 template<>
       
  1059 void CUsbTestConsoleTextEntry<TUint>::ConvertAndSetL()
       
  1060 	{
       
  1061 	TLex lex(iChars);
       
  1062 	
       
  1063 	lex.SkipSpaceAndMark();
       
  1064 
       
  1065 	TBool hex = ETrue;
       
  1066 	if (lex.Get() != '0' || lex.Get() != 'x')
       
  1067 		{
       
  1068 		lex.UnGetToMark();
       
  1069 		hex = EFalse;
       
  1070 		}
       
  1071 		
       
  1072 	TUint val;
       
  1073 	TRadix rad = hex ? EHex : EDecimal;
       
  1074 	User::LeaveIfError(lex.Val(val, rad));
       
  1075 	
       
  1076 	iValue = val;
       
  1077 	}
       
  1078 	
       
  1079 template<>
       
  1080 void CUsbTestConsoleTextEntry<TInt>::ConvertAndSetL()
       
  1081 	{
       
  1082 	TLex lex(iChars);
       
  1083 	
       
  1084 	lex.SkipSpaceAndMark();
       
  1085 
       
  1086 	TUint val;
       
  1087 	User::LeaveIfError(lex.Val(val, EDecimal));
       
  1088 	
       
  1089 	iValue = val;
       
  1090 	}
       
  1091 
       
  1092 
       
  1093 
       
  1094 
       
  1095 
       
  1096 
       
  1097 
       
  1098 
       
  1099 	
       
  1100 
       
  1101 
       
  1102 CEventNotifier::CEventNotifier(TInt aPriority)
       
  1103 	: CActive(aPriority)
       
  1104 	{
       
  1105 	}
       
  1106 
       
  1107 XUsbTestConsoleEvent* CEventNotifier::NewConsoleEventL()
       
  1108 	{
       
  1109 	XUsbTestConsoleEvent* event = new(ELeave) XUsbTestConsoleEvent;
       
  1110 	CleanupStack::PushL(event);
       
  1111 	User::LeaveIfError(event->iEvent.Create(CUsbTestConsole::KNumCharactersOnLine-1));
       
  1112 	CleanupStack::Pop();
       
  1113 	return event;
       
  1114 	}
       
  1115 
       
  1116 void CEventNotifier::RunL()
       
  1117 	{
       
  1118 	DoRunL(NewConsoleEventL());
       
  1119 	}
       
  1120 
       
  1121 
       
  1122 CServiceStateWatcher* CServiceStateWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1123 	{
       
  1124 	CServiceStateWatcher* self = new(ELeave) CServiceStateWatcher(aTestConsole);
       
  1125 	CleanupStack::PushL(self);
       
  1126 	self->ConstructL();
       
  1127 	CleanupStack::Pop(self);
       
  1128 	return self;
       
  1129 	}
       
  1130 CServiceStateWatcher::~CServiceStateWatcher()
       
  1131 	{
       
  1132 	Cancel();
       
  1133 	}
       
  1134 
       
  1135 CServiceStateWatcher::CServiceStateWatcher(CUsbTestConsole& aTestConsole)
       
  1136 	: CEventNotifier(EPriorityStandard)
       
  1137 	, iTestConsole(aTestConsole)
       
  1138 	, iServiceState(EUsbServiceIdle)
       
  1139 	{
       
  1140 	CActiveScheduler::Add(this);
       
  1141 	}
       
  1142 
       
  1143 void CServiceStateWatcher::ConstructL()
       
  1144 	{
       
  1145 	iTestConsole.Usb().ServiceStateNotification(iServiceState, iStatus);
       
  1146 	SetActive();
       
  1147 
       
  1148 	TUsbServiceState serviceState;
       
  1149 	User::LeaveIfError(iTestConsole.Usb().GetServiceState(serviceState));
       
  1150 	iTestConsole.SetServiceState(serviceState);
       
  1151 	}
       
  1152 
       
  1153 void CServiceStateWatcher::DoCancel()
       
  1154 	{
       
  1155 	iTestConsole.Usb().ServiceStateNotificationCancel();
       
  1156 	}
       
  1157 
       
  1158 void CServiceStateWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1159 	{
       
  1160 	iTestConsole.SetServiceState(iServiceState);
       
  1161 	TPtrC res(NULL, 0);
       
  1162 	_LIT(KIdle, "Idle");
       
  1163 	_LIT(KStarting, "Starting");
       
  1164 	_LIT(KStarted, "Started");
       
  1165 	_LIT(KStopping, "Stopping");
       
  1166 	_LIT(KError, "Error");
       
  1167 	switch(iServiceState)
       
  1168 		{
       
  1169 	case EUsbServiceIdle:
       
  1170 		res.Set(KIdle);
       
  1171 		break;
       
  1172 	case EUsbServiceStarting:
       
  1173 		res.Set(KStarting);
       
  1174 		break;
       
  1175 	case EUsbServiceStarted:
       
  1176 		res.Set(KStarted);
       
  1177 		break;
       
  1178 	case EUsbServiceStopping:
       
  1179 		res.Set(KStopping);
       
  1180 		break;
       
  1181 	case EUsbServiceFatalError:
       
  1182 		res.Set(KError);
       
  1183 		break;
       
  1184 	default:
       
  1185 		PANIC;
       
  1186 		break;
       
  1187 		}
       
  1188 		
       
  1189 	iTestConsole.Usb().ServiceStateNotification(iServiceState, iStatus);
       
  1190 	SetActive();
       
  1191 
       
  1192 	aEvent->iEvent.AppendFormat(_L("D:ServiceState [%S]"), &res);
       
  1193 	iTestConsole.NotifyEvent(aEvent);
       
  1194 
       
  1195 	// Seems like there can be race conditions
       
  1196 	TUsbServiceState serviceState;
       
  1197 	User::LeaveIfError(iTestConsole.Usb().GetServiceState(serviceState));
       
  1198 
       
  1199 	iTestConsole.SetServiceState(serviceState);
       
  1200 	}
       
  1201 
       
  1202 	
       
  1203 CDeviceStateWatcher* CDeviceStateWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1204 	{
       
  1205 	CDeviceStateWatcher* self = new(ELeave) CDeviceStateWatcher(aTestConsole);
       
  1206 	CleanupStack::PushL(self);
       
  1207 	self->ConstructL();
       
  1208 	CleanupStack::Pop(self);
       
  1209 	return self;
       
  1210 	}
       
  1211 CDeviceStateWatcher::~CDeviceStateWatcher()
       
  1212 	{
       
  1213 	Cancel();
       
  1214 	}
       
  1215 
       
  1216 CDeviceStateWatcher::CDeviceStateWatcher(CUsbTestConsole& aTestConsole)
       
  1217 	: CEventNotifier(EPriorityStandard)
       
  1218 	, iTestConsole(aTestConsole)
       
  1219 	{
       
  1220 	CActiveScheduler::Add(this);
       
  1221 	}
       
  1222 
       
  1223 void CDeviceStateWatcher::ConstructL()
       
  1224 	{
       
  1225 	iTestConsole.Usb().DeviceStateNotification(0xffffffff, iDeviceState, iStatus);
       
  1226 	SetActive();
       
  1227 
       
  1228 	TUsbDeviceState deviceState;
       
  1229 	User::LeaveIfError(iTestConsole.Usb().GetDeviceState(deviceState));
       
  1230 	iTestConsole.SetDeviceState(deviceState);
       
  1231 	}
       
  1232 
       
  1233 void CDeviceStateWatcher::DoCancel()
       
  1234 	{
       
  1235 	iTestConsole.Usb().DeviceStateNotificationCancel();
       
  1236 	}
       
  1237 
       
  1238 void CDeviceStateWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1239 	{
       
  1240 	iTestConsole.SetDeviceState(iDeviceState);
       
  1241 	TPtrC res(NULL, 0);
       
  1242 	_LIT(KUndefined, "Undefined");
       
  1243     _LIT(KDefault, "Default");
       
  1244     _LIT(KAttached, "Attached");
       
  1245     _LIT(KPowered, "Powered");
       
  1246     _LIT(KConfigured, "Configured");
       
  1247     _LIT(KAddress, "Address");
       
  1248     _LIT(KSuspended, "Suspended");
       
  1249 	switch(iDeviceState)
       
  1250 		{
       
  1251 	case EUsbDeviceStateUndefined:
       
  1252 		res.Set(KUndefined);
       
  1253 		break;
       
  1254 	case EUsbDeviceStateDefault:
       
  1255 		res.Set(KDefault);
       
  1256 		break;
       
  1257 	case EUsbDeviceStateAttached:
       
  1258 		res.Set(KAttached);
       
  1259 		break;
       
  1260 	case EUsbDeviceStatePowered:
       
  1261 		res.Set(KPowered);
       
  1262 		break;
       
  1263 	case EUsbDeviceStateConfigured:
       
  1264 		res.Set(KConfigured);
       
  1265 		break;
       
  1266 	case EUsbDeviceStateAddress:
       
  1267 		res.Set(KAddress);
       
  1268 		break;
       
  1269 	case EUsbDeviceStateSuspended:
       
  1270 		res.Set(KSuspended);
       
  1271 		break;
       
  1272 	default:
       
  1273 		PANIC;
       
  1274 		break;
       
  1275 		}
       
  1276 
       
  1277     iTestConsole.Usb().DeviceStateNotification(0xffffffff, iDeviceState, iStatus);
       
  1278 	SetActive();
       
  1279 
       
  1280 	aEvent->iEvent.AppendFormat(_L("D:DeviceState [%S]"), &res);
       
  1281 	iTestConsole.NotifyEvent(aEvent);
       
  1282 
       
  1283 	// Seems like there can be race conditions
       
  1284 	TUsbDeviceState deviceState;
       
  1285 	User::LeaveIfError(iTestConsole.Usb().GetDeviceState(deviceState));
       
  1286 
       
  1287 	iTestConsole.SetDeviceState(deviceState);
       
  1288 	}
       
  1289 	
       
  1290 CConnectionIdleWatcher* CConnectionIdleWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1291 	{
       
  1292 	CConnectionIdleWatcher * self = new(ELeave) CConnectionIdleWatcher (aTestConsole);
       
  1293 	CleanupStack::PushL(self);
       
  1294 	self->ConstructL();
       
  1295 	CleanupStack::Pop(self);
       
  1296 	return self;
       
  1297 	}
       
  1298 CConnectionIdleWatcher::~CConnectionIdleWatcher()
       
  1299 	{
       
  1300 	Cancel();
       
  1301 	iConnectionIdleProp.Close();
       
  1302 	}
       
  1303 
       
  1304 CConnectionIdleWatcher::CConnectionIdleWatcher(CUsbTestConsole& aTestConsole)
       
  1305 	: CEventNotifier(EPriorityStandard)
       
  1306 	, iTestConsole(aTestConsole)
       
  1307 	{
       
  1308 	CActiveScheduler::Add(this);
       
  1309 	}
       
  1310 
       
  1311 void CConnectionIdleWatcher::ConstructL()
       
  1312 	{
       
  1313 	User::LeaveIfError(iConnectionIdleProp.Attach(KUidUsbManCategory, KUsbOtgConnectionIdleProperty));
       
  1314 	iConnectionIdleProp.Subscribe(iStatus);
       
  1315 	SetActive();
       
  1316 
       
  1317 	TInt val;
       
  1318 	TInt err = iConnectionIdleProp.Get(val);
       
  1319 	LOG("CConnectionIdleWatcher::ConstructL iConnectionIdleProp.Get(val) => val=%d", val);
       
  1320 	User::LeaveIfError(err);
       
  1321 	iTestConsole.SetConnectionIdle(val);
       
  1322 	}
       
  1323 
       
  1324 void CConnectionIdleWatcher::DoCancel()
       
  1325 	{
       
  1326 	iConnectionIdleProp.Cancel();
       
  1327 	}
       
  1328 
       
  1329 void CConnectionIdleWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1330 	{
       
  1331 	CleanupStack::PushL(aEvent);
       
  1332 
       
  1333 	iConnectionIdleProp.Subscribe(iStatus);
       
  1334 	SetActive();
       
  1335 
       
  1336 	TInt val;
       
  1337 	User::LeaveIfError(iConnectionIdleProp.Get(val));
       
  1338 
       
  1339 	TPtrC res(NULL, 0);
       
  1340 	_LIT(KConnectionIdle, "Idle");
       
  1341 	_LIT(KConnectionBusy, "Busy");
       
  1342 	switch(val)
       
  1343 		{
       
  1344 	case 0:
       
  1345 		res.Set(KConnectionBusy);
       
  1346 		break;
       
  1347 
       
  1348 	case 1:
       
  1349 		res.Set(KConnectionIdle);
       
  1350 		break;
       
  1351 
       
  1352 	default:
       
  1353 		PANIC;
       
  1354 		break;
       
  1355 		}
       
  1356 	CleanupStack::Pop();
       
  1357 
       
  1358 	aEvent->iEvent.AppendFormat(_L("O:ConnectionIdle [%S]"), &res);
       
  1359 	iTestConsole.SetConnectionIdle(val);
       
  1360 	iTestConsole.NotifyEvent(aEvent);
       
  1361 	}
       
  1362 	
       
  1363 	
       
  1364 CIdPinWatcher* CIdPinWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1365 	{
       
  1366 	CIdPinWatcher* self = new(ELeave) CIdPinWatcher(aTestConsole);
       
  1367 	CleanupStack::PushL(self);
       
  1368 	self->ConstructL();
       
  1369 	CleanupStack::Pop(self);
       
  1370 	return self;
       
  1371 	}
       
  1372 CIdPinWatcher::~CIdPinWatcher()
       
  1373 	{
       
  1374 	Cancel();
       
  1375 	iIdPinProp.Close();
       
  1376 	}
       
  1377 
       
  1378 CIdPinWatcher::CIdPinWatcher(CUsbTestConsole& aTestConsole)
       
  1379 	: CEventNotifier(EPriorityStandard)
       
  1380 	, iTestConsole(aTestConsole)
       
  1381 	{
       
  1382 	CActiveScheduler::Add(this);
       
  1383 	}
       
  1384 
       
  1385 void CIdPinWatcher::ConstructL()
       
  1386 	{
       
  1387 	User::LeaveIfError(iIdPinProp.Attach(KUidUsbManCategory, KUsbOtgIdPinPresentProperty));
       
  1388 	iIdPinProp.Subscribe(iStatus);
       
  1389 	SetActive();
       
  1390 
       
  1391 	TInt val;
       
  1392 	TInt err = iIdPinProp.Get(val);
       
  1393 	LOG("CIdPinWatcher::ConstructL iIdPinProp.Get(val) => %d",err);
       
  1394 	User::LeaveIfError(err);
       
  1395 	iTestConsole.SetIdPin(val);
       
  1396 	}
       
  1397 
       
  1398 void CIdPinWatcher::DoCancel()
       
  1399 	{
       
  1400 	iIdPinProp.Cancel();
       
  1401 	}
       
  1402 
       
  1403 void CIdPinWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1404 	{
       
  1405 	CleanupStack::PushL(aEvent);
       
  1406 
       
  1407 	iIdPinProp.Subscribe(iStatus);
       
  1408 	SetActive();
       
  1409 
       
  1410 	TInt val;
       
  1411 	User::LeaveIfError(iIdPinProp.Get(val));
       
  1412 
       
  1413 	TPtrC res(NULL, 0);
       
  1414 	_LIT(KIdPinInserted, "Inserted");
       
  1415 	_LIT(KIdPinRemoved, "Removed");
       
  1416 	switch(val)
       
  1417 		{
       
  1418 	case 0:
       
  1419 		res.Set(KIdPinRemoved);
       
  1420 		break;
       
  1421 
       
  1422 	case 1:
       
  1423 		res.Set(KIdPinInserted);
       
  1424 		break;
       
  1425 
       
  1426 	default:
       
  1427 		PANIC;
       
  1428 		break;
       
  1429 		}
       
  1430 	CleanupStack::Pop();
       
  1431 
       
  1432 	aEvent->iEvent.AppendFormat(_L("O:IdPin [%S]"), &res);
       
  1433 	iTestConsole.SetIdPin(val);
       
  1434 	iTestConsole.NotifyEvent(aEvent);
       
  1435 	}
       
  1436 	
       
  1437 	
       
  1438 CVBusWatcher* CVBusWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1439 	{
       
  1440 	CVBusWatcher* self = new(ELeave) CVBusWatcher(aTestConsole);
       
  1441 	CleanupStack::PushL(self);
       
  1442 	self->ConstructL();
       
  1443 	CleanupStack::Pop(self);
       
  1444 	return self;
       
  1445 	}
       
  1446 CVBusWatcher::~CVBusWatcher()
       
  1447 	{
       
  1448 	Cancel();
       
  1449 	iVBusProp.Close();
       
  1450 	}
       
  1451 
       
  1452 CVBusWatcher::CVBusWatcher(CUsbTestConsole& aTestConsole)
       
  1453 	: CEventNotifier(EPriorityStandard)
       
  1454 	, iTestConsole(aTestConsole)
       
  1455 	{
       
  1456 	CActiveScheduler::Add(this);
       
  1457 	}
       
  1458 
       
  1459 void CVBusWatcher::ConstructL()
       
  1460 	{
       
  1461 	User::LeaveIfError(iVBusProp.Attach(KUidUsbManCategory, KUsbOtgVBusPoweredProperty));
       
  1462 	iVBusProp.Subscribe(iStatus);
       
  1463 	SetActive();
       
  1464 
       
  1465 	TInt val;
       
  1466 	User::LeaveIfError(iVBusProp.Get(val));
       
  1467 	iTestConsole.SetVBus(val);
       
  1468 	}
       
  1469 
       
  1470 void CVBusWatcher::DoCancel()
       
  1471 	{
       
  1472 	iVBusProp.Cancel();
       
  1473 	}
       
  1474 
       
  1475 void CVBusWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1476 	{
       
  1477 	CleanupStack::PushL(aEvent);
       
  1478 
       
  1479 	iVBusProp.Subscribe(iStatus);
       
  1480 	SetActive();
       
  1481 
       
  1482 	TInt val;
       
  1483 	User::LeaveIfError(iVBusProp.Get(val));
       
  1484 
       
  1485 	TPtrC res(NULL, 0);
       
  1486 	_LIT(KVBusRaised, "Raised");
       
  1487 	_LIT(KVBusDropped, "Dropped");
       
  1488 	switch(val)
       
  1489 		{
       
  1490 	case 0:
       
  1491 		{
       
  1492 		if ( iTestConsole.GetAutoSrpResponseState() ) 
       
  1493 			{
       
  1494 			(iTestConsole.Timer())->Cancel();
       
  1495 			}
       
  1496 		res.Set(KVBusDropped);
       
  1497 		break;
       
  1498 		}
       
  1499 	case 1:
       
  1500 		res.Set(KVBusRaised);
       
  1501 		break;
       
  1502 
       
  1503 	default:
       
  1504 		PANIC;
       
  1505 		break;
       
  1506 		}
       
  1507 	CleanupStack::Pop();
       
  1508 
       
  1509 	aEvent->iEvent.AppendFormat(_L("O:VBus [%S]"), &res);
       
  1510 	iTestConsole.SetVBus(val);
       
  1511 	iTestConsole.NotifyEvent(aEvent);
       
  1512 	}
       
  1513 	
       
  1514 COtgStateWatcher* COtgStateWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1515 	{
       
  1516 	COtgStateWatcher* self = new(ELeave) COtgStateWatcher(aTestConsole);
       
  1517 	CleanupStack::PushL(self);
       
  1518 	self->ConstructL();
       
  1519 	CleanupStack::Pop(self);
       
  1520 	return self;
       
  1521 	}
       
  1522 
       
  1523 COtgStateWatcher::~COtgStateWatcher()
       
  1524 	{
       
  1525 	Cancel();
       
  1526 	iOtgStateProp.Close();
       
  1527 	}
       
  1528 
       
  1529 COtgStateWatcher::COtgStateWatcher(CUsbTestConsole& aTestConsole)
       
  1530 	: CEventNotifier(EPriorityStandard)
       
  1531 	, iTestConsole(aTestConsole)
       
  1532 	{
       
  1533 	CActiveScheduler::Add(this);
       
  1534 	}
       
  1535 
       
  1536 void COtgStateWatcher::ConstructL()
       
  1537 	{
       
  1538 	User::LeaveIfError(iOtgStateProp.Attach(KUidUsbManCategory, KUsbOtgStateProperty));
       
  1539 	iOtgStateProp.Subscribe(iStatus);
       
  1540 	SetActive();
       
  1541 
       
  1542 	TInt val;
       
  1543 	User::LeaveIfError(iOtgStateProp.Get(val));
       
  1544 	iTestConsole.SetOtgState(val);
       
  1545 	}
       
  1546 
       
  1547 void COtgStateWatcher::DoCancel()
       
  1548 	{
       
  1549 	iOtgStateProp.Cancel();
       
  1550 	}
       
  1551 
       
  1552 void COtgStateWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1553 	{
       
  1554 	CleanupStack::PushL(aEvent);
       
  1555 
       
  1556 	iOtgStateProp.Subscribe(iStatus);
       
  1557 	SetActive();
       
  1558 
       
  1559 	TInt val;
       
  1560 	User::LeaveIfError(iOtgStateProp.Get(val));
       
  1561 
       
  1562 	TPtrC res(NULL, 0);
       
  1563 	
       
  1564 	_LIT(KReset, 		"Reset"			);
       
  1565 
       
  1566 	_LIT(KAIdle, 		"A-Idle"		);
       
  1567 	_LIT(KAHost, 		"A-Host"		);
       
  1568 	_LIT(KAPeripheral, 	"A-Peripheral"	);
       
  1569 	_LIT(KABusError, 	"A-Bus Error"	);
       
  1570 	
       
  1571 	_LIT(KBIdle, 		"B-Idle"		);
       
  1572 	_LIT(KBPeripheral, 	"B-Peripheral"	);
       
  1573 	_LIT(KBHost, 		"B-Host"		);
       
  1574 	
       
  1575 	_LIT(KUnknown, 		"Unknown"		);
       
  1576 
       
  1577 	switch(val)
       
  1578 		{
       
  1579 	case EUsbOtgStateReset:
       
  1580 		res.Set(KReset);
       
  1581 		break;
       
  1582 
       
  1583 	case EUsbOtgStateAIdle:
       
  1584 		res.Set(KAIdle);
       
  1585 		break;
       
  1586 
       
  1587 	case EUsbOtgStateAHost:
       
  1588 		if ( iTestConsole.GetAutoSrpResponseState() ) 
       
  1589 			{
       
  1590 			(iTestConsole.Timer())->Cancel();
       
  1591 			}
       
  1592 		res.Set(KAHost);
       
  1593 		break;
       
  1594 
       
  1595 	case EUsbOtgStateAPeripheral:
       
  1596 		res.Set(KAPeripheral);
       
  1597 		break;
       
  1598 
       
  1599 	case EUsbOtgStateAVbusError:
       
  1600 		res.Set(KABusError);
       
  1601 		break;
       
  1602 
       
  1603 	case EUsbOtgStateBIdle:
       
  1604 		res.Set(KBIdle);
       
  1605 		break;
       
  1606 
       
  1607 	case EUsbOtgStateBPeripheral:
       
  1608 		res.Set(KBPeripheral);
       
  1609 		break;
       
  1610 		
       
  1611 	case EUsbOtgStateBHost:
       
  1612 		res.Set(KBHost);
       
  1613 		break;
       
  1614 
       
  1615 	default:
       
  1616 		res.Set(KUnknown);
       
  1617 		break;
       
  1618 		}
       
  1619 	CleanupStack::Pop();
       
  1620 
       
  1621 	aEvent->iEvent.AppendFormat(_L("O:OtgState [%S]"), &res);
       
  1622 	iTestConsole.SetOtgState(val);
       
  1623 	iTestConsole.NotifyEvent(aEvent);
       
  1624 	}
       
  1625 
       
  1626 CHostEventWatcher* CHostEventWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1627 	{
       
  1628 	CHostEventWatcher* self = new(ELeave) CHostEventWatcher(aTestConsole);
       
  1629 	CleanupStack::PushL(self);
       
  1630 	self->ConstructL();
       
  1631 	CleanupStack::Pop(self);
       
  1632 	return self;
       
  1633 	}
       
  1634 
       
  1635 CHostEventWatcher::~CHostEventWatcher()
       
  1636 	{
       
  1637 	Cancel();
       
  1638 	}
       
  1639 
       
  1640 CHostEventWatcher::CHostEventWatcher(CUsbTestConsole& aTestConsole)
       
  1641 	: CEventNotifier(EPriorityStandard)
       
  1642 	, iTestConsole(aTestConsole)
       
  1643 	{
       
  1644 	CActiveScheduler::Add(this);
       
  1645 	}
       
  1646 
       
  1647 void CHostEventWatcher::ConstructL()
       
  1648 	{
       
  1649 	iTestConsole.Usb().HostEventNotification(iStatus, iDeviceInfo);
       
  1650 	SetActive();
       
  1651 	iTestConsole.SetAttachedDevices(0);
       
  1652 	}
       
  1653 
       
  1654 void CHostEventWatcher::DoCancel()
       
  1655 	{
       
  1656 	iTestConsole.Usb().HostEventNotificationCancel();
       
  1657 	}
       
  1658 
       
  1659 void CHostEventWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1660 	{
       
  1661 	CleanupStack::PushL(aEvent);
       
  1662 
       
  1663 	switch(iDeviceInfo.iEventType)
       
  1664 		{
       
  1665 	case EDeviceAttachment:
       
  1666 			{
       
  1667 			if(iDeviceInfo.iError == KErrNone)
       
  1668 				{
       
  1669 				User::LeaveIfError(iAttachedDevices.Append(iDeviceInfo.iDeviceId));
       
  1670 				}
       
  1671 			aEvent->iEvent.AppendFormat(_L("H:Attach[%08x] Err[%d] VidPid[%04x,%04x]"), iDeviceInfo.iDeviceId, iDeviceInfo.iError, iDeviceInfo.iVid, iDeviceInfo.iPid);
       
  1672 			
       
  1673 			if (  (iDeviceInfo.iVid == 0x046D)
       
  1674 			    &&(iDeviceInfo.iPid == 0x0A02)
       
  1675 			   )
       
  1676 				{
       
  1677 				iTestConsole.SetDeviceType(CUsbTestConsole::ELogitechHeadset);
       
  1678 				}
       
  1679 			else
       
  1680 				{
       
  1681 				iTestConsole.SetDeviceType(CUsbTestConsole::EGenericDevice);
       
  1682 				}
       
  1683 			}
       
  1684 		break;
       
  1685 
       
  1686 	case EDriverLoad:
       
  1687 			{
       
  1688 			TPtrC res(NULL, 0);
       
  1689 			_LIT(KDriverLoadSuccess, "Success");
       
  1690 			_LIT(KDriverLoadPartialSuccess, "Warning");
       
  1691 			_LIT(KDriverLoadFailure, "Failure");
       
  1692 			switch(iDeviceInfo.iDriverLoadStatus)
       
  1693 				{
       
  1694 			case EDriverLoadSuccess:
       
  1695 				res.Set(KDriverLoadSuccess);
       
  1696 				break;
       
  1697 			case EDriverLoadPartialSuccess:
       
  1698 				res.Set(KDriverLoadPartialSuccess);
       
  1699 				break;
       
  1700 			case EDriverLoadFailure:
       
  1701 				res.Set(KDriverLoadFailure);
       
  1702 				break;
       
  1703 			default:
       
  1704 				PANIC;
       
  1705 				break;
       
  1706 				}
       
  1707 			aEvent->iEvent.AppendFormat(_L("H:Load[%08x] Err[%d] Status[%S]"), iDeviceInfo.iDeviceId, iDeviceInfo.iError, &res);
       
  1708 			}
       
  1709 		break;
       
  1710 
       
  1711 	case EDeviceDetachment:
       
  1712 			{
       
  1713 			aEvent->iEvent.AppendFormat(_L("H:Detach [%08x]"), iDeviceInfo.iDeviceId);
       
  1714 			TInt ix = iAttachedDevices.Find(iDeviceInfo.iDeviceId);
       
  1715 			if(ix == KErrNotFound)
       
  1716 				{
       
  1717 				// This is probably caused by starting a new instance of the test console.
       
  1718 				break;
       
  1719 				}
       
  1720 			iAttachedDevices.Remove(ix);
       
  1721 			iTestConsole.SetDeviceType(CUsbTestConsole::ENoDevice);
       
  1722 			}
       
  1723 		break;
       
  1724 	default:
       
  1725 		PANIC;
       
  1726 		break;
       
  1727 		}
       
  1728 	CleanupStack::Pop();
       
  1729 	iTestConsole.SetAttachedDevices(iAttachedDevices.Count());
       
  1730 	iTestConsole.NotifyEvent(aEvent);
       
  1731 	iTestConsole.Usb().HostEventNotification(iStatus, iDeviceInfo);
       
  1732 	SetActive();
       
  1733 	}
       
  1734 	
       
  1735 	
       
  1736 CMessageWatcher* CMessageWatcher::NewL(CUsbTestConsole& aTestConsole)
       
  1737 	{
       
  1738 	CMessageWatcher* self = new(ELeave) CMessageWatcher(aTestConsole);
       
  1739 	CleanupStack::PushL(self);
       
  1740 	self->ConstructL();
       
  1741 	CleanupStack::Pop(self);
       
  1742 	return self;
       
  1743 	}
       
  1744 CMessageWatcher::~CMessageWatcher()
       
  1745 	{
       
  1746 	Cancel();
       
  1747 	}
       
  1748 
       
  1749 CMessageWatcher::CMessageWatcher(CUsbTestConsole& aTestConsole)
       
  1750 	: CEventNotifier(EPriorityStandard)
       
  1751 	, iTestConsole(aTestConsole)
       
  1752 	{
       
  1753 	CActiveScheduler::Add(this);
       
  1754 	}
       
  1755 
       
  1756 void CMessageWatcher::ConstructL()
       
  1757 	{
       
  1758 	iTestConsole.Usb().MessageNotification(iStatus, iMessage);
       
  1759 	SetActive();
       
  1760 	}
       
  1761 
       
  1762 void CMessageWatcher::DoCancel()
       
  1763 	{
       
  1764 	iTestConsole.Usb().MessageNotificationCancel();
       
  1765 	}
       
  1766 
       
  1767 void CMessageWatcher::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1768 	{
       
  1769 	TInt err = iStatus.Int();
       
  1770 	
       
  1771 	if (err)
       
  1772 		{
       
  1773 		aEvent->iEvent.AppendFormat(_L("O:Message[%d] Err[%d]"), iMessage, err);
       
  1774 		}
       
  1775 	else
       
  1776 		{
       
  1777 		TPtrC text(NULL, 0);
       
  1778 
       
  1779 		// OTGDI
       
  1780 		_LIT(KMessOtgdiEventQueueOverflow,			"O:Event Queue Overflow"			);
       
  1781 		_LIT(KMessOtgdiStateQueueOverflow,			"O:State Queue Overflow"			);
       
  1782 		_LIT(KMessOtgdiMessageQueueOverflow,		"O:Message Queue Overflow"			);
       
  1783 		_LIT(KMessOtgdiBadState,					"O:Bad State"						);
       
  1784 		_LIT(KMessOtgdiStackNotStarted,				"O:Stack Not Started"				);
       
  1785 		_LIT(KMessOtgdiVbusAlreadyRaised,			"O:VBUS Already Raised"				);
       
  1786 		_LIT(KMessOtgdiSrpForbidden,				"O:SRP Forbidden"					);
       
  1787 		_LIT(KMessOtgdiBusControlProblem,			"O:Bus Control Problem"				);
       
  1788 		_LIT(KMessOtgdiVbusPowerUpError,			"O:VBUS Power Up Error"				);		
       
  1789 		_LIT(KMessOtgdiHnpEnableProblem,			"O:HNP Enable Problem"				);		
       
  1790 		_LIT(KMessOtgdiPeriphNotSupported,			"O:Peripheral Not Supported"		);		
       
  1791 		_LIT(KMessOtgdiVbusError,					"O:VBUS Error"						);
       
  1792 		_LIT(KMessOtgdiSrpTimeout,					"O:SRP Timeout"						);
       
  1793 		_LIT(KMessOtgdiSrpActive,					"O:SRP Already Active"				);
       
  1794 		_LIT(KMessOtgdiSrpNotPermitted,				"O:SRP Not Permitted"				);
       
  1795 		_LIT(KMessOtgdiHnpNotPermitted,				"O:HNP Not Permitted"				);
       
  1796 		_LIT(KMessOtgdiHnpNotEnabled,				"O:HNP Not Enabled"					);
       
  1797 		_LIT(KMessOtgdiHnpNotSuspended,				"O:HNP Not Suspended"				);
       
  1798 		_LIT(KMessOtgdiVbusPowerUpNotPermitted,		"O:VBUS Power Up Not Permitted"		);
       
  1799 		_LIT(KMessOtgdiVbusPowerDownNotPermitted,	"O:VBUS Power Down Not Permitted"	);
       
  1800 		_LIT(KMessOtgdiVbusClearErrorNotPermitted,	"O:VBUS Clear Error Not Permitted"	);
       
  1801 		_LIT(KMessOtgdiHnpNotResponding,			"O:HNP Not Responding"				);
       
  1802 		_LIT(KMessOtgdiHnpBusDrop,					"O:VBUS Drop During HNP!"			);
       
  1803 
       
  1804 		// USBDI - Main
       
  1805 
       
  1806 		_LIT(KMessUsbdiRequestsPending,				"U:Requests Pending"				);		
       
  1807 		_LIT(KMessUsbdiBadAddress,					"U:Bad Address"						);
       
  1808 		_LIT(KMessUsbdiNoAddress,					"U:No Address"						);
       
  1809 		_LIT(KMessUsbdiSetAddrFailed,				"U:Set Address Failed"				);
       
  1810 		_LIT(KMessUsbdiNoPower,						"U:No Power"						);
       
  1811 		_LIT(KMessUsbdiTooDeep,						"U:Too Deep"						);
       
  1812 		_LIT(KMessUsbdiIOError,						"U:IO Error"						);
       
  1813 		_LIT(KMessUsbdiNotConfigured,				"U:Not Configured"					);
       
  1814 		_LIT(KMessUsbdiTimeout,						"U:Timeout"							);
       
  1815 		_LIT(KMessUsbdiStalled,						"U:Stalled"							);
       
  1816 		_LIT(KMessUsbdiTestFailure,					"U:Test Failure"					);
       
  1817 		_LIT(KMessUsbdiBadState,					"U:Bad State"						);
       
  1818 		_LIT(KMessUsbdiDeviceSuspended,				"U:Device Suspended"				);
       
  1819 
       
  1820 		// USBDI - Descriptors
       
  1821 
       
  1822 		_LIT(KMessUsbdiBadDescriptorTopology,		"U:Bad Descriptor Topology"			);
       
  1823 
       
  1824 		// USBDI - DevMon
       
  1825 
       
  1826 		_LIT(KMessUsbdiDeviceRejected,				"U:Device Rejected"					);
       
  1827 		_LIT(KMessUsbdiDeviceFailed,				"U:Device failed"					);
       
  1828 		_LIT(KMessUsbdiBadDevice,					"U:Bad Device"						);
       
  1829 		_LIT(KMessUsbdiBadHubPosition,				"U:Bad Hub Position"				);
       
  1830 		_LIT(KMessUsbdiBadHub,						"U:Bad Hub"							);
       
  1831 		_LIT(KMessUsbdiEventOverflow,				"U:Event Overflow"					);
       
  1832 		
       
  1833 		// USBMAN
       
  1834 		
       
  1835 		_LIT(KMessUsbmanSrpInitiated,				"M:SRP Initiated"					);
       
  1836 		_LIT(KMessUsbmanSrpReceived,				"M:SRP Received"					);
       
  1837 		_LIT(KMessUsbmanHnpDisabled,				"M:HNP Disabled"					);
       
  1838 		_LIT(KMessUsbmanHnpEnabled,					"M:HNP Enabled"						);
       
  1839 		_LIT(KMessUsbmanVbusRaised,					"M:VBUS Raised"						);
       
  1840 		_LIT(KMessUsbmanVbusDropped,				"M:VBUS Dropped"					);
       
  1841 		_LIT(KMessUsbmanRequestSession,				"M:Request Session"					);
       
  1842 
       
  1843 		_LIT(KMessUnknown, 							"*:Unknown"							);
       
  1844 
       
  1845 		switch(iMessage)
       
  1846 			{
       
  1847 			// OTGDI
       
  1848 
       
  1849 			case KErrUsbOtgEventQueueOverflow:			text.Set(KMessOtgdiEventQueueOverflow);			break;
       
  1850 			case KErrUsbOtgStateQueueOverflow:	       	text.Set(KMessOtgdiStateQueueOverflow);			break;
       
  1851 			case KErrUsbOtgMessageQueueOverflow:		text.Set(KMessOtgdiMessageQueueOverflow);		break;
       
  1852 			case KErrUsbOtgBadState:					text.Set(KMessOtgdiBadState);					break;		
       
  1853 			case KErrUsbOtgStackNotStarted:				text.Set(KMessOtgdiStackNotStarted);			break;	
       
  1854 			case KErrUsbOtgVbusAlreadyRaised:	       	text.Set(KMessOtgdiVbusAlreadyRaised);			break;
       
  1855 			case KErrUsbOtgSrpForbidden:				text.Set(KMessOtgdiSrpForbidden);				break;	
       
  1856 			case KErrUsbOtgBusControlProblem:	       	text.Set(KMessOtgdiBusControlProblem);			break;
       
  1857 			case KErrUsbOtgVbusPowerUpError:			text.Set(KMessOtgdiVbusPowerUpError);			break;		
       
  1858 			case KErrUsbOtgHnpEnableProblem:			text.Set(KMessOtgdiHnpEnableProblem);			break;		
       
  1859 			case KErrUsbOtgPeriphNotSupported:			text.Set(KMessOtgdiPeriphNotSupported);			break;		
       
  1860 			case KErrUsbOtgVbusError:			       	text.Set(KMessOtgdiVbusError);					break;		
       
  1861 			case KErrUsbOtgSrpTimeout:			       	text.Set(KMessOtgdiSrpTimeout);					break;		
       
  1862 			case KErrUsbOtgSrpActive:			       	text.Set(KMessOtgdiSrpActive);					break;		
       
  1863 			case KErrUsbOtgSrpNotPermitted:				text.Set(KMessOtgdiSrpNotPermitted);			break;
       
  1864 			case KErrUsbOtgHnpNotPermitted:				text.Set(KMessOtgdiHnpNotPermitted);			break;
       
  1865 			case KErrUsbOtgHnpNotEnabled:				text.Set(KMessOtgdiHnpNotEnabled);				break;
       
  1866 			case KErrUsbOtgHnpNotSuspended:				text.Set(KMessOtgdiHnpNotSuspended);			break;
       
  1867 			case KErrUsbOtgVbusPowerUpNotPermitted:  	text.Set(KMessOtgdiVbusPowerUpNotPermitted);	break;
       
  1868 			case KErrUsbOtgVbusPowerDownNotPermitted:	text.Set(KMessOtgdiVbusPowerDownNotPermitted);	break;
       
  1869 			case KErrUsbOtgVbusClearErrorNotPermitted:	text.Set(KMessOtgdiVbusClearErrorNotPermitted);	break;
       
  1870 			case KErrUsbOtgHnpNotResponding:			text.Set(KMessOtgdiHnpNotResponding);			break;
       
  1871 			case KErrUsbOtgHnpBusDrop:					text.Set(KMessOtgdiHnpBusDrop);					break;
       
  1872 
       
  1873 			// USBDI - Main
       
  1874 
       
  1875 			case KErrUsbRequestsPending:				text.Set(KMessUsbdiRequestsPending);			break;		
       
  1876 			case KErrUsbBadAddress:						text.Set(KMessUsbdiBadAddress); 				break;			
       
  1877 			case KErrUsbNoAddress:						text.Set(KMessUsbdiNoAddress); 					break;			
       
  1878 			case KErrUsbSetAddrFailed:					text.Set(KMessUsbdiSetAddrFailed); 				break;		
       
  1879 			case KErrUsbNoPower:						text.Set(KMessUsbdiNoPower); 					break;				
       
  1880 			case KErrUsbTooDeep:						text.Set(KMessUsbdiTooDeep); 					break;				
       
  1881 			case KErrUsbIOError:						text.Set(KMessUsbdiIOError); 					break;				
       
  1882 			case KErrUsbNotConfigured:					text.Set(KMessUsbdiNotConfigured); 				break;		
       
  1883 			case KErrUsbTimeout:						text.Set(KMessUsbdiTimeout); 					break;				
       
  1884 			case KErrUsbStalled:						text.Set(KMessUsbdiStalled); 					break;				
       
  1885 			case KErrUsbTestFailure:					text.Set(KMessUsbdiTestFailure); 				break;			
       
  1886 			case KErrUsbBadState:						text.Set(KMessUsbdiBadState); 					break;			
       
  1887 			case KErrUsbDeviceSuspended:				text.Set(KMessUsbdiDeviceSuspended); 			break;		
       
  1888 																									
       
  1889 			// USBDI - Descriptors																	
       
  1890 			
       
  1891 			case KErrUsbBadDescriptorTopology:			text.Set(KMessUsbdiBadDescriptorTopology); 		break;
       
  1892 
       
  1893 			// USBDI - DevMon
       
  1894 			
       
  1895 			case KErrUsbDeviceRejected:					text.Set(KMessUsbdiDeviceRejected); 			break;		
       
  1896 			case KErrUsbDeviceFailed:					text.Set(KMessUsbdiDeviceFailed); 				break;		
       
  1897 			case KErrUsbBadDevice:						text.Set(KMessUsbdiBadDevice); 					break;			
       
  1898 			case KErrUsbBadHubPosition:					text.Set(KMessUsbdiBadHubPosition); 			break;		
       
  1899 			case KErrUsbBadHub:							text.Set(KMessUsbdiBadHub); 					break;				
       
  1900 			case KErrUsbEventOverflow:					text.Set(KMessUsbdiEventOverflow); 				break;		
       
  1901 																										
       
  1902 			// USBMAN																					
       
  1903 																										
       
  1904 			case KUsbMessageSrpInitiated:				text.Set(KMessUsbmanSrpInitiated);				break;
       
  1905 			case KUsbMessageSrpReceived:				text.Set(KMessUsbmanSrpReceived);				break;
       
  1906 			case KUsbMessageHnpDisabled:				text.Set(KMessUsbmanHnpDisabled);				break;
       
  1907 			case KUsbMessageHnpEnabled:					text.Set(KMessUsbmanHnpEnabled);				break;
       
  1908 			case KUsbMessageVbusRaised:					text.Set(KMessUsbmanVbusRaised);				break;
       
  1909 			case KUsbMessageVbusDropped:				text.Set(KMessUsbmanVbusDropped);				break;
       
  1910 			case KUsbMessageRequestSession:				text.Set(KMessUsbmanRequestSession);			break;
       
  1911 																										
       
  1912 			default:									text.Set(KMessUnknown);							break;
       
  1913 			}																							
       
  1914 
       
  1915 		aEvent->iEvent.AppendFormat(_L("O:Message[%d] [%S]"), iMessage, &text);
       
  1916 		
       
  1917 		if (   ( iMessage == KUsbMessageSrpReceived )
       
  1918 		    && ( iTestConsole.GetAutoSrpResponseState() )
       
  1919 		   )
       
  1920 			{
       
  1921 			iTestConsole.Usb().BusRespondSrp();
       
  1922 			iTestConsole.Timer()->Start(KTimerAWaitBConnect);
       
  1923 			}
       
  1924 		else if ( iMessage == KUsbMessageRequestSession )
       
  1925 			{
       
  1926 			iTestConsole.Usb().BusRequest();
       
  1927 			} 
       
  1928 		}
       
  1929 
       
  1930 	iTestConsole.Usb().MessageNotification(iStatus, iMessage);
       
  1931 	SetActive();
       
  1932 	
       
  1933 	iTestConsole.NotifyEvent(aEvent);
       
  1934 	}
       
  1935 
       
  1936 
       
  1937 	
       
  1938 void CUsbManStarter::NewL(CUsbManStarter*& aSelf, CUsbTestConsole& aTestConsole)
       
  1939 	{
       
  1940 	aSelf = NULL;
       
  1941 	CUsbManStarter* self = new(ELeave) CUsbManStarter(aSelf, aTestConsole);
       
  1942 	CleanupStack::PushL(self);
       
  1943 	self->ConstructL();
       
  1944 	CleanupStack::Pop(self);
       
  1945 	aSelf = self;
       
  1946 	}
       
  1947 
       
  1948 CUsbManStarter::~CUsbManStarter()
       
  1949 	{
       
  1950 	Cancel();
       
  1951 	iSelf = NULL;
       
  1952 	}
       
  1953 
       
  1954 CUsbManStarter::CUsbManStarter(CUsbManStarter*& aSelf, CUsbTestConsole& aTestConsole)
       
  1955 	: CEventNotifier(EPriorityStandard)
       
  1956 	, iSelf(aSelf)
       
  1957 	, iTestConsole(aTestConsole)
       
  1958 	{
       
  1959 	CActiveScheduler::Add(this);
       
  1960 	}
       
  1961 
       
  1962 void CUsbManStarter::ConstructL()
       
  1963 	{
       
  1964 	iTestConsole.Usb().Start(iStatus);
       
  1965 	SetActive();
       
  1966 	}
       
  1967 
       
  1968 void CUsbManStarter::DoCancel()
       
  1969 	{
       
  1970 	iTestConsole.Usb().StartCancel();
       
  1971 	}
       
  1972 
       
  1973 void CUsbManStarter::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  1974 	{
       
  1975 	aEvent->iEvent.AppendFormat(_L("G:Start:Err[%d]"), iStatus.Int());
       
  1976 	iTestConsole.NotifyEvent(aEvent);
       
  1977 	delete this;
       
  1978 	}
       
  1979 
       
  1980 void CUsbManStarter::DestroyL()
       
  1981 	{
       
  1982 	XUsbTestConsoleEvent* event = NewConsoleEventL();
       
  1983 	event->iEvent.Append(_L("G:StartCancel"));
       
  1984 	iTestConsole.NotifyEvent(event);
       
  1985 	delete this;
       
  1986 	}
       
  1987 	
       
  1988 	
       
  1989 void CUsbManStoper::NewL(CUsbManStoper*& aSelf, CUsbTestConsole& aTestConsole)
       
  1990 	{
       
  1991 	aSelf = NULL;
       
  1992 	CUsbManStoper* self = new(ELeave) CUsbManStoper(aSelf, aTestConsole);
       
  1993 	CleanupStack::PushL(self);
       
  1994 	self->ConstructL();
       
  1995 	CleanupStack::Pop(self);
       
  1996 	aSelf = self;
       
  1997 	}
       
  1998 
       
  1999 CUsbManStoper::~CUsbManStoper()
       
  2000 	{
       
  2001 	Cancel();
       
  2002 	iSelf = NULL;
       
  2003 	}
       
  2004 
       
  2005 CUsbManStoper::CUsbManStoper(CUsbManStoper*& aSelf, CUsbTestConsole& aTestConsole)
       
  2006 	: CEventNotifier(EPriorityStandard)
       
  2007 	, iSelf(aSelf)
       
  2008 	, iTestConsole(aTestConsole)
       
  2009 	{
       
  2010 	CActiveScheduler::Add(this);
       
  2011 	}
       
  2012 
       
  2013 void CUsbManStoper::ConstructL()
       
  2014 	{
       
  2015 	iTestConsole.Usb().Stop(iStatus);
       
  2016 	SetActive();
       
  2017 	}
       
  2018 
       
  2019 void CUsbManStoper::DoCancel()
       
  2020 	{
       
  2021 	iTestConsole.Usb().StopCancel();
       
  2022 	}
       
  2023 
       
  2024 void CUsbManStoper::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  2025 	{
       
  2026 	aEvent->iEvent.AppendFormat(_L("G:Stop:Err[%d]"), iStatus.Int());
       
  2027 	iTestConsole.NotifyEvent(aEvent);
       
  2028 	delete this;
       
  2029 	}
       
  2030 
       
  2031 void CUsbManStoper::DestroyL()
       
  2032 	{
       
  2033 	XUsbTestConsoleEvent* event = NewConsoleEventL();
       
  2034 	event->iEvent.Append(_L("G:StopCancel"));
       
  2035 	iTestConsole.NotifyEvent(event);
       
  2036 	delete this;
       
  2037 	}
       
  2038 	
       
  2039 	
       
  2040 	
       
  2041 void CUsbManTryStarter::NewL(CUsbManTryStarter*& aSelf, CUsbTestConsole& aTestConsole, TInt aPersonalityId)
       
  2042 	{
       
  2043 	aSelf = NULL;
       
  2044 	CUsbManTryStarter* self = new(ELeave) CUsbManTryStarter(aSelf, aTestConsole, aPersonalityId);
       
  2045 	CleanupStack::PushL(self);
       
  2046 	self->ConstructL();
       
  2047 	CleanupStack::Pop(self);
       
  2048 	aSelf = self;
       
  2049 	}
       
  2050 
       
  2051 CUsbManTryStarter::~CUsbManTryStarter()
       
  2052 	{
       
  2053 	Cancel();
       
  2054 	iSelf = NULL;
       
  2055 	}
       
  2056 
       
  2057 CUsbManTryStarter::CUsbManTryStarter(CUsbManTryStarter*& aSelf, CUsbTestConsole& aTestConsole, TInt aPersonalityId)
       
  2058 	: CEventNotifier(EPriorityStandard)
       
  2059 	, iSelf(aSelf)
       
  2060 	, iTestConsole(aTestConsole)
       
  2061 	, iPersonalityId(aPersonalityId)
       
  2062 	{
       
  2063 	CActiveScheduler::Add(this);
       
  2064 	}
       
  2065 
       
  2066 void CUsbManTryStarter::ConstructL()
       
  2067 	{
       
  2068 	iTestConsole.Usb().TryStart(iPersonalityId, iStatus);
       
  2069 	SetActive();
       
  2070 	}
       
  2071 
       
  2072 void CUsbManTryStarter::DoCancel()
       
  2073 	{
       
  2074 	iTestConsole.Usb().StartCancel();
       
  2075 	}
       
  2076 
       
  2077 void CUsbManTryStarter::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  2078 	{
       
  2079 	aEvent->iEvent.AppendFormat(_L("G:TryStart:Err[%d]"), iStatus.Int());
       
  2080 	iTestConsole.NotifyEvent(aEvent);
       
  2081 	delete this;
       
  2082 	}
       
  2083 
       
  2084 void CUsbManTryStarter::DestroyL()
       
  2085 	{
       
  2086 	XUsbTestConsoleEvent* event = NewConsoleEventL();
       
  2087 	event->iEvent.Append(_L("G:StartCancel"));
       
  2088 	iTestConsole.NotifyEvent(event);
       
  2089 	delete this;
       
  2090 	}
       
  2091 	
       
  2092 	
       
  2093 void CUsbManTryStoper::NewL(CUsbManTryStoper*& aSelf, CUsbTestConsole& aTestConsole)
       
  2094 	{
       
  2095 	aSelf = NULL;
       
  2096 	CUsbManTryStoper* self = new(ELeave) CUsbManTryStoper(aSelf, aTestConsole);
       
  2097 	CleanupStack::PushL(self);
       
  2098 	self->ConstructL();
       
  2099 	CleanupStack::Pop(self);
       
  2100 	aSelf = self;
       
  2101 	}
       
  2102 
       
  2103 CUsbManTryStoper::~CUsbManTryStoper()
       
  2104 	{
       
  2105 	Cancel();
       
  2106 	iSelf = NULL;
       
  2107 	}
       
  2108 
       
  2109 CUsbManTryStoper::CUsbManTryStoper(CUsbManTryStoper*& aSelf, CUsbTestConsole& aTestConsole)
       
  2110 	: CEventNotifier(EPriorityStandard)
       
  2111 	, iSelf(aSelf)
       
  2112 	, iTestConsole(aTestConsole)
       
  2113 	{
       
  2114 	CActiveScheduler::Add(this);
       
  2115 	}
       
  2116 
       
  2117 void CUsbManTryStoper::ConstructL()
       
  2118 	{
       
  2119 	iTestConsole.Usb().TryStop(iStatus);
       
  2120 	SetActive();
       
  2121 	}
       
  2122 
       
  2123 void CUsbManTryStoper::DoCancel()
       
  2124 	{
       
  2125 	iTestConsole.Usb().StopCancel();
       
  2126 	}
       
  2127 
       
  2128 void CUsbManTryStoper::DoRunL(XUsbTestConsoleEvent* aEvent)
       
  2129 	{
       
  2130 	aEvent->iEvent.AppendFormat(_L("G:TryStop:Err[%d]"), iStatus.Int());
       
  2131 	iTestConsole.NotifyEvent(aEvent);
       
  2132 	delete this;
       
  2133 	}
       
  2134 
       
  2135 void CUsbManTryStoper::DestroyL()
       
  2136 	{
       
  2137 	XUsbTestConsoleEvent* event = NewConsoleEventL();
       
  2138 	event->iEvent.Append(_L("G:StopCancel"));
       
  2139 	iTestConsole.NotifyEvent(event);
       
  2140 	delete this;
       
  2141 	}
       
  2142 
       
  2143 CUsbTestTimer* CUsbTestTimer::NewL(CUsbTestConsole& aUsb)
       
  2144 	{
       
  2145 	CUsbTestTimer* self = new(ELeave) CUsbTestTimer(aUsb);
       
  2146 	CleanupStack::PushL(self);
       
  2147 	self->ConstructL();
       
  2148 	CleanupStack::Pop(self);
       
  2149 	return self;
       
  2150 	}
       
  2151 
       
  2152 CUsbTestTimer::~CUsbTestTimer()
       
  2153 	{
       
  2154 	Cancel();
       
  2155 	}
       
  2156 
       
  2157 void CUsbTestTimer::ConstructL()
       
  2158 	{
       
  2159 	CTimer::ConstructL();
       
  2160 	CActiveScheduler::Add(this);
       
  2161 	}
       
  2162 
       
  2163 CUsbTestTimer::CUsbTestTimer(CUsbTestConsole& aUsb)
       
  2164 : CTimer(EPriorityStandard)
       
  2165 , iTestConsole(aUsb)
       
  2166 	{	
       
  2167 	}
       
  2168 
       
  2169 void CUsbTestTimer::Start(TTimeIntervalMicroSeconds32 aTime)
       
  2170 	{
       
  2171 	After(aTime);
       
  2172 	}
       
  2173 
       
  2174 void CUsbTestTimer::RunL()
       
  2175 	{
       
  2176 		XUsbTestConsoleEvent* event = new(ELeave) XUsbTestConsoleEvent;
       
  2177 		CleanupStack::PushL(event);
       
  2178 		User::LeaveIfError(event->iEvent.Create(CUsbTestConsole::KNumCharactersOnLine-1));
       
  2179 		CleanupStack::Pop();
       
  2180 		
       
  2181 		TPtrC res(NULL, 0);
       
  2182 		_LIT(KErrMsg, "Device Not Responding");
       
  2183 		
       
  2184 		res.Set(KErrMsg);
       
  2185 		event->iEvent.AppendFormat(_L("T:Timer Message [%S]"), &res);
       
  2186 		iTestConsole.NotifyEvent(event);
       
  2187 	}
       
  2188 
       
  2189 void CUsbTestTimer::DoCancel()
       
  2190 	{
       
  2191 	CTimer::DoCancel();
       
  2192 	}