author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
#ifndef __ENDPOINT_STALL_WATCHER_H |
sl@0 | 2 |
#define __ENDPOINT_STALL_WATCHER_H |
sl@0 | 3 |
|
sl@0 | 4 |
/* |
sl@0 | 5 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 6 |
* All rights reserved. |
sl@0 | 7 |
* This component and the accompanying materials are made available |
sl@0 | 8 |
* under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 9 |
* which accompanies this distribution, and is available |
sl@0 | 10 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 11 |
* |
sl@0 | 12 |
* Initial Contributors: |
sl@0 | 13 |
* Nokia Corporation - initial contribution. |
sl@0 | 14 |
* |
sl@0 | 15 |
* Contributors: |
sl@0 | 16 |
* |
sl@0 | 17 |
* Description: |
sl@0 | 18 |
* @file BaseTestCase.h |
sl@0 | 19 |
* @internalComponent |
sl@0 | 20 |
* |
sl@0 | 21 |
* |
sl@0 | 22 |
*/ |
sl@0 | 23 |
|
sl@0 | 24 |
|
sl@0 | 25 |
|
sl@0 | 26 |
#include <d32usbc.h> |
sl@0 | 27 |
#include <e32base.h> |
sl@0 | 28 |
#include "testdebug.h" |
sl@0 | 29 |
|
sl@0 | 30 |
|
sl@0 | 31 |
namespace NUnitTesting_USBDI |
sl@0 | 32 |
{ |
sl@0 | 33 |
|
sl@0 | 34 |
/** |
sl@0 | 35 |
*/ |
sl@0 | 36 |
class CEndpointStallWatcher : public CActive |
sl@0 | 37 |
{ |
sl@0 | 38 |
public: |
sl@0 | 39 |
/** |
sl@0 | 40 |
C++ constructor |
sl@0 | 41 |
*/ |
sl@0 | 42 |
CEndpointStallWatcher(RDevUsbcClient& aClientDriver) |
sl@0 | 43 |
: CActive(EPriorityUserInput), |
sl@0 | 44 |
iClientDriver(aClientDriver), |
sl@0 | 45 |
iEpMask(0) |
sl@0 | 46 |
{ |
sl@0 | 47 |
CActiveScheduler::Add(this); |
sl@0 | 48 |
RequestNotification(); |
sl@0 | 49 |
} |
sl@0 | 50 |
|
sl@0 | 51 |
/** |
sl@0 | 52 |
Destructor |
sl@0 | 53 |
*/ |
sl@0 | 54 |
~CEndpointStallWatcher() |
sl@0 | 55 |
{ |
sl@0 | 56 |
Cancel(); |
sl@0 | 57 |
} |
sl@0 | 58 |
|
sl@0 | 59 |
protected: |
sl@0 | 60 |
/** |
sl@0 | 61 |
*/ |
sl@0 | 62 |
void DoCancel() |
sl@0 | 63 |
{ |
sl@0 | 64 |
LOG_FUNC |
sl@0 | 65 |
|
sl@0 | 66 |
iClientDriver.EndpointStatusNotifyCancel(); |
sl@0 | 67 |
} |
sl@0 | 68 |
|
sl@0 | 69 |
/** |
sl@0 | 70 |
*/ |
sl@0 | 71 |
void RunL() |
sl@0 | 72 |
/* |
sl@0 | 73 |
This is only called if the host alters the stall status of an endpoint. |
sl@0 | 74 |
It will NOT be called if the client\peripheral has altered the stall ststus |
sl@0 | 75 |
of an endpoint. |
sl@0 | 76 |
*/ |
sl@0 | 77 |
{ |
sl@0 | 78 |
LOG_FUNC |
sl@0 | 79 |
|
sl@0 | 80 |
TUint epMask = iEpMask; |
sl@0 | 81 |
|
sl@0 | 82 |
if(iStatus.Int() != KErrNone) |
sl@0 | 83 |
/* |
sl@0 | 84 |
...for example a reset has occurred. |
sl@0 | 85 |
The EP Mask will not be filled. |
sl@0 | 86 |
*/ |
sl@0 | 87 |
{ |
sl@0 | 88 |
RequestNotification(); |
sl@0 | 89 |
return; |
sl@0 | 90 |
} |
sl@0 | 91 |
|
sl@0 | 92 |
RDebug::Printf("The HOST has halted or cleared a halt on an endpoint."); |
sl@0 | 93 |
if(epMask==0) |
sl@0 | 94 |
{ |
sl@0 | 95 |
RDebug::Printf("Now NO endpoints are stalled!"); |
sl@0 | 96 |
RequestNotification(); |
sl@0 | 97 |
return; |
sl@0 | 98 |
} |
sl@0 | 99 |
|
sl@0 | 100 |
_LIT(KStalledEndpoints, "Currently Stalled Endpoints: "); |
sl@0 | 101 |
_LIT(KComma, ", "); |
sl@0 | 102 |
TUint KLSB = 0x01; |
sl@0 | 103 |
TBuf<128> msg(KStalledEndpoints); |
sl@0 | 104 |
for(TUint8 count = 1; count <= KMaxEndpointsPerClient; count++) |
sl@0 | 105 |
//Notifier does not notify for EP0, so count from EP1 |
sl@0 | 106 |
//up to max endpoints per interface allowed by the Symbian client |
sl@0 | 107 |
{ |
sl@0 | 108 |
epMask>>=1; |
sl@0 | 109 |
if(epMask & KLSB) |
sl@0 | 110 |
{ |
sl@0 | 111 |
msg.AppendNum(count); |
sl@0 | 112 |
msg.Append(KComma); |
sl@0 | 113 |
} |
sl@0 | 114 |
} |
sl@0 | 115 |
RDebug::Print(msg); |
sl@0 | 116 |
RequestNotification(); |
sl@0 | 117 |
return; |
sl@0 | 118 |
} |
sl@0 | 119 |
|
sl@0 | 120 |
/** |
sl@0 | 121 |
*/ |
sl@0 | 122 |
TInt RunError(TInt aError) |
sl@0 | 123 |
{ |
sl@0 | 124 |
LOG_FUNC |
sl@0 | 125 |
|
sl@0 | 126 |
return KErrNone; |
sl@0 | 127 |
} |
sl@0 | 128 |
|
sl@0 | 129 |
private: |
sl@0 | 130 |
void RequestNotification() |
sl@0 | 131 |
{ |
sl@0 | 132 |
iClientDriver.EndpointStatusNotify(iStatus,iEpMask); |
sl@0 | 133 |
SetActive(); |
sl@0 | 134 |
} |
sl@0 | 135 |
private: |
sl@0 | 136 |
/** |
sl@0 | 137 |
The channel to the client driver |
sl@0 | 138 |
*/ |
sl@0 | 139 |
RDevUsbcClient& iClientDriver; |
sl@0 | 140 |
|
sl@0 | 141 |
/** |
sl@0 | 142 |
*/ |
sl@0 | 143 |
TUint iEpMask; |
sl@0 | 144 |
}; |
sl@0 | 145 |
|
sl@0 | 146 |
|
sl@0 | 147 |
} |
sl@0 | 148 |
|
sl@0 | 149 |
|
sl@0 | 150 |
#endif |
sl@0 | 151 |
|
sl@0 | 152 |
|
sl@0 | 153 |