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