1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/src/activestallnotifier.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,89 @@
1.4 +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test/usb\t_usb_device\src\activestallnotifier.cpp
1.18 +// USB Test Program T_USB_DEVICE, functional part.
1.19 +// Device-side part, to work against T_USB_HOST running on the host.
1.20 +//
1.21 +//
1.22 +
1.23 +#include "general.h" // CActiveControl, CActiveRW
1.24 +#include "activestallnotifier.h"
1.25 +
1.26 +extern RTest test;
1.27 +extern TBool gVerbose;
1.28 +extern TBool gSkip;
1.29 +extern TBool gStopOnFail;
1.30 +extern TInt gSoakCount;
1.31 +
1.32 +//
1.33 +// --- class CActiveStallNotifier ---------------------------------------------------------
1.34 +//
1.35 +
1.36 +CActiveStallNotifier::CActiveStallNotifier(CConsoleBase* aConsole, RDEVCLIENT* aPort)
1.37 + : CActive(EPriorityNormal),
1.38 + iConsole(aConsole),
1.39 + iPort(aPort),
1.40 + iEndpointState(0)
1.41 + {
1.42 + CActiveScheduler::Add(this);
1.43 + }
1.44 +
1.45 +CActiveStallNotifier* CActiveStallNotifier::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort)
1.46 + {
1.47 + CActiveStallNotifier* self = new (ELeave) CActiveStallNotifier(aConsole, aPort);
1.48 + CleanupStack::PushL(self);
1.49 + self->ConstructL();
1.50 + CleanupStack::Pop(); // self
1.51 + return self;
1.52 + }
1.53 +
1.54 +
1.55 +void CActiveStallNotifier::ConstructL()
1.56 + {}
1.57 +
1.58 +
1.59 +CActiveStallNotifier::~CActiveStallNotifier()
1.60 + {
1.61 + TUSB_VERBOSE_PRINT("CActiveStallNotifier::~CActiveStallNotifier()");
1.62 + Cancel(); // base class
1.63 + }
1.64 +
1.65 +
1.66 +void CActiveStallNotifier::DoCancel()
1.67 + {
1.68 + TUSB_VERBOSE_PRINT("CActiveStallNotifier::DoCancel()");
1.69 + iPort->EndpointStatusNotifyCancel();
1.70 + }
1.71 +
1.72 +
1.73 +void CActiveStallNotifier::RunL()
1.74 + {
1.75 + // This just displays the bitmap, showing which endpoints (if any) are now stalled.
1.76 + // In a real world program, the user could take here appropriate action (cancel a
1.77 + // transfer request or whatever).
1.78 + TUSB_VERBOSE_PRINT1("StallNotifier: Endpointstate 0x%x\n", iEndpointState);
1.79 + Activate();
1.80 + }
1.81 +
1.82 +
1.83 +void CActiveStallNotifier::Activate()
1.84 + {
1.85 + __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666));
1.86 + iPort->EndpointStatusNotify(iStatus, iEndpointState);
1.87 + SetActive();
1.88 + }
1.89 +
1.90 +
1.91 +
1.92 +// -eof-