os/kernelhwsrv/kerneltest/e32test/device/t_usb.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     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 // e32test\device\t_usb.cpp
    15 // USB Test Program, main part.
    16 // Device-side part, to work against USBRFLCT running on the host.
    17 // 
    18 //
    19 
    20 #include "t_usb.h"
    21 
    22 
    23 void RunAppL(TBool aVerboseOutput)
    24 	{
    25 	RDebug::Print(_L("RunAppL()"));
    26 	// Construct the active scheduler
    27 	CActiveScheduler* myScheduler = new (ELeave) CActiveScheduler();
    28 
    29 	// Push active scheduler onto the cleanup stack
    30 	CleanupStack::PushL(myScheduler);
    31 
    32 	// Install as the active scheduler
    33 	CActiveScheduler::Install(myScheduler);
    34 
    35 	// Create console handler
    36 	CConsoleBase* myConsole =
    37 		Console::NewL(_L("T_USB - USB Client Test Program"), TSize(KConsFullScreen, KConsFullScreen));
    38 	CleanupStack::PushL(myConsole);
    39 
    40 	CActiveConsole* myActiveConsole = CActiveConsole::NewL(myConsole, aVerboseOutput);
    41 	CleanupStack::PushL(myActiveConsole);
    42 
    43 	// Call request function
    44 	myActiveConsole->RequestCharacter();
    45 
    46 	// Start active scheduler
    47 	CActiveScheduler::Start();
    48 
    49 	// Suspend thread for 2 secs
    50 	User::After(2000000);
    51 
    52 	CleanupStack::PopAndDestroy(3);							// myActiveConsole, myConsole, myScheduler
    53 	return;
    54 	}
    55 
    56 
    57 TInt E32Main()
    58 	{
    59 	RDebug::Print(_L("E32Main()"));
    60 
    61 	CTrapCleanup* cleanup = CTrapCleanup::New();			// get clean-up stack
    62 
    63 	__UHEAP_MARK;
    64 
    65 	_LIT(KArg, "verbose");
    66 	TBuf<64> c;
    67 	User::CommandLine(c);
    68 	TBool verbose = EFalse;
    69 	if (c.CompareF(KArg) == 0)
    70 		{
    71 		RDebug::Print(_L("(Verbose output enabled.)\n"));
    72 		verbose = ETrue;
    73 		}
    74 
    75 	TRAPD(error, RunAppL(verbose));
    76 
    77 	__ASSERT_ALWAYS(!error, User::Panic(_L("T_USB: EPOC32EX"), error));
    78 
    79 	__UHEAP_MARKEND;
    80 
    81 	delete cleanup;											// destroy clean-up stack
    82 
    83 	RDebug::Print(_L("Program exit: done.\n"));
    84 
    85 	return 0;												// and return
    86 	}
    87 
    88 
    89 // -eof-