author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 19 | 4a8fed1c0ef6 |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1 |
// Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test/device/t_usbco2.cpp |
|
15 |
// USB Test Program T_USB, functional part. |
|
16 |
// Device-side part, to work against USBRFLCT running on the host. |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
#include <e32hal.h> |
|
21 |
#include <e32uid.h> |
|
22 |
#include <hal.h> |
|
23 |
||
24 |
#include "t_usb.h" // CActiveConsole, CActiveRW |
|
25 |
#include "t_usblib.h" // Helpers |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
28 |
#include "t_usbco2Traces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
29 |
#endif |
0 | 30 |
|
31 |
||
32 |
_LIT(KUsbLddFilename, "eusbc"); // .ldd assumed - it's a filename |
|
33 |
_LIT(KOtgdiLddFilename, "otgdi"); |
|
34 |
_LIT(KUsbDeviceName, "Usbc"); |
|
35 |
_LIT(KFileName, "\\T_USBFILE.BIN"); |
|
36 |
_LIT(KActivePanic, "T_USB"); |
|
37 |
||
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
38 |
static const TUint32 KTusbVersion = 20091224; // just an edit date really |
0 | 39 |
static const TUint8 KUsbrflctVersionMajor = 1; // the version we're compatible with |
40 |
static const TUint8 KUsbrflctVersionMinor = 5; |
|
41 |
static const TUint8 KUsbrflctVersionMicro = 0; |
|
42 |
||
43 |
static const TInt KMaxFileSize = 100 * 1024 * 1024; // 100MB (requires at least 128MB card) |
|
44 |
static const TInt KInitialBufSz = 0; |
|
45 |
static const TInt stridx1 = 0xCC; |
|
46 |
static const TInt stridx2 = 0xEE; |
|
47 |
||
48 |
// |
|
49 |
// --- class CActiveConsole --------------------------------------------------------- |
|
50 |
// |
|
51 |
||
52 |
CActiveConsole::CActiveConsole(CConsoleBase* aConsole, TBool aVerboseOutput) |
|
53 |
: CActive(EPriorityNormal), |
|
54 |
iConsole(aConsole), |
|
55 |
iRW(NULL), |
|
56 |
iBufferSizeChosen(EFalse), |
|
57 |
iBandwidthPriorityChosen(EFalse), |
|
58 |
iDMAChosen(EFalse), |
|
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
iAllocateDma(EFalse), |
0 | 60 |
iDoubleBufferingChosen(EFalse), |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
iAllocateDoubleBuffering(EFalse), |
0 | 62 |
iSoftwareConnect(EFalse), |
63 |
iHighSpeed(EFalse), |
|
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
iResourceAllocationV2(EFalse), |
0 | 65 |
iOtg(EFalse), |
66 |
iVerbose(aVerboseOutput) |
|
67 |
{} |
|
68 |
||
69 |
||
70 |
CActiveConsole* CActiveConsole::NewLC(CConsoleBase* aConsole, TBool aVerboseOutput) |
|
71 |
{ |
|
72 |
CActiveConsole* self = new (ELeave) CActiveConsole(aConsole, aVerboseOutput); |
|
73 |
CleanupStack::PushL(self); |
|
74 |
self->ConstructL(); |
|
75 |
return self; |
|
76 |
} |
|
77 |
||
78 |
||
79 |
CActiveConsole* CActiveConsole::NewL(CConsoleBase* aConsole, TBool aVerboseOutput) |
|
80 |
{ |
|
81 |
CActiveConsole* self = NewLC(aConsole, aVerboseOutput); |
|
82 |
CleanupStack::Pop(); |
|
83 |
return self; |
|
84 |
} |
|
85 |
||
86 |
||
87 |
void CActiveConsole::ConstructL() |
|
88 |
{ |
|
89 |
CActiveScheduler::Add(this); |
|
90 |
||
91 |
// Load logical driver (LDD) |
|
92 |
// (There's no physical driver (PDD) with USB: it's a kernel extension DLL which |
|
93 |
// was already loaded at boot time.) |
|
94 |
TInt r = User::LoadLogicalDevice(KUsbLddFilename); |
|
95 |
if (r != KErrNone && r != KErrAlreadyExists) |
|
96 |
{ |
|
97 |
TUSB_PRINT1("Error %d on loading USB LDD", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
98 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL, "Error %d on loading USB LDD", r); |
0 | 99 |
User::Leave(-1); |
100 |
return; |
|
101 |
} |
|
102 |
TUSB_PRINT("Successfully loaded USB LDD"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
103 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP01, "Successfully loaded USB LDD"); |
0 | 104 |
|
105 |
// Open USB channel |
|
106 |
r = iPort.Open(0); |
|
107 |
if (r != KErrNone) |
|
108 |
{ |
|
109 |
TUSB_PRINT1("Error %d on opening USB port", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
110 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP02, "Error %d on opening USB port", r); |
0 | 111 |
User::Leave(-1); |
112 |
return; |
|
113 |
} |
|
114 |
TUSB_PRINT("Successfully opened USB port"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
115 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP03, "Successfully opened USB port"); |
0 | 116 |
|
117 |
// Create Reader/Writer active object |
|
118 |
iRW = CActiveRW::NewL(iConsole, &iPort, iVerbose); |
|
119 |
if (!iRW) |
|
120 |
{ |
|
121 |
TUSB_PRINT("Failed to create reader/writer"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
122 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP04, "Failed to create reader/writer"); |
0 | 123 |
User::Leave(-1); |
124 |
return; |
|
125 |
} |
|
126 |
TUSB_PRINT("Created reader/writer"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
127 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP05, "Created reader/writer"); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
|
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
// check for endpoint resource allocation v2 support |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
TUsbDeviceCaps d_caps; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
r = iPort.DeviceCaps(d_caps); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
if (r != KErrNone) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
TUSB_PRINT1("Error %d on querying device capabilities", r); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
135 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP06, "Error %d on querying device capabilities", r); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
User::Leave(-1); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
return; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
iResourceAllocationV2 = ((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
|
0 | 141 |
// Check for OTG support |
142 |
TBuf8<KUsbDescSize_Otg> otg_desc; |
|
143 |
r = iPort.GetOtgDescriptor(otg_desc); |
|
144 |
if (!(r == KErrNotSupported || r == KErrNone)) |
|
145 |
{ |
|
146 |
TUSB_PRINT1("Error %d while fetching OTG descriptor", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
147 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP07, "Error %d while fetching OTG descriptor", r); |
0 | 148 |
User::Leave(-1); |
149 |
return; |
|
150 |
} |
|
151 |
iOtg = (r != KErrNotSupported) ? ETrue : EFalse; |
|
152 |
||
153 |
// On an OTG device we have to start the OTG driver, otherwise the Client |
|
154 |
// stack will remain disabled forever. |
|
155 |
if (iOtg) |
|
156 |
{ |
|
157 |
TUSB_PRINT("Running on OTG device: loading OTG driver"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
158 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP08, "Running on OTG device: loading OTG driver"); |
0 | 159 |
r = User::LoadLogicalDevice(KOtgdiLddFilename); |
160 |
if (r != KErrNone) |
|
161 |
{ |
|
162 |
TUSB_PRINT1("Error %d on loading OTG LDD", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
163 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP09, "Error %d on loading OTG LDD", r); |
0 | 164 |
User::Leave(-1); |
165 |
return; |
|
166 |
} |
|
167 |
r = iOtgPort.Open(); |
|
168 |
if (r != KErrNone) |
|
169 |
{ |
|
170 |
TUSB_PRINT1("Error %d on opening OTG port", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
171 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP10, "Error %d on opening OTG port", r); |
0 | 172 |
User::Leave(-1); |
173 |
return; |
|
174 |
} |
|
175 |
r = iOtgPort.StartStacks(); |
|
176 |
if (r != KErrNone) |
|
177 |
{ |
|
178 |
TUSB_PRINT1("Error %d on starting USB stack", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
179 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP11, "Error %d on starting USB stack", r); |
0 | 180 |
User::Leave(-1); |
181 |
return; |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
||
186 |
||
187 |
TInt CActiveConsole::SetupInterface() |
|
188 |
{ |
|
189 |
// Query the USB device/Setup the USB interface |
|
190 |
TInt r = QueryUsbClientL(); |
|
191 |
if (r != KErrNone) |
|
192 |
{ |
|
193 |
TUSB_PRINT1("Interface setup failed", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
194 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE, "Interface setup failed:%d", r); |
0 | 195 |
return r; |
196 |
} |
|
197 |
TUSB_PRINT("Interface successfully set up"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
198 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP01, "Interface successfully set up"); |
0 | 199 |
|
200 |
// Change some descriptors to contain suitable values |
|
201 |
r = SetupDescriptors(); |
|
202 |
if (r != KErrNone) |
|
203 |
{ |
|
204 |
TUSB_PRINT1("Descriptor setup failed", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
205 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP02, "Descriptor setup failed:%d ", r); |
0 | 206 |
return r; |
207 |
} |
|
208 |
||
209 |
// Create device state active object |
|
210 |
iDeviceStateNotifier = CActiveDeviceStateNotifier::NewL(iConsole, &iPort, iVerbose); |
|
211 |
if (!iDeviceStateNotifier) |
|
212 |
{ |
|
213 |
TUSB_PRINT("Failed to create device state notifier"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
214 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP03, "Failed to create device state notifier"); |
0 | 215 |
return r; |
216 |
} |
|
217 |
iDeviceStateNotifier->Activate(); |
|
218 |
||
219 |
// Create endpoint stall status active object |
|
220 |
iStallNotifier = CActiveStallNotifier::NewL(iConsole, &iPort, iVerbose); |
|
221 |
if (!iStallNotifier) |
|
222 |
{ |
|
223 |
TUSB_PRINT("Failed to create stall notifier"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
224 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP04, "Failed to create stall notifier"); |
0 | 225 |
return r; |
226 |
} |
|
227 |
iStallNotifier->Activate(); |
|
228 |
||
229 |
return r; |
|
230 |
} |
|
231 |
||
232 |
||
233 |
CActiveConsole::~CActiveConsole() |
|
234 |
{ |
|
235 |
TUSB_VERBOSE_PRINT("CActiveConsole::~CActiveConsole()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
236 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
237 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
238 |
OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_DCACTIVECONSOLE, "CActiveConsole::~CActiveConsole()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
239 |
} |
0 | 240 |
Cancel(); // base class cancel -> calls our DoCancel |
241 |
delete iRW; // destroy the reader/writer |
|
242 |
delete iDeviceStateNotifier; |
|
243 |
delete iStallNotifier; |
|
244 |
TInt r = iPort.RemoveStringDescriptor(stridx1); |
|
245 |
if (r != KErrNone) |
|
246 |
{ |
|
247 |
TUSB_PRINT1("Error %d on string removal", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
248 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP01, "Error %d on string removal", r); |
0 | 249 |
} |
250 |
r = iPort.RemoveStringDescriptor(stridx2); |
|
251 |
if (r != KErrNone) |
|
252 |
{ |
|
253 |
TUSB_PRINT1("Error %d on string removal", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
254 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP02, "Error %d on string removal", r); |
0 | 255 |
} |
256 |
if (iOtg) |
|
257 |
{ |
|
258 |
TUSB_PRINT("Running on OTG device: unloading OTG driver"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
259 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP03, "Running on OTG device: unloading OTG driver"); |
0 | 260 |
iOtgPort.StopStacks(); |
261 |
iOtgPort.Close(); |
|
262 |
r = User::FreeLogicalDevice(RUsbOtgDriver::Name()); |
|
263 |
if (r != KErrNone) |
|
264 |
{ |
|
265 |
TUSB_PRINT1("Error %d on freeing OTG LDD", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
266 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP04, "Error %d on freeing OTG LDD", r); |
0 | 267 |
} |
268 |
} |
|
269 |
iPort.Close(); // close USB channel |
|
270 |
r = User::FreeLogicalDevice(KUsbDeviceName); |
|
271 |
if (r != KErrNone) |
|
272 |
{ |
|
273 |
TUSB_PRINT1("Error %d during unloading USB LDD", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
274 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP05, "Error %d during unloading USB LDD", r); |
0 | 275 |
User::Leave(-1); |
276 |
return; |
|
277 |
} |
|
278 |
TUSB_PRINT("Successfully unloaded USB LDD"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
279 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP06, "Successfully unloaded USB LDD"); |
0 | 280 |
} |
281 |
||
282 |
||
283 |
void CActiveConsole::DoCancel() |
|
284 |
{ |
|
285 |
TUSB_VERBOSE_PRINT("CActiveConsole::DoCancel()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
286 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
287 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
288 |
OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_DOCANCEL, "CActiveConsole::DoCancel()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
289 |
} |
0 | 290 |
iConsole->ReadCancel(); |
291 |
} |
|
292 |
||
293 |
||
294 |
void CActiveConsole::RunL() |
|
295 |
{ |
|
296 |
TUSB_VERBOSE_PRINT("CActiveConsole::RunL()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
297 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
298 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
299 |
OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_RUNL, "CActiveConsole::RunL()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
300 |
} |
0 | 301 |
ProcessKeyPressL(static_cast<TChar>(iConsole->KeyCode())); |
302 |
} |
|
303 |
||
304 |
||
305 |
void CActiveConsole::RequestCharacter() |
|
306 |
{ |
|
307 |
// A request is issued to the CConsoleBase to accept a character from the keyboard. |
|
308 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
|
309 |
if (!iBufferSizeChosen) |
|
310 |
{ |
|
311 |
iConsole->Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
312 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER, "\n"); |
0 | 313 |
iConsole->Printf(_L("++++ Choose max. Transfer Size ++++\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
314 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP01, "++++ Choose max. Transfer Size ++++\n"); |
0 | 315 |
iConsole->Printf(_L(" '0' - Set up USB device for USBCV\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
316 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP02, " '0' - Set up USB device for USBCV\n"); |
0 | 317 |
iConsole->Printf(_L(" '1' - 32 bytes\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
318 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP03, " '1' - 32 bytes\n"); |
0 | 319 |
iConsole->Printf(_L(" '2' - 1024 bytes\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
320 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP04, " '2' - 1024 bytes\n"); |
0 | 321 |
iConsole->Printf(_L(" '3' - 64 kbytes\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
322 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP05, " '3' - 64 kbytes\n"); |
0 | 323 |
iConsole->Printf(_L(" '4' - 1 Mbyte\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
324 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP06, " '4' - 1 Mbyte\n"); |
0 | 325 |
} |
326 |
else if (!iBandwidthPriorityChosen) |
|
327 |
{ |
|
328 |
iConsole->Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
329 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP07, "\n"); |
0 | 330 |
iConsole->Printf(_L("++++ Choose Bandwidth Priority ++++\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
331 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP08, "++++ Choose Bandwidth Priority ++++\n"); |
0 | 332 |
iConsole->Printf(_L(" '1' - Economical buffering - default\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
333 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP09, " '1' - Economical buffering - default\n"); |
0 | 334 |
iConsole->Printf(_L(" '2' - More memory than default buffering - Plus1\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
335 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP10, " '2' - More memory than default buffering - Plus1\n"); |
0 | 336 |
iConsole->Printf(_L(" '3' - More memory than Plus1 buffering - Plus2\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
337 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP11, " '3' - More memory than Plus1 buffering - Plus2\n"); |
0 | 338 |
iConsole->Printf(_L(" '4' - Maximum buffering\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
339 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP12, " '4' - Maximum buffering\n"); |
0 | 340 |
} |
341 |
else if (!iDMAChosen) |
|
342 |
{ |
|
343 |
iConsole->Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
344 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP13, "\n"); |
0 | 345 |
iConsole->Printf(_L("++++ Choose Endpoint I/O Transfer Mode ++++\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
346 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP14, "++++ Choose Endpoint I/O Transfer Mode ++++\n"); |
0 | 347 |
iConsole->Printf(_L(" '1' - Interrupt Mode\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
348 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP15, " '1' - Interrupt Mode\n"); |
0 | 349 |
iConsole->Printf(_L(" '2' - DMA Mode (recommended)\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
350 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP16, " '2' - DMA Mode (recommended\n"); |
0 | 351 |
} |
352 |
else if (!iDoubleBufferingChosen) |
|
353 |
{ |
|
354 |
iConsole->Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
355 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP17, "\n"); |
0 | 356 |
iConsole->Printf(_L("++++ Choose Endpoint FIFO Mode ++++\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
357 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP18, "++++ Choose Endpoint FIFO Mode ++++\n"); |
0 | 358 |
iConsole->Printf(_L(" '1' - Normal Buffering Mode\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
359 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP19, " '1' - Normal Buffering Mode\n"); |
0 | 360 |
iConsole->Printf(_L(" '2' - Double Buffering Mode (recommended)\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
361 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP20, " '2' - Double Buffering Mode (recommended\n"); |
0 | 362 |
} |
363 |
else |
|
364 |
{ |
|
365 |
iConsole->Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
366 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP21, "\n"); |
0 | 367 |
iConsole->Printf(_L("++++ Select Program Option ++++\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
368 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP22, "++++ Select Program Option ++++\n"); |
0 | 369 |
iConsole->Printf(_L(" 'L'oop test\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
370 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP23, " 'L'oop test\n"); |
0 | 371 |
iConsole->Printf(_L(" Loop test with data 'C'ompare\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
372 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP24, " Loop test with data 'C'ompare\n"); |
0 | 373 |
iConsole->Printf(_L(" 'R'eceive-only test (we receive, host transmits)\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
374 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP25, " 'R'eceive-only test (we receive, host transmits\n"); |
0 | 375 |
iConsole->Printf(_L(" 'T'ransmit-only test\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
376 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP26, " 'T'ransmit-only test\n"); |
0 | 377 |
iConsole->Printf(_L(" Receive and 'P'ut (write) to File\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
378 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP27, " Receive and 'P'ut (writeto File\n"); |
0 | 379 |
iConsole->Printf(_L(" Transmit and 'G'et (read) from File\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
380 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP28, " Transmit and 'G'et (readfrom File\n"); |
0 | 381 |
iConsole->Printf(_L(" Signal Remote-'W'akeup to the host\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
382 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP29, " Signal Remote-'W'akeup to the host\n"); |
0 | 383 |
iConsole->Printf(_L(" 'S'top current transfer\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
384 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP30, " 'S'top current transfer\n"); |
0 | 385 |
#ifdef WITH_DUMP_OPTION |
386 |
iConsole->Printf(_L(" 'D'ump USB regs to debugout\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
387 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP31, " 'D'ump USB regs to debugout\n"); |
0 | 388 |
#endif |
389 |
iConsole->Printf(_L(" Re'E'numerate device\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
390 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP32, " Re'E'numerate device\n"); |
0 | 391 |
iConsole->Printf(_L(" 'Q'uit this app\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
392 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP33, " 'Q'uit this app\n"); |
0 | 393 |
} |
394 |
iConsole->Read(iStatus); |
|
395 |
SetActive(); |
|
396 |
} |
|
397 |
||
398 |
||
399 |
void CActiveConsole::ProcessKeyPressL(TChar aChar) |
|
400 |
{ |
|
401 |
if (aChar == EKeyEscape) |
|
402 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
403 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL, "CActiveConsole: ESC key pressed -> stopping active scheduler..."); |
0 | 404 |
CActiveScheduler::Stop(); |
405 |
return; |
|
406 |
} |
|
407 |
if (!iBufferSizeChosen) |
|
408 |
{ |
|
409 |
// Set maximum buffer size from keypress |
|
410 |
switch (aChar) |
|
411 |
{ |
|
412 |
case '0': |
|
413 |
// This is for creating a USB device that just enumerates, |
|
414 |
// to be used for compliance testing with USBCV. |
|
415 |
iRW->SetMaxBufSize(0); |
|
416 |
break; |
|
417 |
case '1': |
|
418 |
iRW->SetMaxBufSize(32); |
|
419 |
break; |
|
420 |
case '2': |
|
421 |
iRW->SetMaxBufSize(1024); |
|
422 |
break; |
|
423 |
case '3': |
|
424 |
iRW->SetMaxBufSize(64 * 1024); |
|
425 |
break; |
|
426 |
case '4': |
|
427 |
iRW->SetMaxBufSize(KMaxBufSize); |
|
428 |
break; |
|
429 |
default: |
|
430 |
TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
431 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP01, "Not a valid input character: %c", aChar.operator TUint()); |
0 | 432 |
goto request_char; |
433 |
} |
|
434 |
TUSB_PRINT1("Maximum buffer size set to %d bytes", iRW->MaxBufSize()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
435 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP02, "Maximum buffer size set to %d bytes", iRW->MaxBufSize()); |
0 | 436 |
iBufferSizeChosen = ETrue; |
437 |
} |
|
438 |
else if (!iBandwidthPriorityChosen) |
|
439 |
{ |
|
440 |
// Set bandwidth priority from keypress |
|
441 |
switch (aChar) |
|
442 |
{ |
|
443 |
case '1': |
|
444 |
iBandwidthPriority = EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault; |
|
445 |
TUSB_PRINT("Bandwith priority set to default"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
446 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP03, "Bandwith priority set to default"); |
0 | 447 |
break; |
448 |
case '2': |
|
449 |
iBandwidthPriority = EUsbcBandwidthOUTPlus1 | EUsbcBandwidthINPlus1; |
|
450 |
TUSB_PRINT("Bandwith priority set to Plus1"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
451 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP04, "Bandwith priority set to Plus1"); |
0 | 452 |
break; |
453 |
case '3': |
|
454 |
iBandwidthPriority = EUsbcBandwidthOUTPlus2 | EUsbcBandwidthINPlus2; |
|
455 |
TUSB_PRINT("Bandwith priority set to Plus2"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
456 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP05, "Bandwith priority set to Plus2"); |
0 | 457 |
break; |
458 |
case '4': |
|
459 |
iBandwidthPriority = EUsbcBandwidthINMaximum | EUsbcBandwidthOUTMaximum; |
|
460 |
TUSB_PRINT("Bandwith priority set to maximum"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
461 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP06, "Bandwith priority set to maximum"); |
0 | 462 |
break; |
463 |
default: |
|
464 |
TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
465 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP07, "Not a valid input character: %c", aChar.operator TUint()); |
0 | 466 |
goto request_char; |
467 |
} |
|
468 |
TUSB_PRINT1("(Set to 0x%08X)", iBandwidthPriority); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
469 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP08, "(Set to 0x%08X)", iBandwidthPriority); |
0 | 470 |
iBandwidthPriorityChosen = ETrue; |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
471 |
|
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
472 |
if (!iResourceAllocationV2) |
0 | 473 |
{ |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
TUSB_PRINT("Configuring interface..."); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
475 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP09, "Configuring interface..."); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
476 |
TInt r = SetupInterface(); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
477 |
if (r != KErrNone) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
478 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
479 |
TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
480 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP10, "Error: %d. Stopping active scheduler...", r); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
CActiveScheduler::Stop(); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
return; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
} |
0 | 484 |
} |
485 |
} |
|
486 |
else if (!iDMAChosen) |
|
487 |
{ |
|
488 |
// Set DMA mode from keypress |
|
489 |
switch (aChar) |
|
490 |
{ |
|
491 |
case '1': |
|
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
492 |
{ |
0 | 493 |
TUSB_PRINT("- Trying to deallocate endpoint DMA:\n"); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
494 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP11, "- Trying to deallocate endpoint DMA:\n"); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
495 |
if (!iResourceAllocationV2) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
497 |
DeAllocateEndpointDMA(EEndpoint1); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
DeAllocateEndpointDMA(EEndpoint2); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
500 |
iAllocateDma = EFalse; |
0 | 501 |
break; |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
502 |
} |
0 | 503 |
case '2': |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
504 |
{ |
0 | 505 |
TUSB_PRINT("- Trying to allocate endpoint DMA:\n"); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
506 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP12, "- Trying to allocate endpoint DMA:\n"); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
507 |
if (!iResourceAllocationV2) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
508 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
509 |
AllocateEndpointDMA(EEndpoint1); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
AllocateEndpointDMA(EEndpoint2); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
511 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
512 |
iAllocateDma = ETrue; |
0 | 513 |
break; |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
514 |
} |
0 | 515 |
default: |
516 |
TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
517 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP13, "Not a valid input character: %c", aChar.operator TUint()); |
0 | 518 |
goto request_char; |
519 |
} |
|
520 |
iDMAChosen = ETrue; |
|
521 |
} |
|
522 |
else if (!iDoubleBufferingChosen) |
|
523 |
{ |
|
524 |
// Set Double Buffering from keypress |
|
525 |
switch (aChar) |
|
526 |
{ |
|
527 |
case '1': |
|
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
528 |
{ |
0 | 529 |
TUSB_PRINT("- Trying to deallocate Double Buffering:\n"); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
530 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP14, "- Trying to deallocate Double Buffering:\n"); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
531 |
if (!iResourceAllocationV2) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
532 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
533 |
DeAllocateDoubleBuffering(EEndpoint1); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
534 |
DeAllocateDoubleBuffering(EEndpoint2); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
535 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
536 |
iAllocateDoubleBuffering = EFalse; |
0 | 537 |
break; |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
538 |
} |
0 | 539 |
case '2': |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
540 |
{ |
0 | 541 |
TUSB_PRINT("- Trying to allocate Double Buffering:\n"); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
542 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP15, "- Trying to allocate Double Buffering:\n"); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
543 |
if (!iResourceAllocationV2) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
544 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
545 |
AllocateDoubleBuffering(EEndpoint1); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
546 |
AllocateDoubleBuffering(EEndpoint2); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
547 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
548 |
iAllocateDoubleBuffering = ETrue; |
0 | 549 |
break; |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
550 |
} |
0 | 551 |
default: |
552 |
TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
553 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP16, "Not a valid input character: %c", aChar.operator TUint()); |
0 | 554 |
goto request_char; |
555 |
} |
|
556 |
iDoubleBufferingChosen = ETrue; |
|
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
|
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
558 |
if (iResourceAllocationV2) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
559 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
560 |
TUSB_PRINT("Configuring interface..."); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
561 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP17, "Configuring interface..."); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
562 |
TInt r = SetupInterface(); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
563 |
if (r != KErrNone) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
564 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
566 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP18, "Error: %d. Stopping active scheduler...", r); |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
567 |
CActiveScheduler::Stop(); |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
568 |
return; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
569 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
} |
0 | 571 |
|
572 |
// Everything chosen, so let's re-enumerate... |
|
573 |
TUSB_PRINT("Enumeration..."); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
574 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP19, "Enumeration..."); |
0 | 575 |
TInt r = ReEnumerate(); |
576 |
if (r != KErrNone) |
|
577 |
{ |
|
578 |
TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
579 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP20, "Error: %d. Stopping active scheduler...", r); |
0 | 580 |
CActiveScheduler::Stop(); |
581 |
return; |
|
582 |
} |
|
583 |
TUSB_PRINT("Device successfully re-enumerated\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
584 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP21, "Device successfully re-enumerated\n"); |
0 | 585 |
|
586 |
// Make sure program versions match if testing against USBRFLCT |
|
587 |
if (iRW->MaxBufSize() != 0) |
|
588 |
{ |
|
589 |
r = iRW->ExchangeVersions(); |
|
590 |
if (r != KErrNone) |
|
591 |
{ |
|
592 |
TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
593 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP22, "Error: %d. Stopping active scheduler...", r); |
0 | 594 |
CActiveScheduler::Stop(); |
595 |
return; |
|
596 |
} |
|
597 |
} |
|
598 |
} |
|
599 |
else |
|
600 |
{ |
|
601 |
// Execute one of the 'proper' program functions |
|
602 |
switch (aChar) |
|
603 |
{ |
|
604 |
case 'l': // start loop test |
|
605 |
case 'L': |
|
606 |
TUSB_PRINT("-> Loop test selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
607 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP23, "-> Loop test selected\n"); |
0 | 608 |
iRW->SetTransferMode(ELoop); |
609 |
iRW->SendPreamble(); |
|
610 |
break; |
|
611 |
case 'c': // start loop/compare test |
|
612 |
case 'C': |
|
613 |
TUSB_PRINT("-> Loop test with compare selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
614 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP24, "-> Loop test with compare selected\n"); |
0 | 615 |
iRW->SetTransferMode(ELoopComp); |
616 |
iRW->SendPreamble(); |
|
617 |
break; |
|
618 |
case 'r': // start receive-only test |
|
619 |
case 'R': |
|
620 |
TUSB_PRINT("-> Receive-only test selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
621 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP25, "-> Receive-only test selected\n"); |
0 | 622 |
iRW->SetTransferMode(EReceiveOnly); |
623 |
iRW->SendPreamble(); |
|
624 |
break; |
|
625 |
case 't': // start transmit-only test |
|
626 |
case 'T': |
|
627 |
TUSB_PRINT("-> Transmit-only test selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
628 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP26, "-> Transmit-only test selected\n"); |
0 | 629 |
iRW->SetTransferMode(ETransmitOnly); |
630 |
iRW->SendPreamble(); |
|
631 |
break; |
|
632 |
case 'g': // start transmit & get-from-file test |
|
633 |
case 'G': |
|
634 |
TUSB_PRINT("-> Transmit from file test selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
635 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP27, "-> Transmit from file test selected\n"); |
0 | 636 |
iRW->SetTransferMode(ETransmitOnly); |
637 |
iRW->ReadFromDisk(ETrue); |
|
638 |
iRW->SendPreamble(); |
|
639 |
break; |
|
640 |
case 'p': // start receive & put-to-file test |
|
641 |
case 'P': |
|
642 |
TUSB_PRINT("-> Receive to file test selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
643 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP28, "-> Receive to file test selected\n"); |
0 | 644 |
iRW->SetTransferMode(EReceiveOnly); |
645 |
iRW->WriteToDisk(ETrue); |
|
646 |
iRW->SendPreamble(); |
|
647 |
break; |
|
648 |
case 'w': // remote-wakeup |
|
649 |
case 'W': |
|
650 |
TUSB_PRINT("-> Signal Remote-wakeup selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
651 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP29, "-> Signal Remote-wakeup selected\n"); |
0 | 652 |
iPort.SignalRemoteWakeup(); |
653 |
break; |
|
654 |
case 's': // stop either |
|
655 |
case 'S': |
|
656 |
TUSB_PRINT("-> Stop transfer selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
657 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP30, "-> Stop transfer selected\n"); |
0 | 658 |
iRW->Stop(); |
659 |
break; |
|
660 |
#ifdef WITH_DUMP_OPTION |
|
661 |
case 'd': // dump controller registers |
|
662 |
case 'D': |
|
663 |
TUSB_PRINT("-> Dump option selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
664 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP31, "-> Dump option selected\n"); |
0 | 665 |
iPort.DumpRegisters(); |
666 |
QueryRxBuffer(); |
|
667 |
break; |
|
668 |
#endif |
|
669 |
case 'e': // ReEnumerate() |
|
670 |
case 'E': |
|
671 |
TUSB_PRINT("-> Re-enumerate device selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
672 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP32, "-> Re-enumerate device selected\n"); |
0 | 673 |
ReEnumerate(); |
674 |
break; |
|
675 |
case 'q': // quit |
|
676 |
case 'Q': |
|
677 |
TUSB_PRINT("-> Quit program selected\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
678 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP33, "-> Quit program selected\n"); |
0 | 679 |
TUSB_VERBOSE_PRINT("CActiveConsole: stopping active scheduler..."); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
680 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
681 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
682 |
OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP34, "CActiveConsole: stopping active scheduler..."); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
683 |
} |
0 | 684 |
CActiveScheduler::Stop(); |
685 |
return; |
|
686 |
default: |
|
687 |
TUSB_PRINT1("-> Not a valid input character: %c", aChar.operator TUint()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
688 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP35, "-> Not a valid input character: %c", aChar.operator TUint()); |
0 | 689 |
goto request_char; |
690 |
} |
|
691 |
} |
|
692 |
request_char: |
|
693 |
RequestCharacter(); |
|
694 |
return; |
|
695 |
} |
|
696 |
||
697 |
||
698 |
#ifdef WITH_DUMP_OPTION |
|
699 |
void CActiveConsole::QueryRxBuffer() |
|
700 |
{ |
|
701 |
// Let's look whether there's data in the rx buffer |
|
702 |
TInt bytes = 0; |
|
703 |
TInt r = iPort.QueryReceiveBuffer(EEndpoint2, bytes); |
|
704 |
if (r != KErrNone) |
|
705 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
706 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYRXBUFFER, " Error %d on querying read buffer\n", r); |
0 | 707 |
} |
708 |
else |
|
709 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
710 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYRXBUFFER_DUP01, " %d bytes in RX buffer\n", bytes); |
0 | 711 |
} |
712 |
} |
|
713 |
#endif |
|
714 |
||
715 |
||
716 |
TInt CActiveConsole::QueryUsbClientL() |
|
717 |
{ |
|
718 |
// Not really just querying... but rather setting up the whole interface. |
|
719 |
// It's in fact a bit lengthy, but all these steps are required, once, |
|
720 |
// and in that order. |
|
721 |
||
722 |
// Get device/endpoint capabilities |
|
723 |
// |
|
724 |
// A TPckg, or TPckBuf was not used in the following, because |
|
725 |
// |
|
726 |
// TPckgBuf<TUsbcEndpointData[KUsbcMaxEndpoints]> databuf; |
|
727 |
// |
|
728 |
// doesn't work. Also, |
|
729 |
// |
|
730 |
// TUsbcEndpointData data[KUsbcMaxEndpoints]; |
|
731 |
// TPckgBuf<TUsbcEndpointData[KUsbcMaxEndpoints]> databuf(data); |
|
732 |
// |
|
733 |
// doesn't work. Also, |
|
734 |
// |
|
735 |
// TUsbcEndpointData data[KUsbcMaxEndpoints]; |
|
736 |
// TPckgBuf<TUsbcEndpointData[]> databuf(data); |
|
737 |
// |
|
738 |
// doesn't work. |
|
739 |
// So we seem to have to stick to the ugly cast below. |
|
740 |
// |
|
741 |
// TUsbcEndpointData data[KUsbcMaxEndpoints]; |
|
742 |
// TPtr8 databuf(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
|
743 |
// |
|
744 |
||
745 |
// Device |
|
746 |
TUsbDeviceCaps d_caps; |
|
747 |
TInt r = iPort.DeviceCaps(d_caps); |
|
748 |
if (r != KErrNone) |
|
749 |
{ |
|
750 |
TUSB_PRINT1("Error %d on querying device capabilities", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
751 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL, "Error %d on querying device capabilities", r); |
0 | 752 |
return KErrGeneral; |
753 |
} |
|
754 |
const TInt n = d_caps().iTotalEndpoints; |
|
755 |
||
756 |
TUSB_PRINT("### USB device capabilities:"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
757 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP01, "### USB device capabilities:"); |
0 | 758 |
TUSB_PRINT1("Number of endpoints: %d", n); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
759 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP02, "Number of endpoints: %d", n); |
0 | 760 |
TUSB_PRINT1("Supports Software-Connect: %s", |
761 |
d_caps().iConnect ? _S("yes") : _S("no")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
762 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP03, "Supports Software-Connect: %s", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
763 |
d_caps().iConnect ? _L("yes") : _L("no")); |
0 | 764 |
TUSB_PRINT1("Device is Self-Powered: %s", |
765 |
d_caps().iSelfPowered ? _S("yes") : _S("no")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
766 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP04, "Device is Self-Powered: %s", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
767 |
d_caps().iSelfPowered ? _L("yes") : _L("no")); |
0 | 768 |
TUSB_PRINT1("Supports Remote-Wakeup: %s", |
769 |
d_caps().iRemoteWakeup ? _S("yes") : _S("no")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
770 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP05, "Supports Remote-Wakeup: %s", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
771 |
d_caps().iRemoteWakeup ? _L("yes") : _L("no")); |
0 | 772 |
TUSB_PRINT1("Supports High-speed: %s", |
773 |
d_caps().iHighSpeed ? _S("yes") : _S("no")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
774 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP06, "Supports High-speed: %s", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
775 |
d_caps().iHighSpeed ? _L("yes") : _L("no")); |
0 | 776 |
TUSB_PRINT1("Supports OTG: %s", |
777 |
iOtg ? _S("yes") : _S("no")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
778 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP07, "Supports OTG: %s", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
779 |
iOtg ? _L("yes") : _L("no")); |
0 | 780 |
TUSB_PRINT1("Supports unpowered cable detection: %s", |
781 |
(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
|
782 |
_S("yes") : _S("no")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
783 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP08, "Supports unpowered cable detection: %s", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
784 |
(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
785 |
_L("yes") : _L("no")); |
0 | 786 |
TUSB_PRINT1("Supports endpoint resource alloc scheme V2: %s\n", |
787 |
(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ? |
|
788 |
_S("yes") : _S("no")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
789 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP09, "Supports endpoint resource alloc scheme V2: %s\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
790 |
(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ? |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
791 |
_L("yes") : _L("no")); |
0 | 792 |
TUSB_PRINT(""); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
793 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP10, ""); |
0 | 794 |
|
795 |
iSoftwareConnect = d_caps().iConnect; // we need to remember this |
|
796 |
||
797 |
if (n < 2) |
|
798 |
{ |
|
799 |
TUSB_PRINT1("Error: only %d endpoints available on device", n); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
800 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP11, "Error: only %d endpoints available on device", n); |
0 | 801 |
return KErrGeneral; |
802 |
} |
|
803 |
||
804 |
// Endpoints |
|
805 |
TUsbcEndpointData data[KUsbcMaxEndpoints]; |
|
806 |
TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
|
807 |
r = iPort.EndpointCaps(dataptr); |
|
808 |
if (r != KErrNone) |
|
809 |
{ |
|
810 |
TUSB_PRINT1("Error %d on querying endpoint capabilities", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
811 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP12, "Error %d on querying endpoint capabilities", r); |
0 | 812 |
return KErrGeneral; |
813 |
} |
|
814 |
TUSB_PRINT("### USB device endpoint capabilities:"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
815 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP13, "### USB device endpoint capabilities:"); |
0 | 816 |
for (TInt i = 0; i < n; i++) |
817 |
{ |
|
818 |
const TUsbcEndpointCaps* caps = &data[i].iCaps; |
|
819 |
TUSB_PRINT2("Endpoint: SizeMask = 0x%08x TypeDirMask = 0x%08x", |
|
820 |
caps->iSizes, caps->iTypesAndDir); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
821 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP14, "Endpoint: SizeMask = 0x%08x TypeDirMask = 0x%08x", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
822 |
caps->iSizes, caps->iTypesAndDir); |
0 | 823 |
} |
824 |
TUSB_PRINT(""); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
825 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP15, ""); |
0 | 826 |
|
827 |
// Set up the active interface |
|
828 |
TUsbcInterfaceInfoBuf ifc; |
|
829 |
TInt ep_found = 0; |
|
830 |
TBool foundBulkIN = EFalse; |
|
831 |
TBool foundBulkOUT = EFalse; |
|
832 |
for (TInt i = 0; i < n; i++) |
|
833 |
{ |
|
834 |
const TUsbcEndpointCaps* const caps = &data[i].iCaps; |
|
835 |
const TInt mps = caps->MaxPacketSize(); |
|
836 |
if (!foundBulkIN && |
|
837 |
(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == |
|
838 |
(KUsbEpTypeBulk | KUsbEpDirIn)) |
|
839 |
{ |
|
840 |
if (!(mps == 64 || mps == 512)) |
|
841 |
{ |
|
842 |
TUSB_PRINT1("Funny Bulk IN MaxPacketSize: %d - T_USB will probably fail...", mps); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
843 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP16, "Funny Bulk IN MaxPacketSize: %d - T_USB will probably fail...", mps); |
0 | 844 |
} |
845 |
// EEndpoint1 is going to be our Tx (IN) endpoint |
|
846 |
ifc().iEndpointData[0].iType = KUsbEpTypeBulk; |
|
847 |
ifc().iEndpointData[0].iDir = KUsbEpDirIn; |
|
848 |
ifc().iEndpointData[0].iSize = mps; |
|
849 |
foundBulkIN = ETrue; |
|
850 |
if (++ep_found == 2) |
|
851 |
break; |
|
852 |
} |
|
853 |
else if (!foundBulkOUT && |
|
854 |
(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == |
|
855 |
(KUsbEpTypeBulk | KUsbEpDirOut)) |
|
856 |
{ |
|
857 |
if (!(mps == 64 || mps == 512)) |
|
858 |
{ |
|
859 |
TUSB_PRINT1("Funny Bulk OUT MaxPacketSize: %d - T_USB will probably fail...", mps); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
860 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP17, "Funny Bulk OUT MaxPacketSize: %d - T_USB will probably fail...", mps); |
0 | 861 |
} |
862 |
// EEndpoint2 is going to be our Rx (OUT) endpoint |
|
863 |
ifc().iEndpointData[1].iType = KUsbEpTypeBulk; |
|
864 |
ifc().iEndpointData[1].iDir = KUsbEpDirOut; |
|
865 |
ifc().iEndpointData[1].iSize = mps; |
|
866 |
foundBulkOUT = ETrue; |
|
867 |
if (++ep_found == 2) |
|
868 |
break; |
|
869 |
} |
|
870 |
} |
|
871 |
if (ep_found != 2) |
|
872 |
{ |
|
873 |
TUSB_PRINT1("No suitable endpoints found", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
874 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP18, "No suitable endpoints found:%d", r); |
0 | 875 |
return KErrGeneral; |
876 |
} |
|
877 |
||
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
878 |
if (iResourceAllocationV2) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
879 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
if (iAllocateDma) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
881 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
882 |
ifc().iEndpointData[0].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
883 |
ifc().iEndpointData[1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
884 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
885 |
if (iAllocateDoubleBuffering) |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
886 |
{ |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
887 |
ifc().iEndpointData[0].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DoubleBuffering; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
888 |
ifc().iEndpointData[1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DoubleBuffering; |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
889 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
890 |
} |
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
891 |
|
0 | 892 |
_LIT16(ifcname, "T_USB Test Interface (Default Setting 0)"); |
893 |
ifc().iString = const_cast<TDesC16*>(&ifcname); |
|
894 |
ifc().iTotalEndpointsUsed = 2; |
|
895 |
ifc().iClass.iClassNum = 0xff; // vendor-specific |
|
896 |
ifc().iClass.iSubClassNum = 0xff; // vendor-specific |
|
897 |
ifc().iClass.iProtocolNum = 0xff; // vendor-specific |
|
898 |
r = iPort.SetInterface(0, ifc, iBandwidthPriority); |
|
899 |
if (r != KErrNone) |
|
900 |
{ |
|
901 |
TUSB_PRINT1("Error %d on setting active interface", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
902 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP19, "Error %d on setting active interface", r); |
0 | 903 |
} |
904 |
||
905 |
// Find ep's for an alternate ifc setting. |
|
906 |
// We're not really going to use it, but it gives USBCV et al. more stuff to play with. |
|
907 |
if (!SupportsAlternateInterfaces()) |
|
908 |
{ |
|
909 |
TUSB_PRINT("Alternate Interfaces not supported - skipping alternate setting setup\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
910 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP20, "Alternate Interfaces not supported - skipping alternate setting setup\n"); |
0 | 911 |
return KErrNone; |
912 |
} |
|
913 |
ep_found = 0; |
|
914 |
TBool foundIsoIN = EFalse; |
|
915 |
TBool foundIsoOUT = EFalse; |
|
916 |
||
917 |
// NB! We cannot assume that any specific device has any given set of |
|
918 |
// capabilities, so whilst we try and set an assortment of endpoint types |
|
919 |
// we may not get what we want. |
|
920 |
||
921 |
// Also, note that the endpoint[] array in the interface descriptor |
|
922 |
// must be filled from ep[0]...ep[n-1]. |
|
923 |
||
924 |
for (TInt i = 0; i < n; i++) |
|
925 |
{ |
|
926 |
const TUsbcEndpointCaps* const caps = &data[i].iCaps; |
|
927 |
const TInt mps = caps->MaxPacketSize(); |
|
928 |
if (!foundIsoIN && |
|
929 |
(caps->iTypesAndDir & (KUsbEpTypeIsochronous | KUsbEpDirIn)) == |
|
930 |
(KUsbEpTypeIsochronous | KUsbEpDirIn)) |
|
931 |
{ |
|
932 |
// This is going to be our Iso TX (IN) endpoint |
|
933 |
ifc().iEndpointData[ep_found].iType = KUsbEpTypeIsochronous; |
|
934 |
ifc().iEndpointData[ep_found].iDir = KUsbEpDirIn; |
|
935 |
ifc().iEndpointData[ep_found].iSize = mps; |
|
936 |
ifc().iEndpointData[ep_found].iInterval = 0x01; // 2^(bInterval-1)ms, bInterval must be [1..16] |
|
937 |
ifc().iEndpointData[ep_found].iInterval_Hs = 0x01; // same as for FS |
|
938 |
ifc().iEndpointData[ep_found].iExtra = 2; // 2 extra bytes for Audio Class EP descriptor |
|
939 |
foundIsoIN = ETrue; |
|
940 |
if (++ep_found == 2) |
|
941 |
break; |
|
942 |
} |
|
943 |
else if (!foundIsoOUT && |
|
944 |
(caps->iTypesAndDir & (KUsbEpTypeIsochronous | KUsbEpDirOut)) == |
|
945 |
(KUsbEpTypeIsochronous | KUsbEpDirOut)) |
|
946 |
{ |
|
947 |
// This is going to be our Iso RX (OUT) endpoint |
|
948 |
ifc().iEndpointData[ep_found].iType = KUsbEpTypeIsochronous; |
|
949 |
ifc().iEndpointData[ep_found].iDir = KUsbEpDirOut; |
|
950 |
ifc().iEndpointData[ep_found].iSize = mps; |
|
951 |
ifc().iEndpointData[ep_found].iInterval = 0x01; // 2^(bInterval-1)ms, bInterval must be [1..16] |
|
952 |
ifc().iEndpointData[ep_found].iExtra = 2; // 2 extra bytes for Audio Class EP descriptor |
|
953 |
foundIsoOUT = ETrue; |
|
954 |
if (++ep_found == 2) |
|
955 |
break; |
|
956 |
} |
|
957 |
} |
|
958 |
// Let's try to add Bulk endpoints up to the max # of 2. |
|
959 |
if (ep_found < 2) |
|
960 |
{ |
|
961 |
for (TInt i = 0; i < n; i++) |
|
962 |
{ |
|
963 |
const TUsbcEndpointCaps* const caps = &data[i].iCaps; |
|
964 |
const TUint mps = caps->MaxPacketSize(); |
|
965 |
if (caps->iTypesAndDir & KUsbEpTypeBulk) |
|
966 |
{ |
|
967 |
const TUint dir = (caps->iTypesAndDir & KUsbEpDirIn) ? KUsbEpDirIn : KUsbEpDirOut; |
|
968 |
ifc().iEndpointData[ep_found].iType = KUsbEpTypeBulk; |
|
969 |
ifc().iEndpointData[ep_found].iDir = dir; |
|
970 |
ifc().iEndpointData[ep_found].iSize = mps; |
|
971 |
if (++ep_found == 2) |
|
972 |
break; |
|
973 |
} |
|
974 |
} |
|
975 |
} |
|
976 |
if (ep_found == 0) |
|
977 |
{ |
|
978 |
TUSB_PRINT("Not enough suitable endpoints found for alt ifc"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
979 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP21, "Not enough suitable endpoints found for alt ifc"); |
0 | 980 |
// not a disaster though |
981 |
return KErrNone; |
|
982 |
} |
|
983 |
||
984 |
_LIT16(ifcname1, "T_USB Test Interface (Alternate Setting 1)"); |
|
985 |
ifc().iString = const_cast<TDesC16*>(&ifcname1); |
|
986 |
ifc().iTotalEndpointsUsed = ep_found; |
|
987 |
ifc().iClass.iClassNum = KUsbAudioInterfaceClassCode; |
|
988 |
ifc().iClass.iSubClassNum = KUsbAudioInterfaceSubclassCode_Audiostreaming; |
|
989 |
ifc().iClass.iProtocolNum = KUsbAudioInterfaceProtocolCode_Pr_Protocol_Undefined; |
|
990 |
// Tell the driver that this setting is not interested in Ep0 requests: |
|
991 |
ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease; |
|
992 |
r = iPort.SetInterface(1, ifc); |
|
993 |
if (r != KErrNone) |
|
994 |
{ |
|
995 |
TUSB_PRINT1("Error %d on setting alternate interface", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
996 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP22, "Error %d on setting alternate interface", r); |
0 | 997 |
} |
998 |
||
999 |
return r; |
|
1000 |
} |
|
1001 |
||
1002 |
||
1003 |
void CActiveConsole::AllocateEndpointDMA(TEndpointNumber aEndpoint) |
|
1004 |
{ |
|
1005 |
TInt r = iPort.AllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDMA); |
|
1006 |
if (r == KErrNone) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1007 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA, "DMA allocation on endpoint %d: KErrNone", aEndpoint); |
0 | 1008 |
else if (r == KErrInUse) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1009 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP01, "DMA allocation on endpoint %d: KErrInUse", aEndpoint); |
0 | 1010 |
else if (r == KErrNotSupported) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1011 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP02, "DMA allocation on endpoint %d: KErrNotSupported", aEndpoint); |
0 | 1012 |
else |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1013 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP03, "DMA allocation on endpoint %d: unexpected return value %d", |
0 | 1014 |
aEndpoint, r); |
1015 |
TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDMA); |
|
1016 |
TUSB_PRINT2("DMA on endpoint %d %s\n", |
|
1017 |
aEndpoint, res ? _S("allocated") : _S("not allocated")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1018 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP04, "DMA on endpoint %d %s\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1019 |
aEndpoint, res ? _L("allocated") : _L("not allocated")); |
0 | 1020 |
|
1021 |
if ((r == KErrNone) && !res) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1022 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP05, "(Allocation success but negative query result: contradiction!)\n"); |
0 | 1023 |
else if ((r != KErrNone) && res) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1024 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP06, "(Allocation failure but positive query result: contradiction!)\n"); |
0 | 1025 |
} |
1026 |
||
1027 |
||
1028 |
void CActiveConsole::DeAllocateEndpointDMA(TEndpointNumber aEndpoint) |
|
1029 |
{ |
|
1030 |
TInt r = iPort.DeAllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDMA); |
|
1031 |
if (r == KErrNone) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1032 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA, "DMA deallocation on endpoint %d: KErrNone", aEndpoint); |
0 | 1033 |
else if (r == KErrNotSupported) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1034 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA_DUP01, "DMA deallocation on endpoint %d: KErrNotSupported", aEndpoint); |
0 | 1035 |
else |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1036 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA_DUP02, "DMA deallocation on endpoint %d: unexpected return value %d", |
0 | 1037 |
aEndpoint, r); |
1038 |
TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDMA); |
|
1039 |
TUSB_PRINT2("DMA on endpoint %d %s\n", |
|
1040 |
aEndpoint, res ? _S("allocated") : _S("not allocated")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1041 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA_DUP03, "DMA on endpoint %d %s\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1042 |
aEndpoint, res ? _L("allocated") : _L("not allocated")); |
0 | 1043 |
} |
1044 |
||
1045 |
||
1046 |
void CActiveConsole::AllocateDoubleBuffering(TEndpointNumber aEndpoint) |
|
1047 |
{ |
|
1048 |
TInt r = iPort.AllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
|
1049 |
if (r == KErrNone) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1050 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING, "Double Buffering allocation on endpoint %d: KErrNone", aEndpoint); |
0 | 1051 |
else if (r == KErrInUse) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1052 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP01, "Double Buffering allocation on endpoint %d: KErrInUse", aEndpoint); |
0 | 1053 |
else if (r == KErrNotSupported) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1054 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP02, "Double Buffering allocation on endpoint %d: KErrNotSupported", aEndpoint); |
0 | 1055 |
else |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1056 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP03, "Double Buffering allocation on endpoint %d: unexpected return value %d", |
0 | 1057 |
aEndpoint, r); |
1058 |
TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
|
1059 |
TUSB_PRINT2("Double Buffering on endpoint %d %s\n", |
|
1060 |
aEndpoint, res ? _S("allocated") : _S("not allocated")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1061 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP04, "Double Buffering on endpoint %d %s\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1062 |
aEndpoint, res ? _L("allocated") : _L("not allocated")); |
0 | 1063 |
|
1064 |
if ((r == KErrNone) && !res) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1065 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP05, "(Allocation success but negative query result: contradiction!)\n"); |
0 | 1066 |
else if ((r != KErrNone) && res) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1067 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP06, "(Allocation failure but positive query result: contradiction!)\n"); |
0 | 1068 |
} |
1069 |
||
1070 |
||
1071 |
void CActiveConsole::DeAllocateDoubleBuffering(TEndpointNumber aEndpoint) |
|
1072 |
{ |
|
1073 |
TInt r = iPort.DeAllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
|
1074 |
if (r == KErrNone) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1075 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING, "Double Buffering deallocation on endpoint %d: KErrNone", aEndpoint); |
0 | 1076 |
else if (r == KErrNotSupported) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1077 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING_DUP01, "Double Buffering deallocation on endpoint %d: KErrNotSupported", aEndpoint); |
0 | 1078 |
else |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1079 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING_DUP02, "Double Buffering deallocation on endpoint %d: unexpected return value %d", |
0 | 1080 |
aEndpoint, r); |
1081 |
TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
|
1082 |
TUSB_PRINT2("Double Buffering on endpoint %d %s\n", |
|
1083 |
aEndpoint, res ? _S("allocated") : _S("not allocated")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1084 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING_DUP03, "Double Buffering on endpoint %d %s\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1085 |
aEndpoint, res ? _L("allocated") : _L("not allocated")); |
0 | 1086 |
} |
1087 |
||
1088 |
||
1089 |
TInt CActiveConsole::ReEnumerate() |
|
1090 |
{ |
|
1091 |
TRequestStatus enum_status; |
|
1092 |
iPort.ReEnumerate(enum_status); |
|
1093 |
if (!iSoftwareConnect) |
|
1094 |
{ |
|
1095 |
iConsole->Printf(_L("This device does not support software\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1096 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE, "This device does not support software\n"); |
0 | 1097 |
iConsole->Printf(_L("disconnect/reconnect\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1098 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP01, "disconnect/reconnect\n"); |
0 | 1099 |
iConsole->Printf(_L("Please physically unplug and replug\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1100 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP02, "Please physically unplug and replug\n"); |
0 | 1101 |
iConsole->Printf(_L("the USB cable NOW... ")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1102 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP03, "the USB cable NOW... "); |
0 | 1103 |
} |
1104 |
iConsole->Printf(_L("\n>>> START THE USBRFLCT PROGRAM ON THE HOST SIDE NOW <<<\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1105 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP04, "\n>>> START THE USBRFLCT PROGRAM ON THE HOST SIDE NOW <<<\n"); |
0 | 1106 |
User::WaitForRequest(enum_status); |
1107 |
if (enum_status != KErrNone) |
|
1108 |
{ |
|
1109 |
TUSB_PRINT1("Error: Re-enumeration status = %d", enum_status.Int()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1110 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP05, "Error: Re-enumeration status = %d", enum_status.Int()); |
0 | 1111 |
return KErrGeneral; |
1112 |
} |
|
1113 |
TUsbcDeviceState device_state = EUsbcDeviceStateUndefined; |
|
1114 |
TInt r = iPort.DeviceStatus(device_state); |
|
1115 |
if (r != KErrNone) |
|
1116 |
{ |
|
1117 |
TUSB_PRINT1("Error %d on querying device state", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1118 |
OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP06, "Error %d on querying device state", r); |
0 | 1119 |
} |
1120 |
else |
|
1121 |
{ |
|
1122 |
TUSB_PRINT1("Current device state: %s", |
|
1123 |
(device_state == EUsbcDeviceStateUndefined) ? _S("Undefined") : |
|
1124 |
((device_state == EUsbcDeviceStateAttached) ? _S("Attached") : |
|
1125 |
((device_state == EUsbcDeviceStatePowered) ? _S("Powered") : |
|
1126 |
((device_state == EUsbcDeviceStateDefault) ? _S("Default") : |
|
1127 |
((device_state == EUsbcDeviceStateAddress) ? _S("Address") : |
|
1128 |
((device_state == EUsbcDeviceStateConfigured) ? _S("Configured") : |
|
1129 |
((device_state == EUsbcDeviceStateSuspended) ? _S("Suspended") : |
|
1130 |
_S("Unknown")))))))); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1131 |
OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP07, "Current device state: %s", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1132 |
(device_state == EUsbcDeviceStateUndefined) ? _L("Undefined") : |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1133 |
((device_state == EUsbcDeviceStateAttached) ? _L("Attached") : |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1134 |
((device_state == EUsbcDeviceStatePowered) ? _L("Powered") : |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1135 |
((device_state == EUsbcDeviceStateDefault) ? _L("Default") : |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1136 |
((device_state == EUsbcDeviceStateAddress) ? _L("Address") : |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1137 |
((device_state == EUsbcDeviceStateConfigured) ? _L("Configured") : |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1138 |
((device_state == EUsbcDeviceStateSuspended) ? _L("Suspended") : |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1139 |
_L("Unknown")))))))); |
0 | 1140 |
} |
1141 |
||
1142 |
// Check the speed of the established physical USB connection |
|
1143 |
iHighSpeed = iPort.CurrentlyUsingHighSpeed(); |
|
1144 |
if (iHighSpeed) |
|
1145 |
{ |
|
1146 |
TUSB_PRINT("---> USB High-speed Testing\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1147 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP08, "---> USB High-speed Testing\n"); |
0 | 1148 |
// It can only be 512 bytes when using high-speed. |
1149 |
iRW->SetMaxPacketSize(512); // iRW already exists at this point |
|
1150 |
} |
|
1151 |
else |
|
1152 |
{ |
|
1153 |
TUSB_PRINT("---> USB Full-speed Testing\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1154 |
OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP09, "---> USB Full-speed Testing\n"); |
0 | 1155 |
// We only support 64 bytes when using full-speed. |
1156 |
iRW->SetMaxPacketSize(64); // iRW already exists at this point |
|
1157 |
} |
|
1158 |
||
1159 |
return KErrNone; |
|
1160 |
} |
|
1161 |
||
1162 |
||
1163 |
#ifdef test |
|
1164 |
#undef test |
|
1165 |
#endif |
|
1166 |
#define test(x) \ |
|
1167 |
do { \ |
|
1168 |
if (!(x)) \ |
|
1169 |
{ \ |
|
1170 |
TUSB_PRINT1("Failure occurred! - on line %d", __LINE__); \ |
|
1171 |
return KErrGeneral; \ |
|
1172 |
} \ |
|
1173 |
} while (0) |
|
1174 |
||
1175 |
||
1176 |
TInt CActiveConsole::SetupDescriptors() |
|
1177 |
{ |
|
1178 |
// === Device Descriptor |
|
1179 |
||
1180 |
TInt deviceDescriptorSize = 0; |
|
1181 |
iPort.GetDeviceDescriptorSize(deviceDescriptorSize); |
|
1182 |
test(static_cast<TUint>(deviceDescriptorSize) == KUsbDescSize_Device); |
|
1183 |
||
1184 |
TBuf8<KUsbDescSize_Device> deviceDescriptor; |
|
1185 |
TInt r = iPort.GetDeviceDescriptor(deviceDescriptor); |
|
1186 |
test(r == KErrNone); |
|
1187 |
||
1188 |
const TInt KUsbSpecOffset = 2; |
|
1189 |
const TInt KUsbVendorIdOffset = 8; |
|
1190 |
const TInt KUsbProductIdOffset = 10; |
|
1191 |
const TInt KUsbDevReleaseOffset = 12; |
|
1192 |
// Change the USB spec number to 2.00 |
|
1193 |
deviceDescriptor[KUsbSpecOffset] = 0x00; |
|
1194 |
deviceDescriptor[KUsbSpecOffset+1] = 0x02; |
|
1195 |
// Change the device vendor ID (VID) to 0x0E22 (Symbian) |
|
1196 |
deviceDescriptor[KUsbVendorIdOffset] = 0x22; // little endian! |
|
1197 |
deviceDescriptor[KUsbVendorIdOffset+1] = 0x0E; |
|
1198 |
// Change the device product ID (PID) to 0x1111 |
|
1199 |
deviceDescriptor[KUsbProductIdOffset] = 0x11; |
|
1200 |
deviceDescriptor[KUsbProductIdOffset+1] = 0x11; |
|
1201 |
// Change the device release number to 3.05 |
|
1202 |
deviceDescriptor[KUsbDevReleaseOffset] = 0x05; |
|
1203 |
deviceDescriptor[KUsbDevReleaseOffset+1] = 0x03; |
|
1204 |
r = iPort.SetDeviceDescriptor(deviceDescriptor); |
|
1205 |
test(r == KErrNone); |
|
1206 |
||
1207 |
const TUint16 Vid = (((TUint16)deviceDescriptor[KUsbVendorIdOffset + 1] << 8) & 0xff00) | |
|
1208 |
deviceDescriptor[KUsbVendorIdOffset]; |
|
1209 |
const TUint16 Pid = (((TUint16)deviceDescriptor[KUsbProductIdOffset + 1] << 8) & 0xff00) | |
|
1210 |
deviceDescriptor[KUsbProductIdOffset]; |
|
1211 |
||
1212 |
TUSB_PRINT6("\nVID = 0x%04X / PID = 0x%04X / DevRel = %d%d.%d%d\n", Vid, Pid, |
|
1213 |
((deviceDescriptor[KUsbDevReleaseOffset + 1] >> 4) & 0x0f), |
|
1214 |
(deviceDescriptor[KUsbDevReleaseOffset + 1] & 0x0f), |
|
1215 |
((deviceDescriptor[KUsbDevReleaseOffset] >> 4) & 0x0f), |
|
1216 |
(deviceDescriptor[KUsbDevReleaseOffset] & 0x0f)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1217 |
OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_SETUPDESCRIPTORS, "\nVID = 0x%04X / PID = 0x%04X / ", Vid, Pid); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1218 |
OstTraceExt4(TRACE_NORMAL, CACTIVECONSOLE_SETUPDESCRIPTORS_DUP01, "DevRel = %d%d.%d%d\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1219 |
((deviceDescriptor[KUsbDevReleaseOffset + 1] >> 4) & 0x0f), |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1220 |
(deviceDescriptor[KUsbDevReleaseOffset + 1] & 0x0f), |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1221 |
((deviceDescriptor[KUsbDevReleaseOffset] >> 4) & 0x0f), |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1222 |
(deviceDescriptor[KUsbDevReleaseOffset] & 0x0f)); |
0 | 1223 |
|
1224 |
// === Configuration Descriptor |
|
1225 |
||
1226 |
TInt configDescriptorSize = 0; |
|
1227 |
iPort.GetConfigurationDescriptorSize(configDescriptorSize); |
|
1228 |
test(static_cast<TUint>(configDescriptorSize) == KUsbDescSize_Config); |
|
1229 |
||
1230 |
TBuf8<KUsbDescSize_Config> configDescriptor; |
|
1231 |
r = iPort.GetConfigurationDescriptor(configDescriptor); |
|
1232 |
test(r == KErrNone); |
|
1233 |
||
1234 |
// Change the reported max power to 100mA (= 2 * 0x32), |
|
1235 |
// which is the highest value allowed for a bus-powered device. |
|
1236 |
const TInt KUsbMaxPowerOffset = 8; |
|
1237 |
configDescriptor[KUsbMaxPowerOffset] = 0x32; |
|
1238 |
r = iPort.SetConfigurationDescriptor(configDescriptor); |
|
1239 |
test(r == KErrNone); |
|
1240 |
||
1241 |
// === String Descriptors |
|
1242 |
||
1243 |
// Set up two arbitrary string descriptors, which can be queried |
|
1244 |
// manually from the host side for testing purposes (for instance |
|
1245 |
// using 'usbcheck'). |
|
1246 |
||
1247 |
_LIT16(string_one, "Arbitrary String Descriptor Test String 1"); |
|
1248 |
TBuf16<KUsbStringDescStringMaxSize / 2> wr_str(string_one); |
|
1249 |
r = iPort.SetStringDescriptor(stridx1, wr_str); |
|
1250 |
test(r == KErrNone); |
|
1251 |
||
1252 |
_LIT16(string_two, "Another Arbitrary String Descriptor Test String"); |
|
1253 |
wr_str.FillZ(wr_str.MaxLength()); |
|
1254 |
wr_str = string_two; |
|
1255 |
r = iPort.SetStringDescriptor(stridx2, wr_str); |
|
1256 |
test(r == KErrNone); |
|
1257 |
||
1258 |
return KErrNone; |
|
1259 |
} |
|
1260 |
||
1261 |
||
1262 |
// |
|
1263 |
// --- class CActiveRW --------------------------------------------------------- |
|
1264 |
// |
|
1265 |
||
1266 |
CActiveRW::CActiveRW(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput) |
|
1267 |
: CActive(EPriorityNormal), |
|
1268 |
iConsole(aConsole), |
|
1269 |
iPort(aPort), |
|
1270 |
iBufSz(KInitialBufSz), |
|
1271 |
iMaxBufSz(KInitialBufSz), |
|
1272 |
iMaxPktSz(0), |
|
1273 |
iCurrentXfer(ENone), |
|
1274 |
iXferMode(::ENone), |
|
1275 |
iDoStop(EFalse), |
|
1276 |
iPktNum(~0), |
|
1277 |
iVerbose(aVerboseOutput) |
|
1278 |
{ |
|
1279 |
TUSB_VERBOSE_PRINT("CActiveRW::CActiveRW()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1280 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1281 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1282 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_CACTIVERW, "CActiveRW::CActiveRW()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1283 |
} |
0 | 1284 |
} |
1285 |
||
1286 |
||
1287 |
CActiveRW* CActiveRW::NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, TBool aVerboseOutput) |
|
1288 |
{ |
|
1289 |
CActiveRW* self = new (ELeave) CActiveRW(aConsole, aPort, aVerboseOutput); |
|
1290 |
CleanupStack::PushL(self); |
|
1291 |
self->ConstructL(); |
|
1292 |
CActiveScheduler::Add(self); |
|
1293 |
CleanupStack::Pop(); // self |
|
1294 |
return self; |
|
1295 |
} |
|
1296 |
||
1297 |
||
1298 |
void CActiveRW::ConstructL() |
|
1299 |
{ |
|
1300 |
TUSB_VERBOSE_PRINT("CActiveRW::ConstructL()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1301 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1302 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1303 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_CONSTRUCTL, "CActiveRW::ConstructL()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1304 |
} |
0 | 1305 |
|
1306 |
User::LeaveIfError(iFs.Connect()); |
|
1307 |
||
1308 |
// Prepare Preamble buffer |
|
1309 |
iPreambleBuf.SetMax(); |
|
1310 |
iPreambleBuf.FillZ(); |
|
1311 |
||
1312 |
// Prepare IN data buffer |
|
1313 |
iWriteBuf.SetMax(); |
|
1314 |
for (TInt i = 0; i < iWriteBuf.MaxSize(); i++) |
|
1315 |
{ |
|
1316 |
iWriteBuf[i] = i; |
|
1317 |
} |
|
1318 |
||
1319 |
// Prepare OUT data buffer |
|
1320 |
iReadBuf.SetMax(); |
|
1321 |
||
1322 |
// Create read timeout timer active object (but don't activate it yet) |
|
1323 |
iTimeoutTimer = CActiveTimer::NewL(iConsole, iPort, iVerbose); |
|
1324 |
if (!iTimeoutTimer) |
|
1325 |
{ |
|
1326 |
TUSB_PRINT("Failed to create timeout timer"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1327 |
OstTrace0(TRACE_NORMAL, CACTIVERW_CONSTRUCTL_DUP01, "Failed to create timeout timer"); |
0 | 1328 |
} |
1329 |
} |
|
1330 |
||
1331 |
||
1332 |
CActiveRW::~CActiveRW() |
|
1333 |
{ |
|
1334 |
TUSB_VERBOSE_PRINT("CActiveRW::~CActiveRW()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1335 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1336 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1337 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_DCACTIVERW, "CActiveRW::~CActiveRW()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1338 |
} |
0 | 1339 |
Cancel(); // base class |
1340 |
delete iTimeoutTimer; |
|
1341 |
iFile.Close(); |
|
1342 |
iFs.Close(); |
|
1343 |
} |
|
1344 |
||
1345 |
||
1346 |
void CActiveRW::SetMaxBufSize(TInt aBufSz) |
|
1347 |
{ |
|
1348 |
if (aBufSz > KMaxBufSize) |
|
1349 |
{ |
|
1350 |
TUSB_PRINT2("SetMaxBufSize(): too large: %d! (using %d)", aBufSz, KMaxBufSize); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1351 |
OstTraceExt2(TRACE_NORMAL, CACTIVERW_SETMAXBUFSIZE, "SetMaxBufSize(): too large: %d! (using %d)", aBufSz, KMaxBufSize); |
0 | 1352 |
aBufSz = KMaxBufSize; |
1353 |
} |
|
1354 |
iMaxBufSz = aBufSz; |
|
1355 |
} |
|
1356 |
||
1357 |
||
1358 |
void CActiveRW::SetMaxPacketSize(TInt aPktSz) |
|
1359 |
{ |
|
1360 |
iMaxPktSz = aPktSz; |
|
1361 |
} |
|
1362 |
||
1363 |
||
1364 |
TInt CActiveRW::MaxBufSize() const |
|
1365 |
{ |
|
1366 |
return iMaxBufSz; |
|
1367 |
} |
|
1368 |
||
1369 |
||
1370 |
void CActiveRW::SetTransferMode(TXferMode aMode) |
|
1371 |
{ |
|
1372 |
iXferMode = aMode; |
|
1373 |
if (aMode == EReceiveOnly || aMode == ETransmitOnly) |
|
1374 |
{ |
|
1375 |
// For streaming transfers we do this only once. |
|
1376 |
iBufSz = iMaxBufSz; |
|
1377 |
} |
|
1378 |
} |
|
1379 |
||
1380 |
||
1381 |
void CActiveRW::RunL() |
|
1382 |
{ |
|
1383 |
TUSB_VERBOSE_PRINT("CActiveRW::RunL()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1384 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1385 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1386 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_RUNL, "CActiveRW::RunL()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1387 |
} |
0 | 1388 |
if (iStatus != KErrNone) |
1389 |
{ |
|
1390 |
TUSB_PRINT1("Error %d in RunL", iStatus.Int()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1391 |
OstTrace1(TRACE_NORMAL, CACTIVERW_RUNL_DUP01, "Error %d in RunL", iStatus.Int()); |
0 | 1392 |
} |
1393 |
if (iDoStop) |
|
1394 |
{ |
|
1395 |
TUSB_PRINT("Stopped"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1396 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RUNL_DUP02, "Stopped"); |
0 | 1397 |
iDoStop = EFalse; |
1398 |
return; |
|
1399 |
} |
|
1400 |
switch (iCurrentXfer) |
|
1401 |
{ |
|
1402 |
case EPreamble: |
|
1403 |
if (iXferMode != EReceiveOnly) |
|
1404 |
SendData(); // next we write data |
|
1405 |
else |
|
1406 |
ReadData(); // or we read data |
|
1407 |
break; |
|
1408 |
case EWriteXfer: |
|
1409 |
if (iXferMode == ETransmitOnly) |
|
1410 |
SendData(); // next we send data |
|
1411 |
else |
|
1412 |
ReadData(); // or we read data |
|
1413 |
break; |
|
1414 |
case EReadXfer: |
|
1415 |
if (iXferMode == EReceiveOnly) |
|
1416 |
{ |
|
1417 |
const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
|
1418 |
if (num != ++iPktNum) |
|
1419 |
{ |
|
1420 |
TUSB_PRINT2("*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1421 |
OstTraceExt2(TRACE_NORMAL, CACTIVERW_RUNL_DUP03, "*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
0 | 1422 |
// Update the packet number with the received number, so that |
1423 |
// if a single packet is duplicated or lost then a single error occurs |
|
1424 |
iPktNum = num; |
|
1425 |
} |
|
1426 |
if (iDiskAccessEnabled) |
|
1427 |
{ |
|
1428 |
// Write out to disk previous completed Read |
|
1429 |
TUSB_VERBOSE_PRINT2("iMaxBufSz = %d (iReadBuf.Size(): %d)", |
|
1430 |
iMaxBufSz, iReadBuf.Size()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1431 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1432 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1433 |
OstTraceExt2(TRACE_VERBOSE, CACTIVERW_RUNL_DUP04, "iMaxBufSz = %d (iReadBuf.Size(): %d)", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1434 |
iMaxBufSz, iReadBuf.Size()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1435 |
} |
0 | 1436 |
WriteBufferToDisk(iReadBuf, iMaxBufSz); |
1437 |
} |
|
1438 |
ReadData(); // next we read data |
|
1439 |
break; |
|
1440 |
} |
|
1441 |
if (iXferMode == ELoopComp) |
|
1442 |
{ |
|
1443 |
if (!CompareBuffers(iBufSz)) |
|
1444 |
{ |
|
1445 |
TUSB_PRINT1("Error while comparing tx & rx buffers for packet 0x%x", iPktNum); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1446 |
OstTrace1(TRACE_NORMAL, CACTIVERW_RUNL_DUP05, "Error while comparing tx & rx buffers for packet 0x%x", iPktNum); |
0 | 1447 |
} |
1448 |
} |
|
1449 |
else if (iBufSz > 3) |
|
1450 |
{ |
|
1451 |
const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
|
1452 |
if (num != iPktNum) |
|
1453 |
{ |
|
1454 |
TUSB_PRINT2("*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1455 |
OstTraceExt2(TRACE_NORMAL, CACTIVERW_RUNL_DUP06, "*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
0 | 1456 |
} |
1457 |
} |
|
1458 |
if (iBufSz == iMaxBufSz) |
|
1459 |
{ |
|
1460 |
iBufSz = KInitialBufSz; |
|
1461 |
} |
|
1462 |
else |
|
1463 |
{ |
|
1464 |
++iBufSz; |
|
1465 |
} |
|
1466 |
SendPreamble(); // next we send the length |
|
1467 |
break; |
|
1468 |
default: |
|
1469 |
TUSB_PRINT("Oops. (Shouldn't end up here...)"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1470 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RUNL_DUP07, "Oops. (Shouldn't end up here...)"); |
0 | 1471 |
break; |
1472 |
} |
|
1473 |
return; |
|
1474 |
} |
|
1475 |
||
1476 |
||
1477 |
TInt CActiveRW::SendVersion() |
|
1478 |
{ |
|
1479 |
TUSB_VERBOSE_PRINT("CActiveRW::SendVersion()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1480 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1481 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1482 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_SENDVERSION, "CActiveRW::SendVersion()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1483 |
} |
0 | 1484 |
if (iXferMode != ::ENone) |
1485 |
{ |
|
1486 |
TUSB_PRINT1("Error : wrong state: %d", iXferMode); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1487 |
OstTrace1(TRACE_NORMAL, CACTIVERW_SENDVERSION_DUP01, "Error : wrong state: %d", iXferMode); |
0 | 1488 |
return KErrGeneral; |
1489 |
} |
|
1490 |
// Here we send our version packet to the host. |
|
1491 |
// (We can use the preamble buffer because we only need it |
|
1492 |
// once and that's also before the preamble uses.) |
|
1493 |
TUSB_PRINT1("Sending T_USB version: %d\n", KTusbVersion); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1494 |
OstTrace1(TRACE_NORMAL, CACTIVERW_SENDVERSION_DUP02, "Sending T_USB version: %d\n", KTusbVersion); |
0 | 1495 |
iPreambleBuf.FillZ(); |
1496 |
*reinterpret_cast<TUint32*>(&iPreambleBuf[0]) = SWAP_BYTES_32(KTusbVersion); |
|
1497 |
// A 'magic' string so that USBRFLCT doesn't interpret the first 4 bytes |
|
1498 |
// of a data preamble packet of an old T_USB as the version number. |
|
1499 |
iPreambleBuf[4] = 'V'; |
|
1500 |
iPreambleBuf[5] = 'e'; |
|
1501 |
iPreambleBuf[6] = 'r'; |
|
1502 |
iPreambleBuf[7] = 's'; |
|
1503 |
TRequestStatus send_status; |
|
1504 |
iPort->Write(send_status, EEndpoint1, iPreambleBuf, KPreambleLength); |
|
1505 |
TUSB_VERBOSE_PRINT("Waiting for write request to complete..."); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1506 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1507 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1508 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_SENDVERSION_DUP03, "Waiting for write request to complete..."); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1509 |
} |
0 | 1510 |
User::WaitForRequest(send_status); |
1511 |
TUSB_VERBOSE_PRINT("...done.\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1512 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1513 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1514 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_SENDVERSION_DUP04, "...done.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1515 |
} |
0 | 1516 |
return send_status.Int(); |
1517 |
} |
|
1518 |
||
1519 |
||
1520 |
TInt CActiveRW::ReceiveVersion() |
|
1521 |
{ |
|
1522 |
TUSB_VERBOSE_PRINT("CActiveRW::ReceiveVersion()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1523 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1524 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1525 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION, "CActiveRW::ReceiveVersion()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1526 |
} |
0 | 1527 |
if (iXferMode != ::ENone) |
1528 |
{ |
|
1529 |
TUSB_PRINT1("Error : wrong state: %d", iXferMode); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1530 |
OstTrace1(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP01, "Error : wrong state: %d", iXferMode); |
0 | 1531 |
return KErrGeneral; |
1532 |
} |
|
1533 |
// Here we try to receive a version packet from the host. |
|
1534 |
// (We can use the preamble buffer because we only need it |
|
1535 |
// once and that's also before the preamble uses.) |
|
1536 |
TUSB_PRINT("Getting host program versions..."); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1537 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP02, "Getting host program versions..."); |
0 | 1538 |
iPreambleBuf.FillZ(); |
1539 |
TRequestStatus receive_status; |
|
1540 |
iPort->Read(receive_status, EEndpoint2, iPreambleBuf, KPreambleLength); |
|
1541 |
TUSB_VERBOSE_PRINT("Waiting for read request to complete..."); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1542 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1543 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1544 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION_DUP03, "Waiting for read request to complete..."); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1545 |
} |
0 | 1546 |
iTimeoutTimer->Activate(5000000); // Host gets 5s |
1547 |
User::WaitForRequest(receive_status, iTimeoutTimer->iStatus); |
|
1548 |
if (receive_status == KRequestPending) |
|
1549 |
{ |
|
1550 |
// Read() still pending... |
|
1551 |
TUSB_PRINT("Cancelling USB Read(): no response from host.\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1552 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP04, "Cancelling USB Read(): no response from host.\n"); |
0 | 1553 |
iPort->ReadCancel(EEndpoint2); |
1554 |
TUSB_PRINT("THIS COULD BE DUE TO AN OLD VERSION OF USBRFLCT ON THE PC:"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1555 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP05, "THIS COULD BE DUE TO AN OLD VERSION OF USBRFLCT ON THE PC:"); |
0 | 1556 |
TUSB_PRINT3("PLEASE CHECK THE VERSION THERE - WE NEED AT LEAST V%d.%d.%d!\n", |
1557 |
KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1558 |
OstTraceExt3(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP06, "PLEASE CHECK THE VERSION THERE - WE NEED AT LEAST V%d.%d.%d!\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1559 |
KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
0 | 1560 |
TUSB_PRINT("When updating an existing USBRFLCT installation <= v1.3.1,\n" \ |
1561 |
L"the following three things will need to be done:\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1562 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP07, "When updating an existing USBRFLCT installation <= v1.3.1,\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1563 |
L"the following three things will need to be done:\n"); |
0 | 1564 |
TUSB_PRINT("1. Connect the device to the PC & start T_USB (just as now),\n" \ |
1565 |
L"then find the USB device in the Windows Device Manager\n" \ |
|
1566 |
L"('Control Panel'->'System'->'Hardware'->'Device Manager').\n" \ |
|
1567 |
L"Right click on the device name and choose 'Uninstall...'.\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1568 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP08, "1. Connect the device to the PC & start T_USB (just as now),\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1569 |
L"then find the USB device in the Windows Device Manager\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1570 |
L"('Control Panel'->'System'->'Hardware'->'Device Manager').\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1571 |
L"Right click on the device name and choose 'Uninstall...'.\n"); |
0 | 1572 |
TUSB_PRINT("2. In c:\\winnt\\inf\\, find (by searching for \"Symbian\") and\n" \ |
1573 |
L"delete the *.INF file that was used to install the existing\n" \ |
|
1574 |
L"version of USBRFLCT.SYS. Make sure to also delete the\n" \ |
|
1575 |
L"precompiled version of that file (<samename>.PNF).\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1576 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP09, "2. In c:\\winnt\\inf\\, find (by searching for \"Symbian\") and\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1577 |
L"delete the *.INF file that was used to install the existing\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1578 |
L"version of USBRFLCT.SYS. Make sure to also delete the\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1579 |
L"precompiled version of that file (<samename>.PNF).\n"); |
0 | 1580 |
TUSB_PRINT("3. In c:\\winnt\\system32\\drivers\\, delete the file USBRFLCT.SYS.\n"); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1581 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP10, "3. In c:\\winnt\\system32\\drivers\\, delete the file USBRFLCT.SYS.\n"); |
0 | 1582 |
TUSB_PRINT("Then unplug & reconnect the USB device and, when prompted, install\n" \ |
1583 |
L"the new USBRFLCT.SYS driver using the .INF file from this distribution.\n" \ |
|
1584 |
L"(All files can be found under e32test\\win32\\usbrflct_distribution\\.)\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1585 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP11, "Then unplug & reconnect the USB device and, when prompted, install\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1586 |
L"the new USBRFLCT.SYS driver using the .INF file from this distribution.\n" \ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1587 |
L"(All files can be found under e32test\\win32\\usbrflct_distribution\\.)\n"); |
0 | 1588 |
TUSB_PRINT("Use the new USBRFLCT.EXE from this distribution.\n"); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1589 |
OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP12, "Use the new USBRFLCT.EXE from this distribution.\n"); |
0 | 1590 |
} |
1591 |
else |
|
1592 |
{ |
|
1593 |
TUSB_VERBOSE_PRINT("...done."); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1594 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1595 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1596 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION_DUP13, "...done."); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1597 |
} |
0 | 1598 |
// Timeout not needed any longer |
1599 |
TUSB_VERBOSE_PRINT("Cancelling timeout timer: USB Read() completed.\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1600 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1601 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1602 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION_DUP14, "Cancelling timeout timer: USB Read() completed.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1603 |
} |
0 | 1604 |
iTimeoutTimer->Cancel(); |
1605 |
} |
|
1606 |
return receive_status.Int(); |
|
1607 |
} |
|
1608 |
||
1609 |
||
1610 |
TInt CActiveRW::ExchangeVersions() |
|
1611 |
{ |
|
1612 |
TUSB_VERBOSE_PRINT("CActiveRW::ExchangeVersions()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1613 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1614 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1615 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_EXCHANGEVERSIONS, "CActiveRW::ExchangeVersions()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1616 |
} |
0 | 1617 |
// First check the version of USBRFLCT that's running on the host |
1618 |
TInt r = ReceiveVersion(); |
|
1619 |
if (r != KErrNone) |
|
1620 |
{ |
|
1621 |
return KErrGeneral; |
|
1622 |
} |
|
1623 |
TUint8 usbrflct_ver_major = iPreambleBuf[0]; |
|
1624 |
TUint8 usbrflct_ver_minor = iPreambleBuf[1]; |
|
1625 |
TUint8 usbrflct_ver_micro = iPreambleBuf[2]; |
|
1626 |
TUint8 usbio_ver_major = iPreambleBuf[3]; |
|
1627 |
TUint8 usbio_ver_minor = iPreambleBuf[4]; |
|
1628 |
TUSB_PRINT5("Host-side: USBRFLCT v%d.%d.%d USBIO v%d.%d\n", |
|
1629 |
usbrflct_ver_major, usbrflct_ver_minor, usbrflct_ver_micro, |
|
1630 |
usbio_ver_major, usbio_ver_minor); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1631 |
OstTraceExt5(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP01, "Host-side: USBRFLCT v%d.%d.%d USBIO v%d.%d\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1632 |
usbrflct_ver_major, usbrflct_ver_minor, usbrflct_ver_micro, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1633 |
usbio_ver_major, usbio_ver_minor); |
0 | 1634 |
if (usbrflct_ver_major < KUsbrflctVersionMajor) |
1635 |
{ |
|
1636 |
TUSB_PRINT1("USBRFLCT version not sufficient (need at least v%d.x.x)\n", |
|
1637 |
KUsbrflctVersionMajor); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1638 |
OstTrace1(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP02, "USBRFLCT version not sufficient (need at least v%d.x.x)\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1639 |
KUsbrflctVersionMajor); |
0 | 1640 |
return KErrGeneral; |
1641 |
} |
|
1642 |
// Just using '<' instead of the seemingly absurd '<= && !==' doesn't work without |
|
1643 |
// GCC compiler warning because Kxxx can also be zero (in which case there's no '<'). |
|
1644 |
else if ((usbrflct_ver_minor <= KUsbrflctVersionMinor) && |
|
1645 |
!(usbrflct_ver_minor == KUsbrflctVersionMinor)) |
|
1646 |
{ |
|
1647 |
TUSB_PRINT2("USBRFLCT version not sufficient (need at least v%d.%d.x)\n", |
|
1648 |
KUsbrflctVersionMajor, KUsbrflctVersionMinor); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1649 |
OstTraceExt2(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP03, "USBRFLCT version not sufficient (need at least v%d.%d.x)\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1650 |
KUsbrflctVersionMajor, KUsbrflctVersionMinor); |
0 | 1651 |
return KErrGeneral; |
1652 |
} |
|
1653 |
// Just using '<' instead of the seemingly absurd '<= && !==' doesn't work without |
|
1654 |
// GCC compiler warning because Kxxx can also be zero (in which case there's no '<'). |
|
1655 |
else if ((usbrflct_ver_micro <= KUsbrflctVersionMicro) && |
|
1656 |
!(usbrflct_ver_micro == KUsbrflctVersionMicro)) |
|
1657 |
{ |
|
1658 |
TUSB_PRINT3("USBRFLCT version not sufficient (need at least v%d.%d.%d)\n", |
|
1659 |
KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1660 |
OstTraceExt3(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP04, "USBRFLCT version not sufficient (need at least v%d.%d.%d)\n", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1661 |
KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
0 | 1662 |
return KErrGeneral; |
1663 |
} |
|
1664 |
// Now we send T_USB's version to the host |
|
1665 |
r = SendVersion(); |
|
1666 |
if (r != KErrNone) |
|
1667 |
{ |
|
1668 |
return KErrGeneral; |
|
1669 |
} |
|
1670 |
return KErrNone; |
|
1671 |
} |
|
1672 |
||
1673 |
||
1674 |
void CActiveRW::SendPreamble() |
|
1675 |
{ |
|
1676 |
TUSB_VERBOSE_PRINT("CActiveRW::SendPreamble()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1677 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1678 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1679 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_SENDPREAMBLE, "CActiveRW::SendPreamble()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1680 |
} |
0 | 1681 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
1682 |
TUSB_VERBOSE_PRINT1("Sending data length: %d bytes", iBufSz); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1683 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1684 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1685 |
OstTrace1(TRACE_VERBOSE, CACTIVERW_SENDPREAMBLE_DUP01, "Sending data length: %d bytes", iBufSz); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1686 |
} |
0 | 1687 |
*reinterpret_cast<TUint32*>(&iPreambleBuf[0]) = SWAP_BYTES_32(iBufSz); |
1688 |
iPort->Write(iStatus, EEndpoint1, iPreambleBuf, KPreambleLength); |
|
1689 |
iCurrentXfer = EPreamble; |
|
1690 |
SetActive(); |
|
1691 |
} |
|
1692 |
||
1693 |
||
1694 |
void CActiveRW::SendData() |
|
1695 |
{ |
|
1696 |
TUSB_VERBOSE_PRINT("CActiveRW::SendData()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1697 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1698 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1699 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_SENDDATA, "CActiveRW::SendData()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1700 |
} |
0 | 1701 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
1702 |
if (iDiskAccessEnabled) |
|
1703 |
{ |
|
1704 |
ReadBufferFromDisk(iWriteBuf, iBufSz); |
|
1705 |
} |
|
1706 |
++iPktNum; |
|
1707 |
if (iBufSz > 3) |
|
1708 |
{ |
|
1709 |
*reinterpret_cast<TUint32*>(const_cast<TUint8*>(iWriteBuf.Ptr())) = iPktNum; |
|
1710 |
} |
|
1711 |
if (iXferMode == ELoopComp) |
|
1712 |
{ |
|
1713 |
for (TInt i = 4; i < iBufSz; i++) |
|
1714 |
{ |
|
1715 |
iWriteBuf[i] = static_cast<TUint8>(iPktNum & 0x000000ff); |
|
1716 |
} |
|
1717 |
} |
|
1718 |
TUSB_VERBOSE_PRINT1("Sending data: %d bytes", iBufSz); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1719 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1720 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1721 |
OstTrace1(TRACE_VERBOSE, CACTIVERW_SENDDATA_DUP01, "Sending data: %d bytes", iBufSz); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1722 |
} |
0 | 1723 |
iPort->Write(iStatus, EEndpoint1, iWriteBuf, iBufSz); |
1724 |
iCurrentXfer = EWriteXfer; |
|
1725 |
SetActive(); |
|
1726 |
} |
|
1727 |
||
1728 |
||
1729 |
TInt CActiveRW::SelectDrive() |
|
1730 |
{ |
|
1731 |
TDriveList driveList; |
|
1732 |
TInt r = iFs.DriveList(driveList); |
|
1733 |
if (r != KErrNone) |
|
1734 |
{ |
|
1735 |
TUSB_PRINT1("RFs::DriveList() returned %d", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1736 |
OstTrace1(TRACE_NORMAL, CACTIVERW_SELECTDRIVE, "RFs::DriveList() returned %d", r); |
0 | 1737 |
return r; |
1738 |
} |
|
1739 |
TUSB_PRINT("Available drives:"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1740 |
OstTrace0(TRACE_NORMAL, CACTIVERW_SELECTDRIVE_DUP01, "Available drives:"); |
0 | 1741 |
for (TInt n = 0; n < KMaxDrives; n++) |
1742 |
{ |
|
1743 |
if (driveList[n] != 0) |
|
1744 |
{ |
|
1745 |
TVolumeInfo volumeInfo; |
|
1746 |
r = iFs.Volume(volumeInfo, n); |
|
1747 |
if (r == KErrNone) |
|
1748 |
{ |
|
1749 |
TPtr name(volumeInfo.iName.Des()); |
|
1750 |
TUSB_PRINT2("Drive %c: %- 16S", 'A' + n, &name); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1751 |
OstTraceExt2(TRACE_NORMAL, CACTIVERW_SELECTDRIVE_DUP02, "Drive %c: %S", 'A' + n, name); |
0 | 1752 |
if (volumeInfo.iDrive.iMediaAtt & KMediaAttWriteProtected) |
1753 |
TUSB_PRINT(" (read-only)"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1754 |
OstTrace0(TRACE_NORMAL, CACTIVERW_SELECTDRIVE_DUP03, " (read-only)"); |
0 | 1755 |
TUSB_PRINT(""); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1756 |
OstTrace0(TRACE_NORMAL, CACTIVERW_SELECTDRIVE_DUP04, ""); |
0 | 1757 |
} |
1758 |
} |
|
1759 |
} |
|
1760 |
iConsole->Printf(_L("Please select a drive letter (or 'Q' to quit)...")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1761 |
OstTrace0(TRACE_NORMAL, CACTIVERW_SELECTDRIVE_DUP05, "Please select a drive letter (or 'Q' to quit..."); |
0 | 1762 |
TChar driveLetter; |
1763 |
TInt driveNumber; |
|
1764 |
TVolumeInfo volumeInfo; |
|
1765 |
do |
|
1766 |
{ |
|
1767 |
driveLetter = (TUint)iConsole->Getch(); |
|
1768 |
driveLetter.UpperCase(); |
|
1769 |
if (driveLetter == 'Q') |
|
1770 |
{ |
|
1771 |
return KErrCancel; |
|
1772 |
} |
|
1773 |
driveNumber = (TUint)driveLetter - 'A'; |
|
1774 |
r = iFs.Volume(volumeInfo, driveNumber); |
|
1775 |
} |
|
1776 |
while ((driveNumber < 0) || |
|
1777 |
(driveNumber >= KMaxDrives) || |
|
1778 |
(r) || |
|
1779 |
(driveList[driveNumber] == 0) || |
|
1780 |
(volumeInfo.iDrive.iMediaAtt & KMediaAttWriteProtected)); |
|
1781 |
||
1782 |
iFileName.Format(_L("%c:"), driveLetter.operator TUint()); |
|
1783 |
iFileName.Append(KFileName); |
|
1784 |
TUSB_PRINT1("\nFilename = %S", &iFileName); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1785 |
OstTraceExt1(TRACE_NORMAL, CACTIVERW_SELECTDRIVE_DUP06, "\nFilename = %S", iFileName); |
0 | 1786 |
TUSB_PRINT1("File size: %d", KMaxFileSize); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1787 |
OstTrace1(TRACE_NORMAL, CACTIVERW_SELECTDRIVE_DUP07, "File size: %d", KMaxFileSize); |
0 | 1788 |
return r; |
1789 |
} |
|
1790 |
||
1791 |
||
1792 |
TInt CActiveRW::WriteToDisk(TBool aEnable) |
|
1793 |
{ |
|
1794 |
iDiskAccessEnabled = aEnable; |
|
1795 |
TInt r = KErrNone; |
|
1796 |
||
1797 |
if (iDiskAccessEnabled) |
|
1798 |
{ |
|
1799 |
r = SelectDrive(); |
|
1800 |
if (r != KErrNone) |
|
1801 |
{ |
|
1802 |
iDiskAccessEnabled = EFalse; |
|
1803 |
return r; |
|
1804 |
} |
|
1805 |
// open the record file |
|
1806 |
r = iFile.Replace(iFs, iFileName, EFileWrite); |
|
1807 |
iFileOffset = 0; |
|
1808 |
} |
|
1809 |
return r; |
|
1810 |
} |
|
1811 |
||
1812 |
||
1813 |
TInt CActiveRW::ReadFromDisk(TBool aEnable) |
|
1814 |
{ |
|
1815 |
iDiskAccessEnabled = aEnable; |
|
1816 |
TInt r = KErrNone; |
|
1817 |
||
1818 |
if (iDiskAccessEnabled) |
|
1819 |
{ |
|
1820 |
r = SelectDrive(); |
|
1821 |
if (r != KErrNone) |
|
1822 |
{ |
|
1823 |
iDiskAccessEnabled = EFalse; |
|
1824 |
return r; |
|
1825 |
} |
|
1826 |
// First create the file & fill it |
|
1827 |
r = iFile.Replace(iFs, iFileName, EFileWrite); |
|
1828 |
if (r != KErrNone) |
|
1829 |
{ |
|
1830 |
TUSB_PRINT1("RFile::Replace() returned %d", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1831 |
OstTrace1(TRACE_NORMAL, CACTIVERW_READFROMDISK, "RFile::Replace() returned %d", r); |
0 | 1832 |
iDiskAccessEnabled = EFalse; |
1833 |
return r; |
|
1834 |
} |
|
1835 |
const TInt KBufferSize = 4 * 1024; |
|
1836 |
TBuf8<KBufferSize> buffer; |
|
1837 |
buffer.SetLength(KBufferSize); |
|
1838 |
for (TInt n = 0; n < KBufferSize; n++) |
|
1839 |
{ |
|
1840 |
buffer[n] = static_cast<TUint8>(n & 0x000000ff); |
|
1841 |
} |
|
1842 |
TUSB_PRINT("Writing data to file (this may take some minutes...)"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1843 |
OstTrace0(TRACE_NORMAL, CACTIVERW_READFROMDISK_DUP01, "Writing data to file (this may take some minutes...)"); |
0 | 1844 |
for (TInt n = 0; n < KMaxFileSize; n += KBufferSize) |
1845 |
{ |
|
1846 |
r = iFile.Write(buffer, KBufferSize); |
|
1847 |
if (r != KErrNone) |
|
1848 |
{ |
|
1849 |
TUSB_PRINT1("RFile::Write() returned %d (disk full?)", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1850 |
OstTrace1(TRACE_NORMAL, CACTIVERW_READFROMDISK_DUP02, "RFile::Write() returned %d (disk full?)", r); |
0 | 1851 |
iFile.Close(); |
1852 |
iDiskAccessEnabled = EFalse; |
|
1853 |
return r; |
|
1854 |
} |
|
1855 |
} |
|
1856 |
TUSB_PRINT("Done."); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1857 |
OstTrace0(TRACE_NORMAL, CACTIVERW_READFROMDISK_DUP03, "Done."); |
0 | 1858 |
iFile.Close(); |
1859 |
// Now open the file for reading |
|
1860 |
r = iFile.Open(iFs, iFileName, EFileRead); |
|
1861 |
if (r != KErrNone) |
|
1862 |
{ |
|
1863 |
TUSB_PRINT1("RFile::Open() returned %d", r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1864 |
OstTrace1(TRACE_NORMAL, CACTIVERW_READFROMDISK_DUP04, "RFile::Open() returned %d", r); |
0 | 1865 |
iDiskAccessEnabled = EFalse; |
1866 |
return r; |
|
1867 |
} |
|
1868 |
iFileOffset = 0; |
|
1869 |
} |
|
1870 |
return r; |
|
1871 |
} |
|
1872 |
||
1873 |
||
1874 |
void CActiveRW::WriteBufferToDisk(TDes8& aBuffer, TInt aLen) |
|
1875 |
{ |
|
1876 |
TUSB_VERBOSE_PRINT1("CActiveRW::WriteBufferToDisk(), len = %d", aLen); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1877 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1878 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1879 |
OstTrace1(TRACE_VERBOSE, CACTIVERW_WRITEBUFFERTODISK, "CActiveRW::WriteBufferToDisk(), len = %d", aLen); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1880 |
} |
0 | 1881 |
TInt r = iFile.Write(aBuffer, aLen); |
1882 |
if (r != KErrNone) |
|
1883 |
{ |
|
1884 |
TUSB_PRINT2("Error writing to %S (%d)", &iFileName, r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1885 |
OstTraceExt2(TRACE_NORMAL, CACTIVERW_WRITEBUFFERTODISK_DUP01, "Error writing to %S (%d)", iFileName, r); |
0 | 1886 |
iDiskAccessEnabled = EFalse; |
1887 |
return; |
|
1888 |
} |
|
1889 |
iFileOffset += aLen; |
|
1890 |
if (iFileOffset >= KMaxFileSize) |
|
1891 |
{ |
|
1892 |
iFileOffset = 0; |
|
1893 |
iFile.Seek(ESeekStart, iFileOffset); |
|
1894 |
} |
|
1895 |
} |
|
1896 |
||
1897 |
||
1898 |
void CActiveRW::ReadBufferFromDisk(TDes8& aBuffer, TInt aLen) |
|
1899 |
{ |
|
1900 |
if (iFileOffset + aLen >= KMaxFileSize) |
|
1901 |
{ |
|
1902 |
iFileOffset = 0; |
|
1903 |
iFile.Seek(ESeekStart, iFileOffset); |
|
1904 |
} |
|
1905 |
const TInt r = iFile.Read(aBuffer, aLen); |
|
1906 |
if (r != KErrNone) |
|
1907 |
{ |
|
1908 |
TUSB_PRINT2("Error reading from %S (%d)", &iFileName, r); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1909 |
OstTraceExt2(TRACE_NORMAL, CACTIVERW_READBUFFERFROMDISK, "Error reading from %S (%d)", iFileName, r); |
0 | 1910 |
iDiskAccessEnabled = EFalse; |
1911 |
return; |
|
1912 |
} |
|
1913 |
TInt readLen = aBuffer.Length(); |
|
1914 |
TUSB_VERBOSE_PRINT1("CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1915 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1916 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1917 |
OstTrace1(TRACE_VERBOSE, CACTIVERW_READBUFFERFROMDISK_DUP01, "CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1918 |
} |
0 | 1919 |
if (readLen < aLen) |
1920 |
{ |
|
1921 |
TUSB_PRINT3("Only %d bytes of %d read from file %S)", |
|
1922 |
readLen, aLen, &iFileName); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1923 |
OstTraceExt3(TRACE_NORMAL, CACTIVERW_READBUFFERFROMDISK_DUP02, "Only %d bytes of %d read from file %S)", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1924 |
readLen, aLen, iFileName); |
0 | 1925 |
iDiskAccessEnabled = EFalse; |
1926 |
return; |
|
1927 |
} |
|
1928 |
iFileOffset += aLen; |
|
1929 |
} |
|
1930 |
||
1931 |
||
1932 |
void CActiveRW::ReadData() |
|
1933 |
{ |
|
1934 |
TUSB_VERBOSE_PRINT("CActiveRW::ReadData()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1935 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1936 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1937 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA, "CActiveRW::ReadData()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1938 |
} |
0 | 1939 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
1940 |
TUSB_VERBOSE_PRINT1("Reading data: %d bytes", iBufSz); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1941 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1942 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1943 |
OstTrace1(TRACE_VERBOSE, CACTIVERW_READDATA_DUP01, "Reading data: %d bytes", iBufSz); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1944 |
} |
0 | 1945 |
if (iXferMode == EReceiveOnly) |
1946 |
{ |
|
1947 |
TUSB_VERBOSE_PRINT(" (rx only)"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1948 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1949 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1950 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP02, " (rx only)"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1951 |
} |
0 | 1952 |
iPort->Read(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1953 |
} |
|
1954 |
else if (iBufSz == iMaxPktSz) |
|
1955 |
{ |
|
1956 |
// we also want to test the packet version of Read() |
|
1957 |
TUSB_VERBOSE_PRINT(" (a single packet)"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1958 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1959 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1960 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP03, " (a single packet)"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1961 |
} |
0 | 1962 |
iPort->ReadPacket(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1963 |
} |
|
1964 |
else if (iBufSz == iReadBuf.MaxSize()) |
|
1965 |
{ |
|
1966 |
// or we could perhaps test the three-parameter version |
|
1967 |
TUSB_VERBOSE_PRINT(" (w/o length)"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1968 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1969 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1970 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP04, " (w/o length)"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1971 |
} |
0 | 1972 |
iPort->Read(iStatus, EEndpoint2, iReadBuf); |
1973 |
} |
|
1974 |
else |
|
1975 |
{ |
|
1976 |
// otherwise, we use the universal default version |
|
1977 |
TUSB_VERBOSE_PRINT(" (normal)"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1978 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1979 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1980 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP05, " (normal)"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1981 |
} |
0 | 1982 |
iPort->Read(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1983 |
} |
|
1984 |
iCurrentXfer = EReadXfer; |
|
1985 |
SetActive(); |
|
1986 |
} |
|
1987 |
||
1988 |
||
1989 |
void CActiveRW::Stop() |
|
1990 |
{ |
|
1991 |
if (!IsActive()) |
|
1992 |
{ |
|
1993 |
TUSB_PRINT("CActiveRW::Stop(): Not active"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1994 |
OstTrace0(TRACE_NORMAL, CACTIVERW_STOP, "CActiveRW::Stop(): Not active"); |
0 | 1995 |
return; |
1996 |
} |
|
1997 |
TUSB_PRINT("Cancelling outstanding transfer requests\n"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1998 |
OstTrace0(TRACE_NORMAL, CACTIVERW_STOP_DUP01, "Cancelling outstanding transfer requests\n"); |
0 | 1999 |
iBufSz = KInitialBufSz; |
2000 |
iPktNum = ~0; |
|
2001 |
iDoStop = ETrue; |
|
2002 |
iCurrentXfer = ENone; |
|
2003 |
Cancel(); |
|
2004 |
} |
|
2005 |
||
2006 |
||
2007 |
void CActiveRW::DoCancel() |
|
2008 |
{ |
|
2009 |
TUSB_VERBOSE_PRINT("CActiveRW::DoCancel()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2010 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2011 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2012 |
OstTrace0(TRACE_VERBOSE, CACTIVERW_DOCANCEL, "CActiveRW::DoCancel()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2013 |
} |
0 | 2014 |
// Canceling the transfer requests can be done explicitly |
2015 |
// for every transfer... |
|
2016 |
iPort->WriteCancel(EEndpoint1); |
|
2017 |
iPort->ReadCancel(EEndpoint2); |
|
2018 |
// or like this: |
|
2019 |
iPort->EndpointTransferCancel(~0); |
|
2020 |
} |
|
2021 |
||
2022 |
||
2023 |
TBool CActiveRW::CompareBuffers(TInt aLen) |
|
2024 |
{ |
|
2025 |
TUSB_VERBOSE_PRINT1("CActiveRW::CompareBuffers(%d)", aLen); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2026 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2027 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2028 |
OstTrace1(TRACE_VERBOSE, CACTIVERW_COMPAREBUFFERS, "CActiveRW::CompareBuffers(%d)", aLen); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2029 |
} |
0 | 2030 |
for (TInt i = 0; i < aLen; i++) |
2031 |
{ |
|
2032 |
if (iReadBuf[i] != iWriteBuf[i]) |
|
2033 |
{ |
|
2034 |
TUSB_VERBOSE_PRINT1("Error: for i = %d:", i); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2035 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2036 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2037 |
OstTrace1(TRACE_VERBOSE, CACTIVERW_COMPAREBUFFERS_DUP01, "Error: for i = %d:", i); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2038 |
} |
0 | 2039 |
TUSB_VERBOSE_PRINT2("iReadBuf: %d != iWriteBuf: %d", |
2040 |
iReadBuf[i], iWriteBuf[i]); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2041 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2042 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2043 |
OstTraceExt2(TRACE_VERBOSE, CACTIVERW_COMPAREBUFFERS_DUP02, "iReadBuf: %d != iWriteBuf: %d", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2044 |
iReadBuf[i], iWriteBuf[i]); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2045 |
} |
0 | 2046 |
return EFalse; |
2047 |
} |
|
2048 |
} |
|
2049 |
return ETrue; |
|
2050 |
} |
|
2051 |
||
2052 |
||
2053 |
// |
|
2054 |
// --- class CActiveStallNotifier --------------------------------------------------------- |
|
2055 |
// |
|
2056 |
||
2057 |
CActiveStallNotifier::CActiveStallNotifier(CConsoleBase* aConsole, RDevUsbcClient* aPort, |
|
2058 |
TBool aVerboseOutput) |
|
2059 |
: CActive(EPriorityNormal), |
|
2060 |
iConsole(aConsole), |
|
2061 |
iPort(aPort), |
|
2062 |
iEndpointState(0), |
|
2063 |
iVerbose(aVerboseOutput) |
|
2064 |
{ |
|
2065 |
CActiveScheduler::Add(this); |
|
2066 |
} |
|
2067 |
||
2068 |
CActiveStallNotifier* CActiveStallNotifier::NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, |
|
2069 |
TBool aVerboseOutput) |
|
2070 |
{ |
|
2071 |
CActiveStallNotifier* self = new (ELeave) CActiveStallNotifier(aConsole, aPort, aVerboseOutput); |
|
2072 |
CleanupStack::PushL(self); |
|
2073 |
self->ConstructL(); |
|
2074 |
CleanupStack::Pop(); // self |
|
2075 |
return self; |
|
2076 |
} |
|
2077 |
||
2078 |
||
2079 |
void CActiveStallNotifier::ConstructL() |
|
2080 |
{} |
|
2081 |
||
2082 |
||
2083 |
CActiveStallNotifier::~CActiveStallNotifier() |
|
2084 |
{ |
|
2085 |
TUSB_VERBOSE_PRINT("CActiveStallNotifier::~CActiveStallNotifier()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2086 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2087 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2088 |
OstTrace0(TRACE_VERBOSE, CACTIVESTALLNOTIFIER_DCACTIVESTALLNOTIFIER, "CActiveStallNotifier::~CActiveStallNotifier()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2089 |
} |
0 | 2090 |
Cancel(); // base class |
2091 |
} |
|
2092 |
||
2093 |
||
2094 |
void CActiveStallNotifier::DoCancel() |
|
2095 |
{ |
|
2096 |
TUSB_VERBOSE_PRINT("CActiveStallNotifier::DoCancel()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2097 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2098 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2099 |
OstTrace0(TRACE_VERBOSE, CACTIVESTALLNOTIFIER_DOCANCEL, "CActiveStallNotifier::DoCancel()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2100 |
} |
0 | 2101 |
iPort->EndpointStatusNotifyCancel(); |
2102 |
} |
|
2103 |
||
2104 |
||
2105 |
void CActiveStallNotifier::RunL() |
|
2106 |
{ |
|
2107 |
// This just displays the bitmap, showing which endpoints (if any) are now stalled. |
|
2108 |
// In a real world program, the user could take here appropriate action (cancel a |
|
2109 |
// transfer request or whatever). |
|
2110 |
TUSB_VERBOSE_PRINT1("StallNotifier: Endpointstate 0x%x\n", iEndpointState); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2111 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2112 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2113 |
OstTrace1(TRACE_VERBOSE, CACTIVESTALLNOTIFIER_RUNL, "StallNotifier: Endpointstate 0x%x\n", iEndpointState); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2114 |
} |
0 | 2115 |
Activate(); |
2116 |
} |
|
2117 |
||
2118 |
||
2119 |
void CActiveStallNotifier::Activate() |
|
2120 |
{ |
|
2121 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
|
2122 |
iPort->EndpointStatusNotify(iStatus, iEndpointState); |
|
2123 |
SetActive(); |
|
2124 |
} |
|
2125 |
||
2126 |
||
2127 |
// |
|
2128 |
// --- class CActiveDeviceStateNotifier --------------------------------------------------------- |
|
2129 |
// |
|
2130 |
||
2131 |
CActiveDeviceStateNotifier::CActiveDeviceStateNotifier(CConsoleBase* aConsole, RDevUsbcClient* aPort, |
|
2132 |
TBool aVerboseOutput) |
|
2133 |
: CActive(EPriorityNormal), |
|
2134 |
iConsole(aConsole), |
|
2135 |
iPort(aPort), |
|
2136 |
iDeviceState(0), |
|
2137 |
iVerbose(aVerboseOutput) |
|
2138 |
{ |
|
2139 |
CActiveScheduler::Add(this); |
|
2140 |
} |
|
2141 |
||
2142 |
CActiveDeviceStateNotifier* CActiveDeviceStateNotifier::NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, |
|
2143 |
TBool aVerboseOutput) |
|
2144 |
{ |
|
2145 |
CActiveDeviceStateNotifier* self = new (ELeave) CActiveDeviceStateNotifier(aConsole, aPort, aVerboseOutput); |
|
2146 |
CleanupStack::PushL(self); |
|
2147 |
self->ConstructL(); |
|
2148 |
CleanupStack::Pop(); // self |
|
2149 |
return self; |
|
2150 |
} |
|
2151 |
||
2152 |
||
2153 |
void CActiveDeviceStateNotifier::ConstructL() |
|
2154 |
{} |
|
2155 |
||
2156 |
||
2157 |
CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() |
|
2158 |
{ |
|
2159 |
TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2160 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2161 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2162 |
OstTrace0(TRACE_VERBOSE, CACTIVEDEVICESTATENOTIFIER_DCACTIVEDEVICESTATENOTIFIER, "CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2163 |
} |
0 | 2164 |
Cancel(); // base class |
2165 |
} |
|
2166 |
||
2167 |
||
2168 |
void CActiveDeviceStateNotifier::DoCancel() |
|
2169 |
{ |
|
2170 |
TUSB_VERBOSE_PRINT("CActiveDeviceStateNotifier::DoCancel()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2171 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2172 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2173 |
OstTrace0(TRACE_VERBOSE, CACTIVEDEVICESTATENOTIFIER_DOCANCEL, "CActiveDeviceStateNotifier::DoCancel()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2174 |
} |
0 | 2175 |
iPort->AlternateDeviceStatusNotifyCancel(); |
2176 |
} |
|
2177 |
||
2178 |
||
2179 |
void CActiveDeviceStateNotifier::RunL() |
|
2180 |
{ |
|
2181 |
// This displays the device state. |
|
2182 |
// In a real world program, the user could take here appropriate action (cancel a |
|
2183 |
// transfer request or whatever). |
|
2184 |
if (!(iDeviceState & KUsbAlternateSetting) && iVerbose) |
|
2185 |
{ |
|
2186 |
switch (iDeviceState) |
|
2187 |
{ |
|
2188 |
case EUsbcDeviceStateUndefined: |
|
2189 |
TUSB_PRINT("Device State notifier: Undefined"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2190 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL, "Device State notifier: Undefined"); |
0 | 2191 |
break; |
2192 |
case EUsbcDeviceStateAttached: |
|
2193 |
TUSB_PRINT("Device State notifier: Attached"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2194 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP01, "Device State notifier: Attached"); |
0 | 2195 |
break; |
2196 |
case EUsbcDeviceStatePowered: |
|
2197 |
TUSB_PRINT("Device State notifier: Powered"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2198 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP02, "Device State notifier: Powered"); |
0 | 2199 |
break; |
2200 |
case EUsbcDeviceStateDefault: |
|
2201 |
TUSB_PRINT("Device State notifier: Default"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2202 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP03, "Device State notifier: Default"); |
0 | 2203 |
break; |
2204 |
case EUsbcDeviceStateAddress: |
|
2205 |
TUSB_PRINT("Device State notifier: Address"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2206 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP04, "Device State notifier: Address"); |
0 | 2207 |
break; |
2208 |
case EUsbcDeviceStateConfigured: |
|
2209 |
TUSB_PRINT("Device State notifier: Configured"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2210 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP05, "Device State notifier: Configured"); |
0 | 2211 |
break; |
2212 |
case EUsbcDeviceStateSuspended: |
|
2213 |
TUSB_PRINT("Device State notifier: Suspended"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2214 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP06, "Device State notifier: Suspended"); |
0 | 2215 |
break; |
2216 |
default: |
|
2217 |
TUSB_PRINT("Device State notifier: ***BAD***"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2218 |
OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP07, "Device State notifier: ***BAD***"); |
0 | 2219 |
} |
2220 |
} |
|
2221 |
else if (iDeviceState & KUsbAlternateSetting) |
|
2222 |
{ |
|
2223 |
TUSB_PRINT1("Device State notifier: Alternate interface setting has changed: now %d", |
|
2224 |
iDeviceState & ~KUsbAlternateSetting); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2225 |
OstTrace1(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP08, "Device State notifier: Alternate interface setting has changed: now %d", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2226 |
iDeviceState & ~KUsbAlternateSetting); |
0 | 2227 |
} |
19
4a8fed1c0ef6
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2228 |
|
0 | 2229 |
Activate(); |
2230 |
} |
|
2231 |
||
2232 |
||
2233 |
void CActiveDeviceStateNotifier::Activate() |
|
2234 |
{ |
|
2235 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
|
2236 |
iPort->AlternateDeviceStatusNotify(iStatus, iDeviceState); |
|
2237 |
SetActive(); |
|
2238 |
} |
|
2239 |
||
2240 |
||
2241 |
// |
|
2242 |
// --- class CActiveTimer --------------------------------------------------------- |
|
2243 |
// |
|
2244 |
||
2245 |
CActiveTimer::CActiveTimer(CConsoleBase* aConsole, RDevUsbcClient* aPort, |
|
2246 |
TBool aVerboseOutput) |
|
2247 |
: CActive(EPriorityNormal), |
|
2248 |
iConsole(aConsole), |
|
2249 |
iPort(aPort), |
|
2250 |
iVerbose(aVerboseOutput) |
|
2251 |
{ |
|
2252 |
CActiveScheduler::Add(this); |
|
2253 |
} |
|
2254 |
||
2255 |
||
2256 |
CActiveTimer* CActiveTimer::NewL(CConsoleBase* aConsole, RDevUsbcClient* aPort, |
|
2257 |
TBool aVerboseOutput) |
|
2258 |
{ |
|
2259 |
CActiveTimer* self = new (ELeave) CActiveTimer(aConsole, aPort, aVerboseOutput); |
|
2260 |
CleanupStack::PushL(self); |
|
2261 |
self->ConstructL(); |
|
2262 |
CleanupStack::Pop(); // self |
|
2263 |
return self; |
|
2264 |
} |
|
2265 |
||
2266 |
||
2267 |
void CActiveTimer::ConstructL() |
|
2268 |
{ |
|
2269 |
User::LeaveIfError(iTimer.CreateLocal()); |
|
2270 |
} |
|
2271 |
||
2272 |
||
2273 |
CActiveTimer::~CActiveTimer() |
|
2274 |
{ |
|
2275 |
TUSB_VERBOSE_PRINT("CActiveTimer::~CActiveTimer()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2276 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2277 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2278 |
OstTrace0(TRACE_VERBOSE, CACTIVETIMER_DCACTIVETIMER, "CActiveTimer::~CActiveTimer()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2279 |
} |
0 | 2280 |
Cancel(); // base class |
2281 |
iTimer.Close(); |
|
2282 |
} |
|
2283 |
||
2284 |
||
2285 |
void CActiveTimer::DoCancel() |
|
2286 |
{ |
|
2287 |
TUSB_VERBOSE_PRINT("CActiveTimer::DoCancel()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2288 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2289 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2290 |
OstTrace0(TRACE_VERBOSE, CACTIVETIMER_DOCANCEL, "CActiveTimer::DoCancel()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2291 |
} |
0 | 2292 |
iTimer.Cancel(); |
2293 |
} |
|
2294 |
||
2295 |
||
2296 |
void CActiveTimer::RunL() |
|
2297 |
{ |
|
2298 |
TUSB_VERBOSE_PRINT("CActiveTimer::RunL()"); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2299 |
if(iVerbose) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2300 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2301 |
OstTrace0(TRACE_VERBOSE, CACTIVETIMER_RUNL, "CActiveTimer::RunL()"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
2302 |
} |
0 | 2303 |
// Nothing to do here, as we call ReadCancel() after a manual WaitForRequest() |
2304 |
// (in CActiveRW::ReceiveVersion()). |
|
2305 |
} |
|
2306 |
||
2307 |
||
2308 |
void CActiveTimer::Activate(TTimeIntervalMicroSeconds32 aDelay) |
|
2309 |
{ |
|
2310 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
|
2311 |
iTimer.After(iStatus, aDelay); |
|
2312 |
SetActive(); |
|
2313 |
} |
|
2314 |
||
2315 |
||
2316 |
// -eof- |