sl@0: #ifndef __ENDPOINT_STALL_WATCHER_H sl@0: #define __ENDPOINT_STALL_WATCHER_H sl@0: sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * @file BaseTestCase.h sl@0: * @internalComponent sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include "testdebug.h" sl@0: sl@0: sl@0: namespace NUnitTesting_USBDI sl@0: { sl@0: sl@0: /** sl@0: */ sl@0: class CEndpointStallWatcher : public CActive sl@0: { sl@0: public: sl@0: /** sl@0: C++ constructor sl@0: */ sl@0: CEndpointStallWatcher(RDevUsbcClient& aClientDriver) sl@0: : CActive(EPriorityUserInput), sl@0: iClientDriver(aClientDriver), sl@0: iEpMask(0) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: RequestNotification(); sl@0: } sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: ~CEndpointStallWatcher() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: protected: sl@0: /** sl@0: */ sl@0: void DoCancel() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: iClientDriver.EndpointStatusNotifyCancel(); sl@0: } sl@0: sl@0: /** sl@0: */ sl@0: void RunL() sl@0: /* sl@0: This is only called if the host alters the stall status of an endpoint. sl@0: It will NOT be called if the client\peripheral has altered the stall ststus sl@0: of an endpoint. sl@0: */ sl@0: { sl@0: LOG_FUNC sl@0: sl@0: TUint epMask = iEpMask; sl@0: sl@0: if(iStatus.Int() != KErrNone) sl@0: /* sl@0: ...for example a reset has occurred. sl@0: The EP Mask will not be filled. sl@0: */ sl@0: { sl@0: RequestNotification(); sl@0: return; sl@0: } sl@0: sl@0: RDebug::Printf("The HOST has halted or cleared a halt on an endpoint."); sl@0: if(epMask==0) sl@0: { sl@0: RDebug::Printf("Now NO endpoints are stalled!"); sl@0: RequestNotification(); sl@0: return; sl@0: } sl@0: sl@0: _LIT(KStalledEndpoints, "Currently Stalled Endpoints: "); sl@0: _LIT(KComma, ", "); sl@0: TUint KLSB = 0x01; sl@0: TBuf<128> msg(KStalledEndpoints); sl@0: for(TUint8 count = 1; count <= KMaxEndpointsPerClient; count++) sl@0: //Notifier does not notify for EP0, so count from EP1 sl@0: //up to max endpoints per interface allowed by the Symbian client sl@0: { sl@0: epMask>>=1; sl@0: if(epMask & KLSB) sl@0: { sl@0: msg.AppendNum(count); sl@0: msg.Append(KComma); sl@0: } sl@0: } sl@0: RDebug::Print(msg); sl@0: RequestNotification(); sl@0: return; sl@0: } sl@0: sl@0: /** sl@0: */ sl@0: TInt RunError(TInt aError) sl@0: { sl@0: LOG_FUNC sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: private: sl@0: void RequestNotification() sl@0: { sl@0: iClientDriver.EndpointStatusNotify(iStatus,iEpMask); sl@0: SetActive(); sl@0: } sl@0: private: sl@0: /** sl@0: The channel to the client driver sl@0: */ sl@0: RDevUsbcClient& iClientDriver; sl@0: sl@0: /** sl@0: */ sl@0: TUint iEpMask; sl@0: }; sl@0: sl@0: sl@0: } sl@0: sl@0: sl@0: #endif sl@0: sl@0: sl@0: