93 // was already loaded at boot time.) |
89 // was already loaded at boot time.) |
94 TInt r = User::LoadLogicalDevice(KUsbLddFilename); |
90 TInt r = User::LoadLogicalDevice(KUsbLddFilename); |
95 if (r != KErrNone && r != KErrAlreadyExists) |
91 if (r != KErrNone && r != KErrAlreadyExists) |
96 { |
92 { |
97 TUSB_PRINT1("Error %d on loading USB LDD", r); |
93 TUSB_PRINT1("Error %d on loading USB LDD", r); |
98 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL, "Error %d on loading USB LDD", r); |
|
99 User::Leave(-1); |
94 User::Leave(-1); |
100 return; |
95 return; |
101 } |
96 } |
102 TUSB_PRINT("Successfully loaded USB LDD"); |
97 TUSB_PRINT("Successfully loaded USB LDD"); |
103 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP01, "Successfully loaded USB LDD"); |
|
104 |
98 |
105 // Open USB channel |
99 // Open USB channel |
106 r = iPort.Open(0); |
100 r = iPort.Open(0); |
107 if (r != KErrNone) |
101 if (r != KErrNone) |
108 { |
102 { |
109 TUSB_PRINT1("Error %d on opening USB port", r); |
103 TUSB_PRINT1("Error %d on opening USB port", r); |
110 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP02, "Error %d on opening USB port", r); |
|
111 User::Leave(-1); |
104 User::Leave(-1); |
112 return; |
105 return; |
113 } |
106 } |
114 TUSB_PRINT("Successfully opened USB port"); |
107 TUSB_PRINT("Successfully opened USB port"); |
115 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP03, "Successfully opened USB port"); |
|
116 |
108 |
117 // Create Reader/Writer active object |
109 // Create Reader/Writer active object |
118 iRW = CActiveRW::NewL(iConsole, &iPort, iVerbose); |
110 iRW = CActiveRW::NewL(iConsole, &iPort, iVerbose); |
119 if (!iRW) |
111 if (!iRW) |
120 { |
112 { |
121 TUSB_PRINT("Failed to create reader/writer"); |
113 TUSB_PRINT("Failed to create reader/writer"); |
122 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP04, "Failed to create reader/writer"); |
|
123 User::Leave(-1); |
114 User::Leave(-1); |
124 return; |
115 return; |
125 } |
116 } |
126 TUSB_PRINT("Created reader/writer"); |
117 TUSB_PRINT("Created reader/writer"); |
127 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP05, "Created reader/writer"); |
|
128 |
118 |
129 // check for endpoint resource allocation v2 support |
119 // check for endpoint resource allocation v2 support |
130 TUsbDeviceCaps d_caps; |
120 TUsbDeviceCaps d_caps; |
131 r = iPort.DeviceCaps(d_caps); |
121 r = iPort.DeviceCaps(d_caps); |
132 if (r != KErrNone) |
122 if (r != KErrNone) |
133 { |
123 { |
134 TUSB_PRINT1("Error %d on querying device capabilities", r); |
124 TUSB_PRINT1("Error %d on querying device capabilities", r); |
135 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_CONSTRUCTL_DUP06, "Error %d on querying device capabilities", r); |
|
136 User::Leave(-1); |
125 User::Leave(-1); |
137 return; |
126 return; |
138 } |
127 } |
139 iResourceAllocationV2 = ((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0); |
128 iResourceAllocationV2 = ((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0); |
140 |
129 |
189 // Query the USB device/Setup the USB interface |
173 // Query the USB device/Setup the USB interface |
190 TInt r = QueryUsbClientL(); |
174 TInt r = QueryUsbClientL(); |
191 if (r != KErrNone) |
175 if (r != KErrNone) |
192 { |
176 { |
193 TUSB_PRINT1("Interface setup failed", r); |
177 TUSB_PRINT1("Interface setup failed", r); |
194 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE, "Interface setup failed:%d", r); |
|
195 return r; |
178 return r; |
196 } |
179 } |
197 TUSB_PRINT("Interface successfully set up"); |
180 TUSB_PRINT("Interface successfully set up"); |
198 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP01, "Interface successfully set up"); |
|
199 |
181 |
200 // Change some descriptors to contain suitable values |
182 // Change some descriptors to contain suitable values |
201 r = SetupDescriptors(); |
183 r = SetupDescriptors(); |
202 if (r != KErrNone) |
184 if (r != KErrNone) |
203 { |
185 { |
204 TUSB_PRINT1("Descriptor setup failed", r); |
186 TUSB_PRINT1("Descriptor setup failed", r); |
205 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP02, "Descriptor setup failed:%d ", r); |
|
206 return r; |
187 return r; |
207 } |
188 } |
208 |
189 |
209 // Create device state active object |
190 // Create device state active object |
210 iDeviceStateNotifier = CActiveDeviceStateNotifier::NewL(iConsole, &iPort, iVerbose); |
191 iDeviceStateNotifier = CActiveDeviceStateNotifier::NewL(iConsole, &iPort, iVerbose); |
211 if (!iDeviceStateNotifier) |
192 if (!iDeviceStateNotifier) |
212 { |
193 { |
213 TUSB_PRINT("Failed to create device state notifier"); |
194 TUSB_PRINT("Failed to create device state notifier"); |
214 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP03, "Failed to create device state notifier"); |
|
215 return r; |
195 return r; |
216 } |
196 } |
217 iDeviceStateNotifier->Activate(); |
197 iDeviceStateNotifier->Activate(); |
218 |
198 |
219 // Create endpoint stall status active object |
199 // Create endpoint stall status active object |
220 iStallNotifier = CActiveStallNotifier::NewL(iConsole, &iPort, iVerbose); |
200 iStallNotifier = CActiveStallNotifier::NewL(iConsole, &iPort, iVerbose); |
221 if (!iStallNotifier) |
201 if (!iStallNotifier) |
222 { |
202 { |
223 TUSB_PRINT("Failed to create stall notifier"); |
203 TUSB_PRINT("Failed to create stall notifier"); |
224 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_SETUPINTERFACE_DUP04, "Failed to create stall notifier"); |
|
225 return r; |
204 return r; |
226 } |
205 } |
227 iStallNotifier->Activate(); |
206 iStallNotifier->Activate(); |
228 |
207 |
229 return r; |
208 return r; |
231 |
210 |
232 |
211 |
233 CActiveConsole::~CActiveConsole() |
212 CActiveConsole::~CActiveConsole() |
234 { |
213 { |
235 TUSB_VERBOSE_PRINT("CActiveConsole::~CActiveConsole()"); |
214 TUSB_VERBOSE_PRINT("CActiveConsole::~CActiveConsole()"); |
236 if(iVerbose) |
|
237 { |
|
238 OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_DCACTIVECONSOLE, "CActiveConsole::~CActiveConsole()"); |
|
239 } |
|
240 Cancel(); // base class cancel -> calls our DoCancel |
215 Cancel(); // base class cancel -> calls our DoCancel |
241 delete iRW; // destroy the reader/writer |
216 delete iRW; // destroy the reader/writer |
242 delete iDeviceStateNotifier; |
217 delete iDeviceStateNotifier; |
243 delete iStallNotifier; |
218 delete iStallNotifier; |
244 TInt r = iPort.RemoveStringDescriptor(stridx1); |
219 TInt r = iPort.RemoveStringDescriptor(stridx1); |
245 if (r != KErrNone) |
220 if (r != KErrNone) |
246 { |
221 { |
247 TUSB_PRINT1("Error %d on string removal", r); |
222 TUSB_PRINT1("Error %d on string removal", r); |
248 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP01, "Error %d on string removal", r); |
|
249 } |
223 } |
250 r = iPort.RemoveStringDescriptor(stridx2); |
224 r = iPort.RemoveStringDescriptor(stridx2); |
251 if (r != KErrNone) |
225 if (r != KErrNone) |
252 { |
226 { |
253 TUSB_PRINT1("Error %d on string removal", r); |
227 TUSB_PRINT1("Error %d on string removal", r); |
254 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP02, "Error %d on string removal", r); |
|
255 } |
228 } |
256 if (iOtg) |
229 if (iOtg) |
257 { |
230 { |
258 TUSB_PRINT("Running on OTG device: unloading OTG driver"); |
231 TUSB_PRINT("Running on OTG device: unloading OTG driver"); |
259 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP03, "Running on OTG device: unloading OTG driver"); |
|
260 iOtgPort.StopStacks(); |
232 iOtgPort.StopStacks(); |
261 iOtgPort.Close(); |
233 iOtgPort.Close(); |
262 r = User::FreeLogicalDevice(RUsbOtgDriver::Name()); |
234 r = User::FreeLogicalDevice(RUsbOtgDriver::Name()); |
263 if (r != KErrNone) |
235 if (r != KErrNone) |
264 { |
236 { |
265 TUSB_PRINT1("Error %d on freeing OTG LDD", r); |
237 TUSB_PRINT1("Error %d on freeing OTG LDD", r); |
266 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP04, "Error %d on freeing OTG LDD", r); |
|
267 } |
238 } |
268 } |
239 } |
269 iPort.Close(); // close USB channel |
240 iPort.Close(); // close USB channel |
270 r = User::FreeLogicalDevice(KUsbDeviceName); |
241 r = User::FreeLogicalDevice(KUsbDeviceName); |
271 if (r != KErrNone) |
242 if (r != KErrNone) |
272 { |
243 { |
273 TUSB_PRINT1("Error %d during unloading USB LDD", r); |
244 TUSB_PRINT1("Error %d during unloading USB LDD", r); |
274 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP05, "Error %d during unloading USB LDD", r); |
|
275 User::Leave(-1); |
245 User::Leave(-1); |
276 return; |
246 return; |
277 } |
247 } |
278 TUSB_PRINT("Successfully unloaded USB LDD"); |
248 TUSB_PRINT("Successfully unloaded USB LDD"); |
279 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_DCACTIVECONSOLE_DUP06, "Successfully unloaded USB LDD"); |
|
280 } |
249 } |
281 |
250 |
282 |
251 |
283 void CActiveConsole::DoCancel() |
252 void CActiveConsole::DoCancel() |
284 { |
253 { |
285 TUSB_VERBOSE_PRINT("CActiveConsole::DoCancel()"); |
254 TUSB_VERBOSE_PRINT("CActiveConsole::DoCancel()"); |
286 if(iVerbose) |
|
287 { |
|
288 OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_DOCANCEL, "CActiveConsole::DoCancel()"); |
|
289 } |
|
290 iConsole->ReadCancel(); |
255 iConsole->ReadCancel(); |
291 } |
256 } |
292 |
257 |
293 |
258 |
294 void CActiveConsole::RunL() |
259 void CActiveConsole::RunL() |
295 { |
260 { |
296 TUSB_VERBOSE_PRINT("CActiveConsole::RunL()"); |
261 TUSB_VERBOSE_PRINT("CActiveConsole::RunL()"); |
297 if(iVerbose) |
|
298 { |
|
299 OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_RUNL, "CActiveConsole::RunL()"); |
|
300 } |
|
301 ProcessKeyPressL(static_cast<TChar>(iConsole->KeyCode())); |
262 ProcessKeyPressL(static_cast<TChar>(iConsole->KeyCode())); |
302 } |
263 } |
303 |
264 |
304 |
265 |
305 void CActiveConsole::RequestCharacter() |
266 void CActiveConsole::RequestCharacter() |
307 // A request is issued to the CConsoleBase to accept a character from the keyboard. |
268 // A request is issued to the CConsoleBase to accept a character from the keyboard. |
308 __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
269 __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
309 if (!iBufferSizeChosen) |
270 if (!iBufferSizeChosen) |
310 { |
271 { |
311 iConsole->Printf(_L("\n")); |
272 iConsole->Printf(_L("\n")); |
312 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER, "\n"); |
|
313 iConsole->Printf(_L("++++ Choose max. Transfer Size ++++\n")); |
273 iConsole->Printf(_L("++++ Choose max. Transfer Size ++++\n")); |
314 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP01, "++++ Choose max. Transfer Size ++++\n"); |
|
315 iConsole->Printf(_L(" '0' - Set up USB device for USBCV\n")); |
274 iConsole->Printf(_L(" '0' - Set up USB device for USBCV\n")); |
316 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP02, " '0' - Set up USB device for USBCV\n"); |
|
317 iConsole->Printf(_L(" '1' - 32 bytes\n")); |
275 iConsole->Printf(_L(" '1' - 32 bytes\n")); |
318 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP03, " '1' - 32 bytes\n"); |
|
319 iConsole->Printf(_L(" '2' - 1024 bytes\n")); |
276 iConsole->Printf(_L(" '2' - 1024 bytes\n")); |
320 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP04, " '2' - 1024 bytes\n"); |
|
321 iConsole->Printf(_L(" '3' - 64 kbytes\n")); |
277 iConsole->Printf(_L(" '3' - 64 kbytes\n")); |
322 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP05, " '3' - 64 kbytes\n"); |
|
323 iConsole->Printf(_L(" '4' - 1 Mbyte\n")); |
278 iConsole->Printf(_L(" '4' - 1 Mbyte\n")); |
324 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP06, " '4' - 1 Mbyte\n"); |
|
325 } |
279 } |
326 else if (!iBandwidthPriorityChosen) |
280 else if (!iBandwidthPriorityChosen) |
327 { |
281 { |
328 iConsole->Printf(_L("\n")); |
282 iConsole->Printf(_L("\n")); |
329 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP07, "\n"); |
|
330 iConsole->Printf(_L("++++ Choose Bandwidth Priority ++++\n")); |
283 iConsole->Printf(_L("++++ Choose Bandwidth Priority ++++\n")); |
331 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP08, "++++ Choose Bandwidth Priority ++++\n"); |
|
332 iConsole->Printf(_L(" '1' - Economical buffering - default\n")); |
284 iConsole->Printf(_L(" '1' - Economical buffering - default\n")); |
333 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP09, " '1' - Economical buffering - default\n"); |
|
334 iConsole->Printf(_L(" '2' - More memory than default buffering - Plus1\n")); |
285 iConsole->Printf(_L(" '2' - More memory than default buffering - Plus1\n")); |
335 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP10, " '2' - More memory than default buffering - Plus1\n"); |
|
336 iConsole->Printf(_L(" '3' - More memory than Plus1 buffering - Plus2\n")); |
286 iConsole->Printf(_L(" '3' - More memory than Plus1 buffering - Plus2\n")); |
337 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP11, " '3' - More memory than Plus1 buffering - Plus2\n"); |
|
338 iConsole->Printf(_L(" '4' - Maximum buffering\n")); |
287 iConsole->Printf(_L(" '4' - Maximum buffering\n")); |
339 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP12, " '4' - Maximum buffering\n"); |
|
340 } |
288 } |
341 else if (!iDMAChosen) |
289 else if (!iDMAChosen) |
342 { |
290 { |
343 iConsole->Printf(_L("\n")); |
291 iConsole->Printf(_L("\n")); |
344 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP13, "\n"); |
|
345 iConsole->Printf(_L("++++ Choose Endpoint I/O Transfer Mode ++++\n")); |
292 iConsole->Printf(_L("++++ Choose Endpoint I/O Transfer Mode ++++\n")); |
346 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP14, "++++ Choose Endpoint I/O Transfer Mode ++++\n"); |
|
347 iConsole->Printf(_L(" '1' - Interrupt Mode\n")); |
293 iConsole->Printf(_L(" '1' - Interrupt Mode\n")); |
348 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP15, " '1' - Interrupt Mode\n"); |
|
349 iConsole->Printf(_L(" '2' - DMA Mode (recommended)\n")); |
294 iConsole->Printf(_L(" '2' - DMA Mode (recommended)\n")); |
350 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP16, " '2' - DMA Mode (recommended\n"); |
|
351 } |
295 } |
352 else if (!iDoubleBufferingChosen) |
296 else if (!iDoubleBufferingChosen) |
353 { |
297 { |
354 iConsole->Printf(_L("\n")); |
298 iConsole->Printf(_L("\n")); |
355 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP17, "\n"); |
|
356 iConsole->Printf(_L("++++ Choose Endpoint FIFO Mode ++++\n")); |
299 iConsole->Printf(_L("++++ Choose Endpoint FIFO Mode ++++\n")); |
357 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP18, "++++ Choose Endpoint FIFO Mode ++++\n"); |
|
358 iConsole->Printf(_L(" '1' - Normal Buffering Mode\n")); |
300 iConsole->Printf(_L(" '1' - Normal Buffering Mode\n")); |
359 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP19, " '1' - Normal Buffering Mode\n"); |
|
360 iConsole->Printf(_L(" '2' - Double Buffering Mode (recommended)\n")); |
301 iConsole->Printf(_L(" '2' - Double Buffering Mode (recommended)\n")); |
361 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP20, " '2' - Double Buffering Mode (recommended\n"); |
|
362 } |
302 } |
363 else |
303 else |
364 { |
304 { |
365 iConsole->Printf(_L("\n")); |
305 iConsole->Printf(_L("\n")); |
366 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP21, "\n"); |
|
367 iConsole->Printf(_L("++++ Select Program Option ++++\n")); |
306 iConsole->Printf(_L("++++ Select Program Option ++++\n")); |
368 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP22, "++++ Select Program Option ++++\n"); |
|
369 iConsole->Printf(_L(" 'L'oop test\n")); |
307 iConsole->Printf(_L(" 'L'oop test\n")); |
370 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP23, " 'L'oop test\n"); |
|
371 iConsole->Printf(_L(" Loop test with data 'C'ompare\n")); |
308 iConsole->Printf(_L(" Loop test with data 'C'ompare\n")); |
372 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP24, " Loop test with data 'C'ompare\n"); |
|
373 iConsole->Printf(_L(" 'R'eceive-only test (we receive, host transmits)\n")); |
309 iConsole->Printf(_L(" 'R'eceive-only test (we receive, host transmits)\n")); |
374 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP25, " 'R'eceive-only test (we receive, host transmits\n"); |
|
375 iConsole->Printf(_L(" 'T'ransmit-only test\n")); |
310 iConsole->Printf(_L(" 'T'ransmit-only test\n")); |
376 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP26, " 'T'ransmit-only test\n"); |
|
377 iConsole->Printf(_L(" Receive and 'P'ut (write) to File\n")); |
311 iConsole->Printf(_L(" Receive and 'P'ut (write) to File\n")); |
378 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP27, " Receive and 'P'ut (writeto File\n"); |
|
379 iConsole->Printf(_L(" Transmit and 'G'et (read) from File\n")); |
312 iConsole->Printf(_L(" Transmit and 'G'et (read) from File\n")); |
380 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP28, " Transmit and 'G'et (readfrom File\n"); |
|
381 iConsole->Printf(_L(" Signal Remote-'W'akeup to the host\n")); |
313 iConsole->Printf(_L(" Signal Remote-'W'akeup to the host\n")); |
382 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP29, " Signal Remote-'W'akeup to the host\n"); |
|
383 iConsole->Printf(_L(" 'S'top current transfer\n")); |
314 iConsole->Printf(_L(" 'S'top current transfer\n")); |
384 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP30, " 'S'top current transfer\n"); |
|
385 #ifdef WITH_DUMP_OPTION |
315 #ifdef WITH_DUMP_OPTION |
386 iConsole->Printf(_L(" 'D'ump USB regs to debugout\n")); |
316 iConsole->Printf(_L(" 'D'ump USB regs to debugout\n")); |
387 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP31, " 'D'ump USB regs to debugout\n"); |
|
388 #endif |
317 #endif |
389 iConsole->Printf(_L(" Re'E'numerate device\n")); |
318 iConsole->Printf(_L(" Re'E'numerate device\n")); |
390 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP32, " Re'E'numerate device\n"); |
|
391 iConsole->Printf(_L(" 'Q'uit this app\n")); |
319 iConsole->Printf(_L(" 'Q'uit this app\n")); |
392 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REQUESTCHARACTER_DUP33, " 'Q'uit this app\n"); |
|
393 } |
320 } |
394 iConsole->Read(iStatus); |
321 iConsole->Read(iStatus); |
395 SetActive(); |
322 SetActive(); |
396 } |
323 } |
397 |
324 |
398 |
325 |
399 void CActiveConsole::ProcessKeyPressL(TChar aChar) |
326 void CActiveConsole::ProcessKeyPressL(TChar aChar) |
400 { |
327 { |
401 if (aChar == EKeyEscape) |
328 if (aChar == EKeyEscape) |
402 { |
329 { |
403 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL, "CActiveConsole: ESC key pressed -> stopping active scheduler..."); |
330 RDebug::Print(_L("CActiveConsole: ESC key pressed -> stopping active scheduler...")); |
404 CActiveScheduler::Stop(); |
331 CActiveScheduler::Stop(); |
405 return; |
332 return; |
406 } |
333 } |
407 if (!iBufferSizeChosen) |
334 if (!iBufferSizeChosen) |
408 { |
335 { |
426 case '4': |
353 case '4': |
427 iRW->SetMaxBufSize(KMaxBufSize); |
354 iRW->SetMaxBufSize(KMaxBufSize); |
428 break; |
355 break; |
429 default: |
356 default: |
430 TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
357 TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
431 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP01, "Not a valid input character: %c", aChar.operator TUint()); |
|
432 goto request_char; |
358 goto request_char; |
433 } |
359 } |
434 TUSB_PRINT1("Maximum buffer size set to %d bytes", iRW->MaxBufSize()); |
360 TUSB_PRINT1("Maximum buffer size set to %d bytes", iRW->MaxBufSize()); |
435 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP02, "Maximum buffer size set to %d bytes", iRW->MaxBufSize()); |
|
436 iBufferSizeChosen = ETrue; |
361 iBufferSizeChosen = ETrue; |
437 } |
362 } |
438 else if (!iBandwidthPriorityChosen) |
363 else if (!iBandwidthPriorityChosen) |
439 { |
364 { |
440 // Set bandwidth priority from keypress |
365 // Set bandwidth priority from keypress |
441 switch (aChar) |
366 switch (aChar) |
442 { |
367 { |
443 case '1': |
368 case '1': |
444 iBandwidthPriority = EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault; |
369 iBandwidthPriority = EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault; |
445 TUSB_PRINT("Bandwith priority set to default"); |
370 TUSB_PRINT("Bandwith priority set to default"); |
446 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP03, "Bandwith priority set to default"); |
|
447 break; |
371 break; |
448 case '2': |
372 case '2': |
449 iBandwidthPriority = EUsbcBandwidthOUTPlus1 | EUsbcBandwidthINPlus1; |
373 iBandwidthPriority = EUsbcBandwidthOUTPlus1 | EUsbcBandwidthINPlus1; |
450 TUSB_PRINT("Bandwith priority set to Plus1"); |
374 TUSB_PRINT("Bandwith priority set to Plus1"); |
451 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP04, "Bandwith priority set to Plus1"); |
|
452 break; |
375 break; |
453 case '3': |
376 case '3': |
454 iBandwidthPriority = EUsbcBandwidthOUTPlus2 | EUsbcBandwidthINPlus2; |
377 iBandwidthPriority = EUsbcBandwidthOUTPlus2 | EUsbcBandwidthINPlus2; |
455 TUSB_PRINT("Bandwith priority set to Plus2"); |
378 TUSB_PRINT("Bandwith priority set to Plus2"); |
456 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP05, "Bandwith priority set to Plus2"); |
|
457 break; |
379 break; |
458 case '4': |
380 case '4': |
459 iBandwidthPriority = EUsbcBandwidthINMaximum | EUsbcBandwidthOUTMaximum; |
381 iBandwidthPriority = EUsbcBandwidthINMaximum | EUsbcBandwidthOUTMaximum; |
460 TUSB_PRINT("Bandwith priority set to maximum"); |
382 TUSB_PRINT("Bandwith priority set to maximum"); |
461 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP06, "Bandwith priority set to maximum"); |
|
462 break; |
383 break; |
463 default: |
384 default: |
464 TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
385 TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
465 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP07, "Not a valid input character: %c", aChar.operator TUint()); |
|
466 goto request_char; |
386 goto request_char; |
467 } |
387 } |
468 TUSB_PRINT1("(Set to 0x%08X)", iBandwidthPriority); |
388 TUSB_PRINT1("(Set to 0x%08X)", iBandwidthPriority); |
469 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP08, "(Set to 0x%08X)", iBandwidthPriority); |
|
470 iBandwidthPriorityChosen = ETrue; |
389 iBandwidthPriorityChosen = ETrue; |
471 |
390 |
472 if (!iResourceAllocationV2) |
391 if (!iResourceAllocationV2) |
473 { |
392 { |
474 TUSB_PRINT("Configuring interface..."); |
393 TUSB_PRINT("Configuring interface..."); |
475 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP09, "Configuring interface..."); |
|
476 TInt r = SetupInterface(); |
394 TInt r = SetupInterface(); |
477 if (r != KErrNone) |
395 if (r != KErrNone) |
478 { |
396 { |
479 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
397 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
480 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP10, "Error: %d. Stopping active scheduler...", r); |
|
481 CActiveScheduler::Stop(); |
398 CActiveScheduler::Stop(); |
482 return; |
399 return; |
483 } |
400 } |
484 } |
401 } |
485 } |
402 } |
537 break; |
450 break; |
538 } |
451 } |
539 case '2': |
452 case '2': |
540 { |
453 { |
541 TUSB_PRINT("- Trying to allocate Double Buffering:\n"); |
454 TUSB_PRINT("- Trying to allocate Double Buffering:\n"); |
542 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP15, "- Trying to allocate Double Buffering:\n"); |
|
543 if (!iResourceAllocationV2) |
455 if (!iResourceAllocationV2) |
544 { |
456 { |
545 AllocateDoubleBuffering(EEndpoint1); |
457 AllocateDoubleBuffering(EEndpoint1); |
546 AllocateDoubleBuffering(EEndpoint2); |
458 AllocateDoubleBuffering(EEndpoint2); |
547 } |
459 } |
548 iAllocateDoubleBuffering = ETrue; |
460 iAllocateDoubleBuffering = ETrue; |
549 break; |
461 break; |
550 } |
462 } |
551 default: |
463 default: |
552 TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
464 TUSB_PRINT1("Not a valid input character: %c", aChar.operator TUint()); |
553 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP16, "Not a valid input character: %c", aChar.operator TUint()); |
|
554 goto request_char; |
465 goto request_char; |
555 } |
466 } |
556 iDoubleBufferingChosen = ETrue; |
467 iDoubleBufferingChosen = ETrue; |
557 |
468 |
558 if (iResourceAllocationV2) |
469 if (iResourceAllocationV2) |
559 { |
470 { |
560 TUSB_PRINT("Configuring interface..."); |
471 TUSB_PRINT("Configuring interface..."); |
561 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP17, "Configuring interface..."); |
|
562 TInt r = SetupInterface(); |
472 TInt r = SetupInterface(); |
563 if (r != KErrNone) |
473 if (r != KErrNone) |
564 { |
474 { |
565 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
475 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
566 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP18, "Error: %d. Stopping active scheduler...", r); |
|
567 CActiveScheduler::Stop(); |
476 CActiveScheduler::Stop(); |
568 return; |
477 return; |
569 } |
478 } |
570 } |
479 } |
571 |
480 |
572 // Everything chosen, so let's re-enumerate... |
481 // Everything chosen, so let's re-enumerate... |
573 TUSB_PRINT("Enumeration..."); |
482 TUSB_PRINT("Enumeration..."); |
574 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP19, "Enumeration..."); |
|
575 TInt r = ReEnumerate(); |
483 TInt r = ReEnumerate(); |
576 if (r != KErrNone) |
484 if (r != KErrNone) |
577 { |
485 { |
578 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
486 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
579 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP20, "Error: %d. Stopping active scheduler...", r); |
|
580 CActiveScheduler::Stop(); |
487 CActiveScheduler::Stop(); |
581 return; |
488 return; |
582 } |
489 } |
583 TUSB_PRINT("Device successfully re-enumerated\n"); |
490 TUSB_PRINT("Device successfully re-enumerated\n"); |
584 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP21, "Device successfully re-enumerated\n"); |
|
585 |
491 |
586 // Make sure program versions match if testing against USBRFLCT |
492 // Make sure program versions match if testing against USBRFLCT |
587 if (iRW->MaxBufSize() != 0) |
493 if (iRW->MaxBufSize() != 0) |
588 { |
494 { |
589 r = iRW->ExchangeVersions(); |
495 r = iRW->ExchangeVersions(); |
590 if (r != KErrNone) |
496 if (r != KErrNone) |
591 { |
497 { |
592 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
498 TUSB_PRINT1("Error: %d. Stopping active scheduler...", r); |
593 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP22, "Error: %d. Stopping active scheduler...", r); |
|
594 CActiveScheduler::Stop(); |
499 CActiveScheduler::Stop(); |
595 return; |
500 return; |
596 } |
501 } |
597 } |
502 } |
598 } |
503 } |
602 switch (aChar) |
507 switch (aChar) |
603 { |
508 { |
604 case 'l': // start loop test |
509 case 'l': // start loop test |
605 case 'L': |
510 case 'L': |
606 TUSB_PRINT("-> Loop test selected\n"); |
511 TUSB_PRINT("-> Loop test selected\n"); |
607 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP23, "-> Loop test selected\n"); |
|
608 iRW->SetTransferMode(ELoop); |
512 iRW->SetTransferMode(ELoop); |
609 iRW->SendPreamble(); |
513 iRW->SendPreamble(); |
610 break; |
514 break; |
611 case 'c': // start loop/compare test |
515 case 'c': // start loop/compare test |
612 case 'C': |
516 case 'C': |
613 TUSB_PRINT("-> Loop test with compare selected\n"); |
517 TUSB_PRINT("-> Loop test with compare selected\n"); |
614 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP24, "-> Loop test with compare selected\n"); |
|
615 iRW->SetTransferMode(ELoopComp); |
518 iRW->SetTransferMode(ELoopComp); |
616 iRW->SendPreamble(); |
519 iRW->SendPreamble(); |
617 break; |
520 break; |
618 case 'r': // start receive-only test |
521 case 'r': // start receive-only test |
619 case 'R': |
522 case 'R': |
620 TUSB_PRINT("-> Receive-only test selected\n"); |
523 TUSB_PRINT("-> Receive-only test selected\n"); |
621 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP25, "-> Receive-only test selected\n"); |
|
622 iRW->SetTransferMode(EReceiveOnly); |
524 iRW->SetTransferMode(EReceiveOnly); |
623 iRW->SendPreamble(); |
525 iRW->SendPreamble(); |
624 break; |
526 break; |
625 case 't': // start transmit-only test |
527 case 't': // start transmit-only test |
626 case 'T': |
528 case 'T': |
627 TUSB_PRINT("-> Transmit-only test selected\n"); |
529 TUSB_PRINT("-> Transmit-only test selected\n"); |
628 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP26, "-> Transmit-only test selected\n"); |
|
629 iRW->SetTransferMode(ETransmitOnly); |
530 iRW->SetTransferMode(ETransmitOnly); |
630 iRW->SendPreamble(); |
531 iRW->SendPreamble(); |
631 break; |
532 break; |
632 case 'g': // start transmit & get-from-file test |
533 case 'g': // start transmit & get-from-file test |
633 case 'G': |
534 case 'G': |
634 TUSB_PRINT("-> Transmit from file test selected\n"); |
535 TUSB_PRINT("-> Transmit from file test selected\n"); |
635 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP27, "-> Transmit from file test selected\n"); |
|
636 iRW->SetTransferMode(ETransmitOnly); |
536 iRW->SetTransferMode(ETransmitOnly); |
637 iRW->ReadFromDisk(ETrue); |
537 iRW->ReadFromDisk(ETrue); |
638 iRW->SendPreamble(); |
538 iRW->SendPreamble(); |
639 break; |
539 break; |
640 case 'p': // start receive & put-to-file test |
540 case 'p': // start receive & put-to-file test |
641 case 'P': |
541 case 'P': |
642 TUSB_PRINT("-> Receive to file test selected\n"); |
542 TUSB_PRINT("-> Receive to file test selected\n"); |
643 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP28, "-> Receive to file test selected\n"); |
|
644 iRW->SetTransferMode(EReceiveOnly); |
543 iRW->SetTransferMode(EReceiveOnly); |
645 iRW->WriteToDisk(ETrue); |
544 iRW->WriteToDisk(ETrue); |
646 iRW->SendPreamble(); |
545 iRW->SendPreamble(); |
647 break; |
546 break; |
648 case 'w': // remote-wakeup |
547 case 'w': // remote-wakeup |
649 case 'W': |
548 case 'W': |
650 TUSB_PRINT("-> Signal Remote-wakeup selected\n"); |
549 TUSB_PRINT("-> Signal Remote-wakeup selected\n"); |
651 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP29, "-> Signal Remote-wakeup selected\n"); |
|
652 iPort.SignalRemoteWakeup(); |
550 iPort.SignalRemoteWakeup(); |
653 break; |
551 break; |
654 case 's': // stop either |
552 case 's': // stop either |
655 case 'S': |
553 case 'S': |
656 TUSB_PRINT("-> Stop transfer selected\n"); |
554 TUSB_PRINT("-> Stop transfer selected\n"); |
657 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP30, "-> Stop transfer selected\n"); |
|
658 iRW->Stop(); |
555 iRW->Stop(); |
659 break; |
556 break; |
660 #ifdef WITH_DUMP_OPTION |
557 #ifdef WITH_DUMP_OPTION |
661 case 'd': // dump controller registers |
558 case 'd': // dump controller registers |
662 case 'D': |
559 case 'D': |
663 TUSB_PRINT("-> Dump option selected\n"); |
560 TUSB_PRINT("-> Dump option selected\n"); |
664 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP31, "-> Dump option selected\n"); |
|
665 iPort.DumpRegisters(); |
561 iPort.DumpRegisters(); |
666 QueryRxBuffer(); |
562 QueryRxBuffer(); |
667 break; |
563 break; |
668 #endif |
564 #endif |
669 case 'e': // ReEnumerate() |
565 case 'e': // ReEnumerate() |
670 case 'E': |
566 case 'E': |
671 TUSB_PRINT("-> Re-enumerate device selected\n"); |
567 TUSB_PRINT("-> Re-enumerate device selected\n"); |
672 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP32, "-> Re-enumerate device selected\n"); |
|
673 ReEnumerate(); |
568 ReEnumerate(); |
674 break; |
569 break; |
675 case 'q': // quit |
570 case 'q': // quit |
676 case 'Q': |
571 case 'Q': |
677 TUSB_PRINT("-> Quit program selected\n"); |
572 TUSB_PRINT("-> Quit program selected\n"); |
678 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP33, "-> Quit program selected\n"); |
|
679 TUSB_VERBOSE_PRINT("CActiveConsole: stopping active scheduler..."); |
573 TUSB_VERBOSE_PRINT("CActiveConsole: stopping active scheduler..."); |
680 if(iVerbose) |
|
681 { |
|
682 OstTrace0(TRACE_VERBOSE, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP34, "CActiveConsole: stopping active scheduler..."); |
|
683 } |
|
684 CActiveScheduler::Stop(); |
574 CActiveScheduler::Stop(); |
685 return; |
575 return; |
686 default: |
576 default: |
687 TUSB_PRINT1("-> Not a valid input character: %c", aChar.operator TUint()); |
577 TUSB_PRINT1("-> Not a valid input character: %c", aChar.operator TUint()); |
688 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_PROCESSKEYPRESSL_DUP35, "-> Not a valid input character: %c", aChar.operator TUint()); |
|
689 goto request_char; |
578 goto request_char; |
690 } |
579 } |
691 } |
580 } |
692 request_char: |
581 request_char: |
693 RequestCharacter(); |
582 RequestCharacter(); |
746 TUsbDeviceCaps d_caps; |
635 TUsbDeviceCaps d_caps; |
747 TInt r = iPort.DeviceCaps(d_caps); |
636 TInt r = iPort.DeviceCaps(d_caps); |
748 if (r != KErrNone) |
637 if (r != KErrNone) |
749 { |
638 { |
750 TUSB_PRINT1("Error %d on querying device capabilities", r); |
639 TUSB_PRINT1("Error %d on querying device capabilities", r); |
751 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL, "Error %d on querying device capabilities", r); |
|
752 return KErrGeneral; |
640 return KErrGeneral; |
753 } |
641 } |
754 const TInt n = d_caps().iTotalEndpoints; |
642 const TInt n = d_caps().iTotalEndpoints; |
755 |
643 |
756 TUSB_PRINT("### USB device capabilities:"); |
644 TUSB_PRINT("### USB device capabilities:"); |
757 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP01, "### USB device capabilities:"); |
|
758 TUSB_PRINT1("Number of endpoints: %d", n); |
645 TUSB_PRINT1("Number of endpoints: %d", n); |
759 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP02, "Number of endpoints: %d", n); |
|
760 TUSB_PRINT1("Supports Software-Connect: %s", |
646 TUSB_PRINT1("Supports Software-Connect: %s", |
761 d_caps().iConnect ? _S("yes") : _S("no")); |
647 d_caps().iConnect ? _S("yes") : _S("no")); |
762 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP03, "Supports Software-Connect: %s", |
|
763 d_caps().iConnect ? _L("yes") : _L("no")); |
|
764 TUSB_PRINT1("Device is Self-Powered: %s", |
648 TUSB_PRINT1("Device is Self-Powered: %s", |
765 d_caps().iSelfPowered ? _S("yes") : _S("no")); |
649 d_caps().iSelfPowered ? _S("yes") : _S("no")); |
766 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP04, "Device is Self-Powered: %s", |
|
767 d_caps().iSelfPowered ? _L("yes") : _L("no")); |
|
768 TUSB_PRINT1("Supports Remote-Wakeup: %s", |
650 TUSB_PRINT1("Supports Remote-Wakeup: %s", |
769 d_caps().iRemoteWakeup ? _S("yes") : _S("no")); |
651 d_caps().iRemoteWakeup ? _S("yes") : _S("no")); |
770 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP05, "Supports Remote-Wakeup: %s", |
|
771 d_caps().iRemoteWakeup ? _L("yes") : _L("no")); |
|
772 TUSB_PRINT1("Supports High-speed: %s", |
652 TUSB_PRINT1("Supports High-speed: %s", |
773 d_caps().iHighSpeed ? _S("yes") : _S("no")); |
653 d_caps().iHighSpeed ? _S("yes") : _S("no")); |
774 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP06, "Supports High-speed: %s", |
|
775 d_caps().iHighSpeed ? _L("yes") : _L("no")); |
|
776 TUSB_PRINT1("Supports OTG: %s", |
654 TUSB_PRINT1("Supports OTG: %s", |
777 iOtg ? _S("yes") : _S("no")); |
655 iOtg ? _S("yes") : _S("no")); |
778 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP07, "Supports OTG: %s", |
|
779 iOtg ? _L("yes") : _L("no")); |
|
780 TUSB_PRINT1("Supports unpowered cable detection: %s", |
656 TUSB_PRINT1("Supports unpowered cable detection: %s", |
781 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
657 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
782 _S("yes") : _S("no")); |
658 _S("yes") : _S("no")); |
783 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP08, "Supports unpowered cable detection: %s", |
|
784 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
|
785 _L("yes") : _L("no")); |
|
786 TUSB_PRINT1("Supports endpoint resource alloc scheme V2: %s\n", |
659 TUSB_PRINT1("Supports endpoint resource alloc scheme V2: %s\n", |
787 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ? |
660 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ? |
788 _S("yes") : _S("no")); |
661 _S("yes") : _S("no")); |
789 OstTraceExt1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP09, "Supports endpoint resource alloc scheme V2: %s\n", |
|
790 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ? |
|
791 _L("yes") : _L("no")); |
|
792 TUSB_PRINT(""); |
662 TUSB_PRINT(""); |
793 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP10, ""); |
|
794 |
663 |
795 iSoftwareConnect = d_caps().iConnect; // we need to remember this |
664 iSoftwareConnect = d_caps().iConnect; // we need to remember this |
796 |
665 |
797 if (n < 2) |
666 if (n < 2) |
798 { |
667 { |
799 TUSB_PRINT1("Error: only %d endpoints available on device", n); |
668 TUSB_PRINT1("Error: only %d endpoints available on device", n); |
800 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP11, "Error: only %d endpoints available on device", n); |
|
801 return KErrGeneral; |
669 return KErrGeneral; |
802 } |
670 } |
803 |
671 |
804 // Endpoints |
672 // Endpoints |
805 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
673 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
806 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
674 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
807 r = iPort.EndpointCaps(dataptr); |
675 r = iPort.EndpointCaps(dataptr); |
808 if (r != KErrNone) |
676 if (r != KErrNone) |
809 { |
677 { |
810 TUSB_PRINT1("Error %d on querying endpoint capabilities", r); |
678 TUSB_PRINT1("Error %d on querying endpoint capabilities", r); |
811 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP12, "Error %d on querying endpoint capabilities", r); |
|
812 return KErrGeneral; |
679 return KErrGeneral; |
813 } |
680 } |
814 TUSB_PRINT("### USB device endpoint capabilities:"); |
681 TUSB_PRINT("### USB device endpoint capabilities:"); |
815 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP13, "### USB device endpoint capabilities:"); |
|
816 for (TInt i = 0; i < n; i++) |
682 for (TInt i = 0; i < n; i++) |
817 { |
683 { |
818 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
684 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
819 TUSB_PRINT2("Endpoint: SizeMask = 0x%08x TypeDirMask = 0x%08x", |
685 TUSB_PRINT2("Endpoint: SizeMask = 0x%08x TypeDirMask = 0x%08x", |
820 caps->iSizes, caps->iTypesAndDir); |
686 caps->iSizes, caps->iTypesAndDir); |
821 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP14, "Endpoint: SizeMask = 0x%08x TypeDirMask = 0x%08x", |
|
822 caps->iSizes, caps->iTypesAndDir); |
|
823 } |
687 } |
824 TUSB_PRINT(""); |
688 TUSB_PRINT(""); |
825 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP15, ""); |
|
826 |
689 |
827 // Set up the active interface |
690 // Set up the active interface |
828 TUsbcInterfaceInfoBuf ifc; |
691 TUsbcInterfaceInfoBuf ifc; |
829 TInt ep_found = 0; |
692 TInt ep_found = 0; |
830 TBool foundBulkIN = EFalse; |
693 TBool foundBulkIN = EFalse; |
991 ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease; |
848 ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease; |
992 r = iPort.SetInterface(1, ifc); |
849 r = iPort.SetInterface(1, ifc); |
993 if (r != KErrNone) |
850 if (r != KErrNone) |
994 { |
851 { |
995 TUSB_PRINT1("Error %d on setting alternate interface", r); |
852 TUSB_PRINT1("Error %d on setting alternate interface", r); |
996 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_QUERYUSBCLIENTL_DUP22, "Error %d on setting alternate interface", r); |
|
997 } |
853 } |
998 |
854 |
999 return r; |
855 return r; |
1000 } |
856 } |
1001 |
857 |
1002 |
858 |
1003 void CActiveConsole::AllocateEndpointDMA(TEndpointNumber aEndpoint) |
859 void CActiveConsole::AllocateEndpointDMA(TEndpointNumber aEndpoint) |
1004 { |
860 { |
1005 TInt r = iPort.AllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDMA); |
861 TInt r = iPort.AllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDMA); |
1006 if (r == KErrNone) |
862 if (r == KErrNone) |
1007 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA, "DMA allocation on endpoint %d: KErrNone", aEndpoint); |
863 RDebug::Print(_L("DMA allocation on endpoint %d: KErrNone"), aEndpoint); |
1008 else if (r == KErrInUse) |
864 else if (r == KErrInUse) |
1009 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP01, "DMA allocation on endpoint %d: KErrInUse", aEndpoint); |
865 RDebug::Print(_L("DMA allocation on endpoint %d: KErrInUse"), aEndpoint); |
1010 else if (r == KErrNotSupported) |
866 else if (r == KErrNotSupported) |
1011 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP02, "DMA allocation on endpoint %d: KErrNotSupported", aEndpoint); |
867 RDebug::Print(_L("DMA allocation on endpoint %d: KErrNotSupported"), aEndpoint); |
1012 else |
868 else |
1013 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP03, "DMA allocation on endpoint %d: unexpected return value %d", |
869 RDebug::Print(_L("DMA allocation on endpoint %d: unexpected return value %d"), |
1014 aEndpoint, r); |
870 aEndpoint, r); |
1015 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDMA); |
871 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDMA); |
1016 TUSB_PRINT2("DMA on endpoint %d %s\n", |
872 TUSB_PRINT2("DMA on endpoint %d %s\n", |
1017 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
873 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
1018 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP04, "DMA on endpoint %d %s\n", |
|
1019 aEndpoint, res ? _L("allocated") : _L("not allocated")); |
|
1020 |
874 |
1021 if ((r == KErrNone) && !res) |
875 if ((r == KErrNone) && !res) |
1022 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP05, "(Allocation success but negative query result: contradiction!)\n"); |
876 RDebug::Print(_L("(Allocation success but negative query result: contradiction!)\n")); |
1023 else if ((r != KErrNone) && res) |
877 else if ((r != KErrNone) && res) |
1024 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEENDPOINTDMA_DUP06, "(Allocation failure but positive query result: contradiction!)\n"); |
878 RDebug::Print(_L("(Allocation failure but positive query result: contradiction!)\n")); |
1025 } |
879 } |
1026 |
880 |
1027 |
881 |
1028 void CActiveConsole::DeAllocateEndpointDMA(TEndpointNumber aEndpoint) |
882 void CActiveConsole::DeAllocateEndpointDMA(TEndpointNumber aEndpoint) |
1029 { |
883 { |
1030 TInt r = iPort.DeAllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDMA); |
884 TInt r = iPort.DeAllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDMA); |
1031 if (r == KErrNone) |
885 if (r == KErrNone) |
1032 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA, "DMA deallocation on endpoint %d: KErrNone", aEndpoint); |
886 RDebug::Print(_L("DMA deallocation on endpoint %d: KErrNone"), aEndpoint); |
1033 else if (r == KErrNotSupported) |
887 else if (r == KErrNotSupported) |
1034 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA_DUP01, "DMA deallocation on endpoint %d: KErrNotSupported", aEndpoint); |
888 RDebug::Print(_L("DMA deallocation on endpoint %d: KErrNotSupported"), aEndpoint); |
1035 else |
889 else |
1036 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA_DUP02, "DMA deallocation on endpoint %d: unexpected return value %d", |
890 RDebug::Print(_L("DMA deallocation on endpoint %d: unexpected return value %d"), |
1037 aEndpoint, r); |
891 aEndpoint, r); |
1038 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDMA); |
892 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDMA); |
1039 TUSB_PRINT2("DMA on endpoint %d %s\n", |
893 TUSB_PRINT2("DMA on endpoint %d %s\n", |
1040 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
894 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
1041 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEENDPOINTDMA_DUP03, "DMA on endpoint %d %s\n", |
|
1042 aEndpoint, res ? _L("allocated") : _L("not allocated")); |
|
1043 } |
895 } |
1044 |
896 |
1045 |
897 |
1046 void CActiveConsole::AllocateDoubleBuffering(TEndpointNumber aEndpoint) |
898 void CActiveConsole::AllocateDoubleBuffering(TEndpointNumber aEndpoint) |
1047 { |
899 { |
1048 TInt r = iPort.AllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
900 TInt r = iPort.AllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
1049 if (r == KErrNone) |
901 if (r == KErrNone) |
1050 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING, "Double Buffering allocation on endpoint %d: KErrNone", aEndpoint); |
902 RDebug::Print(_L("Double Buffering allocation on endpoint %d: KErrNone"), aEndpoint); |
1051 else if (r == KErrInUse) |
903 else if (r == KErrInUse) |
1052 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP01, "Double Buffering allocation on endpoint %d: KErrInUse", aEndpoint); |
904 RDebug::Print(_L("Double Buffering allocation on endpoint %d: KErrInUse"), aEndpoint); |
1053 else if (r == KErrNotSupported) |
905 else if (r == KErrNotSupported) |
1054 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP02, "Double Buffering allocation on endpoint %d: KErrNotSupported", aEndpoint); |
906 RDebug::Print(_L("Double Buffering allocation on endpoint %d: KErrNotSupported"), aEndpoint); |
1055 else |
907 else |
1056 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP03, "Double Buffering allocation on endpoint %d: unexpected return value %d", |
908 RDebug::Print(_L("Double Buffering allocation on endpoint %d: unexpected return value %d"), |
1057 aEndpoint, r); |
909 aEndpoint, r); |
1058 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
910 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
1059 TUSB_PRINT2("Double Buffering on endpoint %d %s\n", |
911 TUSB_PRINT2("Double Buffering on endpoint %d %s\n", |
1060 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
912 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
1061 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP04, "Double Buffering on endpoint %d %s\n", |
|
1062 aEndpoint, res ? _L("allocated") : _L("not allocated")); |
|
1063 |
913 |
1064 if ((r == KErrNone) && !res) |
914 if ((r == KErrNone) && !res) |
1065 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP05, "(Allocation success but negative query result: contradiction!)\n"); |
915 RDebug::Print(_L("(Allocation success but negative query result: contradiction!)\n")); |
1066 else if ((r != KErrNone) && res) |
916 else if ((r != KErrNone) && res) |
1067 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_ALLOCATEDOUBLEBUFFERING_DUP06, "(Allocation failure but positive query result: contradiction!)\n"); |
917 RDebug::Print(_L("(Allocation failure but positive query result: contradiction!)\n")); |
1068 } |
918 } |
1069 |
919 |
1070 |
920 |
1071 void CActiveConsole::DeAllocateDoubleBuffering(TEndpointNumber aEndpoint) |
921 void CActiveConsole::DeAllocateDoubleBuffering(TEndpointNumber aEndpoint) |
1072 { |
922 { |
1073 TInt r = iPort.DeAllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
923 TInt r = iPort.DeAllocateEndpointResource(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
1074 if (r == KErrNone) |
924 if (r == KErrNone) |
1075 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING, "Double Buffering deallocation on endpoint %d: KErrNone", aEndpoint); |
925 RDebug::Print(_L("Double Buffering deallocation on endpoint %d: KErrNone"), aEndpoint); |
1076 else if (r == KErrNotSupported) |
926 else if (r == KErrNotSupported) |
1077 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING_DUP01, "Double Buffering deallocation on endpoint %d: KErrNotSupported", aEndpoint); |
927 RDebug::Print(_L("Double Buffering deallocation on endpoint %d: KErrNotSupported"), aEndpoint); |
1078 else |
928 else |
1079 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING_DUP02, "Double Buffering deallocation on endpoint %d: unexpected return value %d", |
929 RDebug::Print(_L("Double Buffering deallocation on endpoint %d: unexpected return value %d"), |
1080 aEndpoint, r); |
930 aEndpoint, r); |
1081 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
931 TBool res = iPort.QueryEndpointResourceUse(aEndpoint, EUsbcEndpointResourceDoubleBuffering); |
1082 TUSB_PRINT2("Double Buffering on endpoint %d %s\n", |
932 TUSB_PRINT2("Double Buffering on endpoint %d %s\n", |
1083 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
933 aEndpoint, res ? _S("allocated") : _S("not allocated")); |
1084 OstTraceExt2(TRACE_NORMAL, CACTIVECONSOLE_DEALLOCATEDOUBLEBUFFERING_DUP03, "Double Buffering on endpoint %d %s\n", |
|
1085 aEndpoint, res ? _L("allocated") : _L("not allocated")); |
|
1086 } |
934 } |
1087 |
935 |
1088 |
936 |
1089 TInt CActiveConsole::ReEnumerate() |
937 TInt CActiveConsole::ReEnumerate() |
1090 { |
938 { |
1091 TRequestStatus enum_status; |
939 TRequestStatus enum_status; |
1092 iPort.ReEnumerate(enum_status); |
940 iPort.ReEnumerate(enum_status); |
1093 if (!iSoftwareConnect) |
941 if (!iSoftwareConnect) |
1094 { |
942 { |
1095 iConsole->Printf(_L("This device does not support software\n")); |
943 iConsole->Printf(_L("This device does not support software\n")); |
1096 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE, "This device does not support software\n"); |
|
1097 iConsole->Printf(_L("disconnect/reconnect\n")); |
944 iConsole->Printf(_L("disconnect/reconnect\n")); |
1098 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP01, "disconnect/reconnect\n"); |
|
1099 iConsole->Printf(_L("Please physically unplug and replug\n")); |
945 iConsole->Printf(_L("Please physically unplug and replug\n")); |
1100 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP02, "Please physically unplug and replug\n"); |
|
1101 iConsole->Printf(_L("the USB cable NOW... ")); |
946 iConsole->Printf(_L("the USB cable NOW... ")); |
1102 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP03, "the USB cable NOW... "); |
|
1103 } |
947 } |
1104 iConsole->Printf(_L("\n>>> START THE USBRFLCT PROGRAM ON THE HOST SIDE NOW <<<\n")); |
948 iConsole->Printf(_L("\n>>> START THE USBRFLCT PROGRAM ON THE HOST SIDE NOW <<<\n")); |
1105 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP04, "\n>>> START THE USBRFLCT PROGRAM ON THE HOST SIDE NOW <<<\n"); |
|
1106 User::WaitForRequest(enum_status); |
949 User::WaitForRequest(enum_status); |
1107 if (enum_status != KErrNone) |
950 if (enum_status != KErrNone) |
1108 { |
951 { |
1109 TUSB_PRINT1("Error: Re-enumeration status = %d", enum_status.Int()); |
952 TUSB_PRINT1("Error: Re-enumeration status = %d", enum_status.Int()); |
1110 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP05, "Error: Re-enumeration status = %d", enum_status.Int()); |
|
1111 return KErrGeneral; |
953 return KErrGeneral; |
1112 } |
954 } |
1113 TUsbcDeviceState device_state = EUsbcDeviceStateUndefined; |
955 TUsbcDeviceState device_state = EUsbcDeviceStateUndefined; |
1114 TInt r = iPort.DeviceStatus(device_state); |
956 TInt r = iPort.DeviceStatus(device_state); |
1115 if (r != KErrNone) |
957 if (r != KErrNone) |
1116 { |
958 { |
1117 TUSB_PRINT1("Error %d on querying device state", r); |
959 TUSB_PRINT1("Error %d on querying device state", r); |
1118 OstTrace1(TRACE_NORMAL, CACTIVECONSOLE_REENUMERATE_DUP06, "Error %d on querying device state", r); |
|
1119 } |
960 } |
1120 else |
961 else |
1121 { |
962 { |
1122 TUSB_PRINT1("Current device state: %s", |
963 TUSB_PRINT1("Current device state: %s", |
1123 (device_state == EUsbcDeviceStateUndefined) ? _S("Undefined") : |
964 (device_state == EUsbcDeviceStateUndefined) ? _S("Undefined") : |
1416 { |
1220 { |
1417 const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
1221 const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
1418 if (num != ++iPktNum) |
1222 if (num != ++iPktNum) |
1419 { |
1223 { |
1420 TUSB_PRINT2("*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
1224 TUSB_PRINT2("*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
1421 OstTraceExt2(TRACE_NORMAL, CACTIVERW_RUNL_DUP03, "*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
|
1422 // Update the packet number with the received number, so that |
1225 // Update the packet number with the received number, so that |
1423 // if a single packet is duplicated or lost then a single error occurs |
1226 // if a single packet is duplicated or lost then a single error occurs |
1424 iPktNum = num; |
1227 iPktNum = num; |
1425 } |
1228 } |
1426 if (iDiskAccessEnabled) |
1229 if (iDiskAccessEnabled) |
1427 { |
1230 { |
1428 // Write out to disk previous completed Read |
1231 // Write out to disk previous completed Read |
1429 TUSB_VERBOSE_PRINT2("iMaxBufSz = %d (iReadBuf.Size(): %d)", |
1232 TUSB_VERBOSE_PRINT2("iMaxBufSz = %d (iReadBuf.Size(): %d)", |
1430 iMaxBufSz, iReadBuf.Size()); |
1233 iMaxBufSz, iReadBuf.Size()); |
1431 if(iVerbose) |
|
1432 { |
|
1433 OstTraceExt2(TRACE_VERBOSE, CACTIVERW_RUNL_DUP04, "iMaxBufSz = %d (iReadBuf.Size(): %d)", |
|
1434 iMaxBufSz, iReadBuf.Size()); |
|
1435 } |
|
1436 WriteBufferToDisk(iReadBuf, iMaxBufSz); |
1234 WriteBufferToDisk(iReadBuf, iMaxBufSz); |
1437 } |
1235 } |
1438 ReadData(); // next we read data |
1236 ReadData(); // next we read data |
1439 break; |
1237 break; |
1440 } |
1238 } |
1441 if (iXferMode == ELoopComp) |
1239 if (iXferMode == ELoopComp) |
1442 { |
1240 { |
1443 if (!CompareBuffers(iBufSz)) |
1241 if (!CompareBuffers(iBufSz)) |
1444 { |
1242 { |
1445 TUSB_PRINT1("Error while comparing tx & rx buffers for packet 0x%x", iPktNum); |
1243 TUSB_PRINT1("Error while comparing tx & rx buffers for packet 0x%x", iPktNum); |
1446 OstTrace1(TRACE_NORMAL, CACTIVERW_RUNL_DUP05, "Error while comparing tx & rx buffers for packet 0x%x", iPktNum); |
|
1447 } |
1244 } |
1448 } |
1245 } |
1449 else if (iBufSz > 3) |
1246 else if (iBufSz > 3) |
1450 { |
1247 { |
1451 const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
1248 const TUint32 num = *reinterpret_cast<const TUint32*>(iReadBuf.Ptr()); |
1452 if (num != iPktNum) |
1249 if (num != iPktNum) |
1453 { |
1250 { |
1454 TUSB_PRINT2("*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
1251 TUSB_PRINT2("*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
1455 OstTraceExt2(TRACE_NORMAL, CACTIVERW_RUNL_DUP06, "*** rcv'd wrong pkt number: 0x%x (expected: 0x%x)", num, iPktNum); |
|
1456 } |
1252 } |
1457 } |
1253 } |
1458 if (iBufSz == iMaxBufSz) |
1254 if (iBufSz == iMaxBufSz) |
1459 { |
1255 { |
1460 iBufSz = KInitialBufSz; |
1256 iBufSz = KInitialBufSz; |
1501 iPreambleBuf[6] = 'r'; |
1290 iPreambleBuf[6] = 'r'; |
1502 iPreambleBuf[7] = 's'; |
1291 iPreambleBuf[7] = 's'; |
1503 TRequestStatus send_status; |
1292 TRequestStatus send_status; |
1504 iPort->Write(send_status, EEndpoint1, iPreambleBuf, KPreambleLength); |
1293 iPort->Write(send_status, EEndpoint1, iPreambleBuf, KPreambleLength); |
1505 TUSB_VERBOSE_PRINT("Waiting for write request to complete..."); |
1294 TUSB_VERBOSE_PRINT("Waiting for write request to complete..."); |
1506 if(iVerbose) |
|
1507 { |
|
1508 OstTrace0(TRACE_VERBOSE, CACTIVERW_SENDVERSION_DUP03, "Waiting for write request to complete..."); |
|
1509 } |
|
1510 User::WaitForRequest(send_status); |
1295 User::WaitForRequest(send_status); |
1511 TUSB_VERBOSE_PRINT("...done.\n"); |
1296 TUSB_VERBOSE_PRINT("...done.\n"); |
1512 if(iVerbose) |
|
1513 { |
|
1514 OstTrace0(TRACE_VERBOSE, CACTIVERW_SENDVERSION_DUP04, "...done.\n"); |
|
1515 } |
|
1516 return send_status.Int(); |
1297 return send_status.Int(); |
1517 } |
1298 } |
1518 |
1299 |
1519 |
1300 |
1520 TInt CActiveRW::ReceiveVersion() |
1301 TInt CActiveRW::ReceiveVersion() |
1521 { |
1302 { |
1522 TUSB_VERBOSE_PRINT("CActiveRW::ReceiveVersion()"); |
1303 TUSB_VERBOSE_PRINT("CActiveRW::ReceiveVersion()"); |
1523 if(iVerbose) |
|
1524 { |
|
1525 OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION, "CActiveRW::ReceiveVersion()"); |
|
1526 } |
|
1527 if (iXferMode != ::ENone) |
1304 if (iXferMode != ::ENone) |
1528 { |
1305 { |
1529 TUSB_PRINT1("Error : wrong state: %d", iXferMode); |
1306 TUSB_PRINT1("Error : wrong state: %d", iXferMode); |
1530 OstTrace1(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP01, "Error : wrong state: %d", iXferMode); |
|
1531 return KErrGeneral; |
1307 return KErrGeneral; |
1532 } |
1308 } |
1533 // Here we try to receive a version packet from the host. |
1309 // Here we try to receive a version packet from the host. |
1534 // (We can use the preamble buffer because we only need it |
1310 // (We can use the preamble buffer because we only need it |
1535 // once and that's also before the preamble uses.) |
1311 // once and that's also before the preamble uses.) |
1536 TUSB_PRINT("Getting host program versions..."); |
1312 TUSB_PRINT("Getting host program versions..."); |
1537 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP02, "Getting host program versions..."); |
|
1538 iPreambleBuf.FillZ(); |
1313 iPreambleBuf.FillZ(); |
1539 TRequestStatus receive_status; |
1314 TRequestStatus receive_status; |
1540 iPort->Read(receive_status, EEndpoint2, iPreambleBuf, KPreambleLength); |
1315 iPort->Read(receive_status, EEndpoint2, iPreambleBuf, KPreambleLength); |
1541 TUSB_VERBOSE_PRINT("Waiting for read request to complete..."); |
1316 TUSB_VERBOSE_PRINT("Waiting for read request to complete..."); |
1542 if(iVerbose) |
|
1543 { |
|
1544 OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION_DUP03, "Waiting for read request to complete..."); |
|
1545 } |
|
1546 iTimeoutTimer->Activate(5000000); // Host gets 5s |
1317 iTimeoutTimer->Activate(5000000); // Host gets 5s |
1547 User::WaitForRequest(receive_status, iTimeoutTimer->iStatus); |
1318 User::WaitForRequest(receive_status, iTimeoutTimer->iStatus); |
1548 if (receive_status == KRequestPending) |
1319 if (receive_status == KRequestPending) |
1549 { |
1320 { |
1550 // Read() still pending... |
1321 // Read() still pending... |
1551 TUSB_PRINT("Cancelling USB Read(): no response from host.\n"); |
1322 TUSB_PRINT("Cancelling USB Read(): no response from host.\n"); |
1552 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP04, "Cancelling USB Read(): no response from host.\n"); |
|
1553 iPort->ReadCancel(EEndpoint2); |
1323 iPort->ReadCancel(EEndpoint2); |
1554 TUSB_PRINT("THIS COULD BE DUE TO AN OLD VERSION OF USBRFLCT ON THE PC:"); |
1324 TUSB_PRINT("THIS COULD BE DUE TO AN OLD VERSION OF USBRFLCT ON THE PC:"); |
1555 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP05, "THIS COULD BE DUE TO AN OLD VERSION OF USBRFLCT ON THE PC:"); |
|
1556 TUSB_PRINT3("PLEASE CHECK THE VERSION THERE - WE NEED AT LEAST V%d.%d.%d!\n", |
1325 TUSB_PRINT3("PLEASE CHECK THE VERSION THERE - WE NEED AT LEAST V%d.%d.%d!\n", |
1557 KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
|
1558 OstTraceExt3(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP06, "PLEASE CHECK THE VERSION THERE - WE NEED AT LEAST V%d.%d.%d!\n", |
|
1559 KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
1326 KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
1560 TUSB_PRINT("When updating an existing USBRFLCT installation <= v1.3.1,\n" \ |
1327 TUSB_PRINT("When updating an existing USBRFLCT installation <= v1.3.1,\n" \ |
1561 L"the following three things will need to be done:\n"); |
1328 L"the following three things will need to be done:\n"); |
1562 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP07, "When updating an existing USBRFLCT installation <= v1.3.1,\n" \ |
|
1563 L"the following three things will need to be done:\n"); |
|
1564 TUSB_PRINT("1. Connect the device to the PC & start T_USB (just as now),\n" \ |
1329 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"); |
|
1568 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP08, "1. Connect the device to the PC & start T_USB (just as now),\n" \ |
|
1569 L"then find the USB device in the Windows Device Manager\n" \ |
1330 L"then find the USB device in the Windows Device Manager\n" \ |
1570 L"('Control Panel'->'System'->'Hardware'->'Device Manager').\n" \ |
1331 L"('Control Panel'->'System'->'Hardware'->'Device Manager').\n" \ |
1571 L"Right click on the device name and choose 'Uninstall...'.\n"); |
1332 L"Right click on the device name and choose 'Uninstall...'.\n"); |
1572 TUSB_PRINT("2. In c:\\winnt\\inf\\, find (by searching for \"Symbian\") and\n" \ |
1333 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" \ |
1334 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" \ |
1335 L"version of USBRFLCT.SYS. Make sure to also delete the\n" \ |
1575 L"precompiled version of that file (<samename>.PNF).\n"); |
1336 L"precompiled version of that file (<samename>.PNF).\n"); |
1576 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP09, "2. In c:\\winnt\\inf\\, find (by searching for \"Symbian\") and\n" \ |
|
1577 L"delete the *.INF file that was used to install the existing\n" \ |
|
1578 L"version of USBRFLCT.SYS. Make sure to also delete the\n" \ |
|
1579 L"precompiled version of that file (<samename>.PNF).\n"); |
|
1580 TUSB_PRINT("3. In c:\\winnt\\system32\\drivers\\, delete the file USBRFLCT.SYS.\n"); |
1337 TUSB_PRINT("3. In c:\\winnt\\system32\\drivers\\, delete the file USBRFLCT.SYS.\n"); |
1581 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP10, "3. In c:\\winnt\\system32\\drivers\\, delete the file USBRFLCT.SYS.\n"); |
|
1582 TUSB_PRINT("Then unplug & reconnect the USB device and, when prompted, install\n" \ |
1338 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" \ |
1339 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"); |
1340 L"(All files can be found under e32test\\win32\\usbrflct_distribution\\.)\n"); |
1585 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP11, "Then unplug & reconnect the USB device and, when prompted, install\n" \ |
|
1586 L"the new USBRFLCT.SYS driver using the .INF file from this distribution.\n" \ |
|
1587 L"(All files can be found under e32test\\win32\\usbrflct_distribution\\.)\n"); |
|
1588 TUSB_PRINT("Use the new USBRFLCT.EXE from this distribution.\n"); |
1341 TUSB_PRINT("Use the new USBRFLCT.EXE from this distribution.\n"); |
1589 OstTrace0(TRACE_NORMAL, CACTIVERW_RECEIVEVERSION_DUP12, "Use the new USBRFLCT.EXE from this distribution.\n"); |
|
1590 } |
1342 } |
1591 else |
1343 else |
1592 { |
1344 { |
1593 TUSB_VERBOSE_PRINT("...done."); |
1345 TUSB_VERBOSE_PRINT("...done."); |
1594 if(iVerbose) |
|
1595 { |
|
1596 OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION_DUP13, "...done."); |
|
1597 } |
|
1598 // Timeout not needed any longer |
1346 // Timeout not needed any longer |
1599 TUSB_VERBOSE_PRINT("Cancelling timeout timer: USB Read() completed.\n"); |
1347 TUSB_VERBOSE_PRINT("Cancelling timeout timer: USB Read() completed.\n"); |
1600 if(iVerbose) |
|
1601 { |
|
1602 OstTrace0(TRACE_VERBOSE, CACTIVERW_RECEIVEVERSION_DUP14, "Cancelling timeout timer: USB Read() completed.\n"); |
|
1603 } |
|
1604 iTimeoutTimer->Cancel(); |
1348 iTimeoutTimer->Cancel(); |
1605 } |
1349 } |
1606 return receive_status.Int(); |
1350 return receive_status.Int(); |
1607 } |
1351 } |
1608 |
1352 |
1609 |
1353 |
1610 TInt CActiveRW::ExchangeVersions() |
1354 TInt CActiveRW::ExchangeVersions() |
1611 { |
1355 { |
1612 TUSB_VERBOSE_PRINT("CActiveRW::ExchangeVersions()"); |
1356 TUSB_VERBOSE_PRINT("CActiveRW::ExchangeVersions()"); |
1613 if(iVerbose) |
|
1614 { |
|
1615 OstTrace0(TRACE_VERBOSE, CACTIVERW_EXCHANGEVERSIONS, "CActiveRW::ExchangeVersions()"); |
|
1616 } |
|
1617 // First check the version of USBRFLCT that's running on the host |
1357 // First check the version of USBRFLCT that's running on the host |
1618 TInt r = ReceiveVersion(); |
1358 TInt r = ReceiveVersion(); |
1619 if (r != KErrNone) |
1359 if (r != KErrNone) |
1620 { |
1360 { |
1621 return KErrGeneral; |
1361 return KErrGeneral; |
1626 TUint8 usbio_ver_major = iPreambleBuf[3]; |
1366 TUint8 usbio_ver_major = iPreambleBuf[3]; |
1627 TUint8 usbio_ver_minor = iPreambleBuf[4]; |
1367 TUint8 usbio_ver_minor = iPreambleBuf[4]; |
1628 TUSB_PRINT5("Host-side: USBRFLCT v%d.%d.%d USBIO v%d.%d\n", |
1368 TUSB_PRINT5("Host-side: USBRFLCT v%d.%d.%d USBIO v%d.%d\n", |
1629 usbrflct_ver_major, usbrflct_ver_minor, usbrflct_ver_micro, |
1369 usbrflct_ver_major, usbrflct_ver_minor, usbrflct_ver_micro, |
1630 usbio_ver_major, usbio_ver_minor); |
1370 usbio_ver_major, usbio_ver_minor); |
1631 OstTraceExt5(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP01, "Host-side: USBRFLCT v%d.%d.%d USBIO v%d.%d\n", |
|
1632 usbrflct_ver_major, usbrflct_ver_minor, usbrflct_ver_micro, |
|
1633 usbio_ver_major, usbio_ver_minor); |
|
1634 if (usbrflct_ver_major < KUsbrflctVersionMajor) |
1371 if (usbrflct_ver_major < KUsbrflctVersionMajor) |
1635 { |
1372 { |
1636 TUSB_PRINT1("USBRFLCT version not sufficient (need at least v%d.x.x)\n", |
1373 TUSB_PRINT1("USBRFLCT version not sufficient (need at least v%d.x.x)\n", |
1637 KUsbrflctVersionMajor); |
|
1638 OstTrace1(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP02, "USBRFLCT version not sufficient (need at least v%d.x.x)\n", |
|
1639 KUsbrflctVersionMajor); |
1374 KUsbrflctVersionMajor); |
1640 return KErrGeneral; |
1375 return KErrGeneral; |
1641 } |
1376 } |
1642 // Just using '<' instead of the seemingly absurd '<= && !==' doesn't work without |
1377 // 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 '<'). |
1378 // GCC compiler warning because Kxxx can also be zero (in which case there's no '<'). |
1644 else if ((usbrflct_ver_minor <= KUsbrflctVersionMinor) && |
1379 else if ((usbrflct_ver_minor <= KUsbrflctVersionMinor) && |
1645 !(usbrflct_ver_minor == KUsbrflctVersionMinor)) |
1380 !(usbrflct_ver_minor == KUsbrflctVersionMinor)) |
1646 { |
1381 { |
1647 TUSB_PRINT2("USBRFLCT version not sufficient (need at least v%d.%d.x)\n", |
1382 TUSB_PRINT2("USBRFLCT version not sufficient (need at least v%d.%d.x)\n", |
1648 KUsbrflctVersionMajor, KUsbrflctVersionMinor); |
1383 KUsbrflctVersionMajor, KUsbrflctVersionMinor); |
1649 OstTraceExt2(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP03, "USBRFLCT version not sufficient (need at least v%d.%d.x)\n", |
|
1650 KUsbrflctVersionMajor, KUsbrflctVersionMinor); |
|
1651 return KErrGeneral; |
1384 return KErrGeneral; |
1652 } |
1385 } |
1653 // Just using '<' instead of the seemingly absurd '<= && !==' doesn't work without |
1386 // 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 '<'). |
1387 // GCC compiler warning because Kxxx can also be zero (in which case there's no '<'). |
1655 else if ((usbrflct_ver_micro <= KUsbrflctVersionMicro) && |
1388 else if ((usbrflct_ver_micro <= KUsbrflctVersionMicro) && |
1656 !(usbrflct_ver_micro == KUsbrflctVersionMicro)) |
1389 !(usbrflct_ver_micro == KUsbrflctVersionMicro)) |
1657 { |
1390 { |
1658 TUSB_PRINT3("USBRFLCT version not sufficient (need at least v%d.%d.%d)\n", |
1391 TUSB_PRINT3("USBRFLCT version not sufficient (need at least v%d.%d.%d)\n", |
1659 KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
1392 KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
1660 OstTraceExt3(TRACE_NORMAL, CACTIVERW_EXCHANGEVERSIONS_DUP04, "USBRFLCT version not sufficient (need at least v%d.%d.%d)\n", |
|
1661 KUsbrflctVersionMajor, KUsbrflctVersionMinor, KUsbrflctVersionMicro); |
|
1662 return KErrGeneral; |
1393 return KErrGeneral; |
1663 } |
1394 } |
1664 // Now we send T_USB's version to the host |
1395 // Now we send T_USB's version to the host |
1665 r = SendVersion(); |
1396 r = SendVersion(); |
1666 if (r != KErrNone) |
1397 if (r != KErrNone) |
1904 } |
1601 } |
1905 const TInt r = iFile.Read(aBuffer, aLen); |
1602 const TInt r = iFile.Read(aBuffer, aLen); |
1906 if (r != KErrNone) |
1603 if (r != KErrNone) |
1907 { |
1604 { |
1908 TUSB_PRINT2("Error reading from %S (%d)", &iFileName, r); |
1605 TUSB_PRINT2("Error reading from %S (%d)", &iFileName, r); |
1909 OstTraceExt2(TRACE_NORMAL, CACTIVERW_READBUFFERFROMDISK, "Error reading from %S (%d)", iFileName, r); |
|
1910 iDiskAccessEnabled = EFalse; |
1606 iDiskAccessEnabled = EFalse; |
1911 return; |
1607 return; |
1912 } |
1608 } |
1913 TInt readLen = aBuffer.Length(); |
1609 TInt readLen = aBuffer.Length(); |
1914 TUSB_VERBOSE_PRINT1("CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
1610 TUSB_VERBOSE_PRINT1("CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
1915 if(iVerbose) |
|
1916 { |
|
1917 OstTrace1(TRACE_VERBOSE, CACTIVERW_READBUFFERFROMDISK_DUP01, "CActiveRW::ReadBufferFromDisk(), len = %d\n", readLen); |
|
1918 } |
|
1919 if (readLen < aLen) |
1611 if (readLen < aLen) |
1920 { |
1612 { |
1921 TUSB_PRINT3("Only %d bytes of %d read from file %S)", |
1613 TUSB_PRINT3("Only %d bytes of %d read from file %S)", |
1922 readLen, aLen, &iFileName); |
1614 readLen, aLen, &iFileName); |
1923 OstTraceExt3(TRACE_NORMAL, CACTIVERW_READBUFFERFROMDISK_DUP02, "Only %d bytes of %d read from file %S)", |
|
1924 readLen, aLen, iFileName); |
|
1925 iDiskAccessEnabled = EFalse; |
1615 iDiskAccessEnabled = EFalse; |
1926 return; |
1616 return; |
1927 } |
1617 } |
1928 iFileOffset += aLen; |
1618 iFileOffset += aLen; |
1929 } |
1619 } |
1930 |
1620 |
1931 |
1621 |
1932 void CActiveRW::ReadData() |
1622 void CActiveRW::ReadData() |
1933 { |
1623 { |
1934 TUSB_VERBOSE_PRINT("CActiveRW::ReadData()"); |
1624 TUSB_VERBOSE_PRINT("CActiveRW::ReadData()"); |
1935 if(iVerbose) |
|
1936 { |
|
1937 OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA, "CActiveRW::ReadData()"); |
|
1938 } |
|
1939 __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
1625 __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); |
1940 TUSB_VERBOSE_PRINT1("Reading data: %d bytes", iBufSz); |
1626 TUSB_VERBOSE_PRINT1("Reading data: %d bytes", iBufSz); |
1941 if(iVerbose) |
|
1942 { |
|
1943 OstTrace1(TRACE_VERBOSE, CACTIVERW_READDATA_DUP01, "Reading data: %d bytes", iBufSz); |
|
1944 } |
|
1945 if (iXferMode == EReceiveOnly) |
1627 if (iXferMode == EReceiveOnly) |
1946 { |
1628 { |
1947 TUSB_VERBOSE_PRINT(" (rx only)"); |
1629 TUSB_VERBOSE_PRINT(" (rx only)"); |
1948 if(iVerbose) |
|
1949 { |
|
1950 OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP02, " (rx only)"); |
|
1951 } |
|
1952 iPort->Read(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1630 iPort->Read(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1953 } |
1631 } |
1954 else if (iBufSz == iMaxPktSz) |
1632 else if (iBufSz == iMaxPktSz) |
1955 { |
1633 { |
1956 // we also want to test the packet version of Read() |
1634 // we also want to test the packet version of Read() |
1957 TUSB_VERBOSE_PRINT(" (a single packet)"); |
1635 TUSB_VERBOSE_PRINT(" (a single packet)"); |
1958 if(iVerbose) |
|
1959 { |
|
1960 OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP03, " (a single packet)"); |
|
1961 } |
|
1962 iPort->ReadPacket(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1636 iPort->ReadPacket(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1963 } |
1637 } |
1964 else if (iBufSz == iReadBuf.MaxSize()) |
1638 else if (iBufSz == iReadBuf.MaxSize()) |
1965 { |
1639 { |
1966 // or we could perhaps test the three-parameter version |
1640 // or we could perhaps test the three-parameter version |
1967 TUSB_VERBOSE_PRINT(" (w/o length)"); |
1641 TUSB_VERBOSE_PRINT(" (w/o length)"); |
1968 if(iVerbose) |
|
1969 { |
|
1970 OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP04, " (w/o length)"); |
|
1971 } |
|
1972 iPort->Read(iStatus, EEndpoint2, iReadBuf); |
1642 iPort->Read(iStatus, EEndpoint2, iReadBuf); |
1973 } |
1643 } |
1974 else |
1644 else |
1975 { |
1645 { |
1976 // otherwise, we use the universal default version |
1646 // otherwise, we use the universal default version |
1977 TUSB_VERBOSE_PRINT(" (normal)"); |
1647 TUSB_VERBOSE_PRINT(" (normal)"); |
1978 if(iVerbose) |
|
1979 { |
|
1980 OstTrace0(TRACE_VERBOSE, CACTIVERW_READDATA_DUP05, " (normal)"); |
|
1981 } |
|
1982 iPort->Read(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1648 iPort->Read(iStatus, EEndpoint2, iReadBuf, iBufSz); |
1983 } |
1649 } |
1984 iCurrentXfer = EReadXfer; |
1650 iCurrentXfer = EReadXfer; |
1985 SetActive(); |
1651 SetActive(); |
1986 } |
1652 } |
2185 { |
1812 { |
2186 switch (iDeviceState) |
1813 switch (iDeviceState) |
2187 { |
1814 { |
2188 case EUsbcDeviceStateUndefined: |
1815 case EUsbcDeviceStateUndefined: |
2189 TUSB_PRINT("Device State notifier: Undefined"); |
1816 TUSB_PRINT("Device State notifier: Undefined"); |
2190 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL, "Device State notifier: Undefined"); |
|
2191 break; |
1817 break; |
2192 case EUsbcDeviceStateAttached: |
1818 case EUsbcDeviceStateAttached: |
2193 TUSB_PRINT("Device State notifier: Attached"); |
1819 TUSB_PRINT("Device State notifier: Attached"); |
2194 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP01, "Device State notifier: Attached"); |
|
2195 break; |
1820 break; |
2196 case EUsbcDeviceStatePowered: |
1821 case EUsbcDeviceStatePowered: |
2197 TUSB_PRINT("Device State notifier: Powered"); |
1822 TUSB_PRINT("Device State notifier: Powered"); |
2198 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP02, "Device State notifier: Powered"); |
|
2199 break; |
1823 break; |
2200 case EUsbcDeviceStateDefault: |
1824 case EUsbcDeviceStateDefault: |
2201 TUSB_PRINT("Device State notifier: Default"); |
1825 TUSB_PRINT("Device State notifier: Default"); |
2202 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP03, "Device State notifier: Default"); |
|
2203 break; |
1826 break; |
2204 case EUsbcDeviceStateAddress: |
1827 case EUsbcDeviceStateAddress: |
2205 TUSB_PRINT("Device State notifier: Address"); |
1828 TUSB_PRINT("Device State notifier: Address"); |
2206 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP04, "Device State notifier: Address"); |
|
2207 break; |
1829 break; |
2208 case EUsbcDeviceStateConfigured: |
1830 case EUsbcDeviceStateConfigured: |
2209 TUSB_PRINT("Device State notifier: Configured"); |
1831 TUSB_PRINT("Device State notifier: Configured"); |
2210 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP05, "Device State notifier: Configured"); |
|
2211 break; |
1832 break; |
2212 case EUsbcDeviceStateSuspended: |
1833 case EUsbcDeviceStateSuspended: |
2213 TUSB_PRINT("Device State notifier: Suspended"); |
1834 TUSB_PRINT("Device State notifier: Suspended"); |
2214 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP06, "Device State notifier: Suspended"); |
|
2215 break; |
1835 break; |
2216 default: |
1836 default: |
2217 TUSB_PRINT("Device State notifier: ***BAD***"); |
1837 TUSB_PRINT("Device State notifier: ***BAD***"); |
2218 OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP07, "Device State notifier: ***BAD***"); |
|
2219 } |
1838 } |
2220 } |
1839 } |
2221 else if (iDeviceState & KUsbAlternateSetting) |
1840 else if (iDeviceState & KUsbAlternateSetting) |
2222 { |
1841 { |
2223 TUSB_PRINT1("Device State notifier: Alternate interface setting has changed: now %d", |
1842 TUSB_PRINT1("Device State notifier: Alternate interface setting has changed: now %d", |
2224 iDeviceState & ~KUsbAlternateSetting); |
|
2225 OstTrace1(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP08, "Device State notifier: Alternate interface setting has changed: now %d", |
|
2226 iDeviceState & ~KUsbAlternateSetting); |
1843 iDeviceState & ~KUsbAlternateSetting); |
2227 } |
1844 } |
2228 |
1845 |
2229 Activate(); |
1846 Activate(); |
2230 } |
1847 } |