|
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 LOG_FUNC |
|
65 |
|
66 iClientDriver.EndpointStatusNotifyCancel(); |
|
67 } |
|
68 |
|
69 /** |
|
70 */ |
|
71 void RunL() |
|
72 /* |
|
73 This is only called if the host alters the stall status of an endpoint. |
|
74 It will NOT be called if the client\peripheral has altered the stall ststus |
|
75 of an endpoint. |
|
76 */ |
|
77 { |
|
78 LOG_FUNC |
|
79 |
|
80 TUint epMask = iEpMask; |
|
81 |
|
82 if(iStatus.Int() != KErrNone) |
|
83 /* |
|
84 ...for example a reset has occurred. |
|
85 The EP Mask will not be filled. |
|
86 */ |
|
87 { |
|
88 RequestNotification(); |
|
89 return; |
|
90 } |
|
91 |
|
92 RDebug::Printf("The HOST has halted or cleared a halt on an endpoint."); |
|
93 if(epMask==0) |
|
94 { |
|
95 RDebug::Printf("Now NO endpoints are stalled!"); |
|
96 RequestNotification(); |
|
97 return; |
|
98 } |
|
99 |
|
100 _LIT(KStalledEndpoints, "Currently Stalled Endpoints: "); |
|
101 _LIT(KComma, ", "); |
|
102 TUint KLSB = 0x01; |
|
103 TBuf<128> msg(KStalledEndpoints); |
|
104 for(TUint8 count = 1; count <= KMaxEndpointsPerClient; count++) |
|
105 //Notifier does not notify for EP0, so count from EP1 |
|
106 //up to max endpoints per interface allowed by the Symbian client |
|
107 { |
|
108 epMask>>=1; |
|
109 if(epMask & KLSB) |
|
110 { |
|
111 msg.AppendNum(count); |
|
112 msg.Append(KComma); |
|
113 } |
|
114 } |
|
115 RDebug::Print(msg); |
|
116 RequestNotification(); |
|
117 return; |
|
118 } |
|
119 |
|
120 /** |
|
121 */ |
|
122 TInt RunError(TInt aError) |
|
123 { |
|
124 LOG_FUNC |
|
125 |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 private: |
|
130 void RequestNotification() |
|
131 { |
|
132 iClientDriver.EndpointStatusNotify(iStatus,iEpMask); |
|
133 SetActive(); |
|
134 } |
|
135 private: |
|
136 /** |
|
137 The channel to the client driver |
|
138 */ |
|
139 RDevUsbcClient& iClientDriver; |
|
140 |
|
141 /** |
|
142 */ |
|
143 TUint iEpMask; |
|
144 }; |
|
145 |
|
146 |
|
147 } |
|
148 |
|
149 |
|
150 #endif |
|
151 |
|
152 |
|
153 |