branch | RCL_3 |
changeset 44 | 3e88ff8f41d5 |
parent 43 | c1f20ce4abcf |
43:c1f20ce4abcf | 44:3e88ff8f41d5 |
---|---|
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
22 #include <d32usbcsc.h> |
22 #include <d32usbcsc.h> |
23 #include <hal.h> |
23 #include <hal.h> |
24 #include "t_usblib.h" |
24 #include "t_usblib.h" |
25 #include <e32svr.h> |
25 #include <e32svr.h> |
26 #include "u32std.h" |
26 #include "u32std.h" |
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "t_usbcscTraces.h" |
|
30 #endif |
|
31 |
27 |
32 //#define DEBUGVERSION |
28 //#define DEBUGVERSION |
33 |
29 |
34 #ifdef DEBUGVERSION |
30 #ifdef DEBUGVERSION |
35 #define DEBUGPRINT(a) {a;} |
31 #define DEBUGPRINT(a) {a;} |
311 test_KErrNone(r); |
307 test_KErrNone(r); |
312 |
308 |
313 TUsbcScChunkHeader chunkHeader(gChunk); |
309 TUsbcScChunkHeader chunkHeader(gChunk); |
314 |
310 |
315 DEBUGPRINT(test.Printf(_L("iBuffers at 0x%x, iAltSettings at 0x%x\n"),chunkHeader.iBuffers, chunkHeader.iAltSettings)); |
311 DEBUGPRINT(test.Printf(_L("iBuffers at 0x%x, iAltSettings at 0x%x\n"),chunkHeader.iBuffers, chunkHeader.iAltSettings)); |
316 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TESTBUFFERCONSTRUCTION_TESTBUFFERCONSTRUCTION, "iBuffers at 0x%x, iAltSettings at 0x%x\n",chunkHeader.iBuffers, chunkHeader.iAltSettings)); |
|
317 |
312 |
318 test_Equal(gChunk.Base()+ sizeof(TUint)*2, chunkHeader.iBuffers); |
313 test_Equal(gChunk.Base()+ sizeof(TUint)*2, chunkHeader.iBuffers); |
319 |
314 |
320 DEBUGPRINT(test.Printf(_L("iBuffers: EP0Out: 0x%x EP0In: 0x%x\n"), chunkHeader.iBuffers->Ep0Out()->Offset(), |
315 DEBUGPRINT(test.Printf(_L("iBuffers: EP0Out: 0x%x EP0In: 0x%x\n"), chunkHeader.iBuffers->Ep0Out()->Offset(), |
321 chunkHeader.iBuffers->Ep0In()->Offset())); |
|
322 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TESTBUFFERCONSTRUCTION_TESTBUFFERCONSTRUCTION_DUP01, "iBuffers: EP0Out: 0x%x EP0In: 0x%x\n", chunkHeader.iBuffers->Ep0Out()->Offset(), |
|
323 chunkHeader.iBuffers->Ep0In()->Offset())); |
316 chunkHeader.iBuffers->Ep0In()->Offset())); |
324 |
317 |
325 DEBUGPRINT(test.Printf(_L("iAltSettings: Number of: %d First offset: 0x%x \n"), chunkHeader.iAltSettings->iNumOfAltSettings, |
318 DEBUGPRINT(test.Printf(_L("iAltSettings: Number of: %d First offset: 0x%x \n"), chunkHeader.iAltSettings->iNumOfAltSettings, |
326 chunkHeader.iAltSettings->iAltTableOffset[0])); |
319 chunkHeader.iAltSettings->iAltTableOffset[0])); |
327 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TESTBUFFERCONSTRUCTION_TESTBUFFERCONSTRUCTION_DUP02, "iAltSettings: Number of: %d First offset: 0x%x \n", chunkHeader.iAltSettings->iNumOfAltSettings, |
|
328 chunkHeader.iAltSettings->iAltTableOffset[0])); |
|
329 |
320 |
330 test_Compare(aAltSetConfig->iNumOfAltSet, ==, chunkHeader.iAltSettings->iNumOfAltSettings); |
321 test_Compare(aAltSetConfig->iNumOfAltSet, ==, chunkHeader.iAltSettings->iNumOfAltSettings); |
331 |
322 |
332 TInt maxInEps = 0, maxOutEps = 0; |
323 TInt maxInEps = 0, maxOutEps = 0; |
333 for (int i = 0; i < chunkHeader.iAltSettings->iNumOfAltSettings; i++) |
324 for (int i = 0; i < chunkHeader.iAltSettings->iNumOfAltSettings; i++) |
334 { |
325 { |
335 TInt inEps = 0, outEps = 0; |
326 TInt inEps = 0, outEps = 0; |
336 DEBUGPRINT(test.Printf(_L("Alternate Setting %d offset: 0x%x \n"), i, chunkHeader.iAltSettings->iAltTableOffset[i])); |
327 DEBUGPRINT(test.Printf(_L("Alternate Setting %d offset: 0x%x \n"), i, chunkHeader.iAltSettings->iAltTableOffset[i])); |
337 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TESTBUFFERCONSTRUCTION_TESTBUFFERCONSTRUCTION_DUP03, "Alternate Setting %d offset: 0x%x \n", i, chunkHeader.iAltSettings->iAltTableOffset[i])); |
|
338 |
328 |
339 TInt8* endpoint = (TInt8*) (chunkHeader.iAltSettings->iAltTableOffset[i] + (TInt) gChunk.Base()); |
329 TInt8* endpoint = (TInt8*) (chunkHeader.iAltSettings->iAltTableOffset[i] + (TInt) gChunk.Base()); |
340 for (int j = 1; j <= chunkHeader.GetNumberOfEndpoints(i); j++) |
330 for (int j = 1; j <= chunkHeader.GetNumberOfEndpoints(i); j++) |
341 { |
331 { |
342 TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(endpoint[j * chunkHeader.iAltSettings->iEpRecordSize]); |
332 TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(endpoint[j * chunkHeader.iAltSettings->iEpRecordSize]); |
343 DEBUGPRINT(test.Printf(_L("Endpoint %d owns buffer %d BufferOffset 0x%x Dir %d Type %d\n"), j, endpointInf->iBufferNo, chunkHeader.iBuffers->Buffers(endpointInf->iBufferNo)->Offset(), |
333 DEBUGPRINT(test.Printf(_L("Endpoint %d owns buffer %d BufferOffset 0x%x Dir %d Type %d\n"), j, endpointInf->iBufferNo, chunkHeader.iBuffers->Buffers(endpointInf->iBufferNo)->Offset(), |
344 endpointInf->Direction(), endpointInf->Type())); |
|
345 DEBUGPRINT(OstTraceExt5(TRACE_NORMAL, TESTBUFFERCONSTRUCTION_TESTBUFFERCONSTRUCTION_DUP04, "Endpoint %d owns buffer %d BufferOffset 0x%x Dir %d Type %d\n", j, endpointInf->iBufferNo, chunkHeader.iBuffers->Buffers(endpointInf->iBufferNo)->Offset(), |
|
346 endpointInf->Direction(), endpointInf->Type())); |
334 endpointInf->Direction(), endpointInf->Type())); |
347 if (endpointInf->Direction() == KUsbScHdrEpDirectionOut) |
335 if (endpointInf->Direction() == KUsbScHdrEpDirectionOut) |
348 { |
336 { |
349 outEps++; |
337 outEps++; |
350 } |
338 } |
354 } |
342 } |
355 } |
343 } |
356 |
344 |
357 DEBUGPRINT(test.Printf(_L("Test if Alternate Setting %d has %d endpoints (%d Out Endpoint(s) and %d In Endpoint(s)) \n"), i, aAltSetConfig->iEpsDesc[i].iNumOfEp, |
345 DEBUGPRINT(test.Printf(_L("Test if Alternate Setting %d has %d endpoints (%d Out Endpoint(s) and %d In Endpoint(s)) \n"), i, aAltSetConfig->iEpsDesc[i].iNumOfEp, |
358 aAltSetConfig->iEpsDesc[i].iNumOfOutEp, aAltSetConfig->iEpsDesc[i].iNumOfInEp)); |
346 aAltSetConfig->iEpsDesc[i].iNumOfOutEp, aAltSetConfig->iEpsDesc[i].iNumOfInEp)); |
359 DEBUGPRINT(OstTraceExt4(TRACE_NORMAL, TESTBUFFERCONSTRUCTION_TESTBUFFERCONSTRUCTION_DUP05, "Test if Alternate Setting %d has %d endpoints (%d Out Endpoint(s) and %d In Endpoint(s)) \n", i, aAltSetConfig->iEpsDesc[i].iNumOfEp, |
|
360 aAltSetConfig->iEpsDesc[i].iNumOfOutEp, aAltSetConfig->iEpsDesc[i].iNumOfInEp)); |
|
361 |
347 |
362 test_Compare(chunkHeader.GetNumberOfEndpoints(i), ==, aAltSetConfig->iEpsDesc[i].iNumOfEp); |
348 test_Compare(chunkHeader.GetNumberOfEndpoints(i), ==, aAltSetConfig->iEpsDesc[i].iNumOfEp); |
363 test_Compare(outEps, ==, aAltSetConfig->iEpsDesc[i].iNumOfOutEp); |
349 test_Compare(outEps, ==, aAltSetConfig->iEpsDesc[i].iNumOfOutEp); |
364 test_Compare(inEps, ==, aAltSetConfig->iEpsDesc[i].iNumOfInEp); |
350 test_Compare(inEps, ==, aAltSetConfig->iEpsDesc[i].iNumOfInEp); |
365 if (outEps > maxOutEps) |
351 if (outEps > maxOutEps) |
396 } |
382 } |
397 |
383 |
398 void CActiveConsole::GetCharacter() |
384 void CActiveConsole::GetCharacter() |
399 { |
385 { |
400 test.Printf(_L("\n \n ***** Press Escape to exit ***** \n \n")); |
386 test.Printf(_L("\n \n ***** Press Escape to exit ***** \n \n")); |
401 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_GETCHARACTER, "\n \n ***** Press Escape to exit ***** \n \n"); |
|
402 |
387 |
403 test.Console()->Read(iStatus); |
388 test.Console()->Read(iStatus); |
404 SetActive(); |
389 SetActive(); |
405 } |
390 } |
406 |
391 |
407 void CActiveConsole::DoCancel() |
392 void CActiveConsole::DoCancel() |
408 { |
393 { |
409 DEBUGPRINT(test.Printf(_L("CActiveConsole::DoCancel\n"))); |
394 DEBUGPRINT(test.Printf(_L("CActiveConsole::DoCancel\n"))); |
410 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_DOCANCEL, "CActiveConsole::DoCancel\n")); |
|
411 test.Console()->ReadCancel(); |
395 test.Console()->ReadCancel(); |
412 } |
396 } |
413 |
397 |
414 void CActiveConsole::RunL() |
398 void CActiveConsole::RunL() |
415 { |
399 { |
416 DEBUGPRINT(test.Printf(_L("\n CActiveConsole::RunL\n"))); |
400 DEBUGPRINT(test.Printf(_L("\n CActiveConsole::RunL\n"))); |
417 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_RUNL, "\n CActiveConsole::RunL\n")); |
|
418 if (test.Console()->KeyCode() == EKeyEscape) |
401 if (test.Console()->KeyCode() == EKeyEscape) |
419 { |
402 { |
420 test.Printf(_L("CActiveConsole: ESC key pressed -> stopping active scheduler...\n")); |
403 test.Printf(_L("CActiveConsole: ESC key pressed -> stopping active scheduler...\n")); |
421 OstTrace0(TRACE_NORMAL, CACTIVECONSOLE_RUNL_DUP01, "CActiveConsole: ESC key pressed -> stopping active scheduler...\n"); |
|
422 CActiveScheduler::Stop(); |
404 CActiveScheduler::Stop(); |
423 return; |
405 return; |
424 } |
406 } |
425 GetCharacter(); |
407 GetCharacter(); |
426 } |
408 } |
428 // Class CActiveDeviceStateNotifier |
410 // Class CActiveDeviceStateNotifier |
429 CActiveDeviceStateNotifier::CActiveDeviceStateNotifier() |
411 CActiveDeviceStateNotifier::CActiveDeviceStateNotifier() |
430 : CActive(EPriorityHigh) |
412 : CActive(EPriorityHigh) |
431 { |
413 { |
432 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::CActiveDeviceStateNotifier() \n"))); |
414 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::CActiveDeviceStateNotifier() \n"))); |
433 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_CACTIVEDEVICESTATENOTIFIER, "CActiveDeviceStateNotifier::CActiveDeviceStateNotifier() \n")); |
|
434 CActiveScheduler::Add(this); |
415 CActiveScheduler::Add(this); |
435 } |
416 } |
436 |
417 |
437 CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() |
418 CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() |
438 { |
419 { |
439 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() \n"))); |
420 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() \n"))); |
440 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_DCACTIVEDEVICESTATENOTIFIER, "CActiveDeviceStateNotifier::~CActiveDeviceStateNotifier() \n")); |
|
441 Cancel(); |
421 Cancel(); |
442 } |
422 } |
443 |
423 |
444 void CActiveDeviceStateNotifier::DoCancel() |
424 void CActiveDeviceStateNotifier::DoCancel() |
445 { |
425 { |
446 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::DoCancel\n"))); |
426 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::DoCancel\n"))); |
447 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_DOCANCEL, "CActiveDeviceStateNotifier::DoCancel\n")); |
|
448 gPort.AlternateDeviceStatusNotifyCancel(); |
427 gPort.AlternateDeviceStatusNotifyCancel(); |
449 } |
428 } |
450 |
429 |
451 void CActiveDeviceStateNotifier::Activate() |
430 void CActiveDeviceStateNotifier::Activate() |
452 { |
431 { |
455 } |
434 } |
456 |
435 |
457 void CActiveDeviceStateNotifier::RunL() |
436 void CActiveDeviceStateNotifier::RunL() |
458 { |
437 { |
459 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::RunL() \n"))); |
438 DEBUGPRINT(test.Printf(_L("CActiveDeviceStateNotifier::RunL() \n"))); |
460 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL, "CActiveDeviceStateNotifier::RunL() \n")); |
|
461 if (!(iDeviceState & KUsbAlternateSetting)) |
439 if (!(iDeviceState & KUsbAlternateSetting)) |
462 { |
440 { |
463 switch (iDeviceState) |
441 switch (iDeviceState) |
464 { |
442 { |
465 case EUsbcDeviceStateUndefined: |
443 case EUsbcDeviceStateUndefined: |
466 DEBUGPRINT(test.Printf(_L("Device State notifier: Undefined \n"))); |
444 DEBUGPRINT(test.Printf(_L("Device State notifier: Undefined \n"))); |
467 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP01, "Device State notifier: Undefined \n")); |
|
468 break; |
445 break; |
469 case EUsbcDeviceStateAttached: |
446 case EUsbcDeviceStateAttached: |
470 DEBUGPRINT(test.Printf(_L("Device State notifier: Attached \n"))); |
447 DEBUGPRINT(test.Printf(_L("Device State notifier: Attached \n"))); |
471 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP02, "Device State notifier: Attached \n")); |
|
472 break; |
448 break; |
473 case EUsbcDeviceStatePowered: |
449 case EUsbcDeviceStatePowered: |
474 DEBUGPRINT(test.Printf(_L("Device State notifier: Powered \n"))); |
450 DEBUGPRINT(test.Printf(_L("Device State notifier: Powered \n"))); |
475 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP03, "Device State notifier: Powered \n")); |
|
476 break; |
451 break; |
477 case EUsbcDeviceStateDefault: |
452 case EUsbcDeviceStateDefault: |
478 DEBUGPRINT(test.Printf(_L("Device State notifier: Default \n"))); |
453 DEBUGPRINT(test.Printf(_L("Device State notifier: Default \n"))); |
479 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP04, "Device State notifier: Default \n")); |
|
480 break; |
454 break; |
481 case EUsbcDeviceStateAddress: |
455 case EUsbcDeviceStateAddress: |
482 DEBUGPRINT(test.Printf(_L("Device State notifier: Address \n"))); |
456 DEBUGPRINT(test.Printf(_L("Device State notifier: Address \n"))); |
483 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP05, "Device State notifier: Address \n")); |
|
484 break; |
457 break; |
485 case EUsbcDeviceStateConfigured: |
458 case EUsbcDeviceStateConfigured: |
486 DEBUGPRINT(test.Printf(_L("Device State notifier: Configured \n"))); |
459 DEBUGPRINT(test.Printf(_L("Device State notifier: Configured \n"))); |
487 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP06, "Device State notifier: Configured \n")); |
|
488 break; |
460 break; |
489 case EUsbcDeviceStateSuspended: |
461 case EUsbcDeviceStateSuspended: |
490 DEBUGPRINT(test.Printf(_L("Device State notifier: Suspended \n"))); |
462 DEBUGPRINT(test.Printf(_L("Device State notifier: Suspended \n"))); |
491 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP07, "Device State notifier: Suspended \n")); |
|
492 break; |
463 break; |
493 default: |
464 default: |
494 DEBUGPRINT(test.Printf(_L("Device State notifier: !!!! NOT RECOGNISED !!!! \n"))); |
465 DEBUGPRINT(test.Printf(_L("Device State notifier: !!!! NOT RECOGNISED !!!! \n"))); |
495 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP08, "Device State notifier: !!!! NOT RECOGNISED !!!! \n")); |
|
496 } |
466 } |
497 } |
467 } |
498 else if (iDeviceState & KUsbAlternateSetting) |
468 else if (iDeviceState & KUsbAlternateSetting) |
499 { |
469 { |
500 test.Printf(_L("Device State notifier: Alternate interface setting has changed: now %d \n"), |
470 test.Printf(_L("Device State notifier: Alternate interface setting has changed: now %d \n"), |
501 iDeviceState & ~KUsbAlternateSetting); |
|
502 OstTrace1(TRACE_NORMAL, CACTIVEDEVICESTATENOTIFIER_RUNL_DUP09, "Device State notifier: Alternate interface setting has changed: now %d \n", |
|
503 iDeviceState & ~KUsbAlternateSetting); |
471 iDeviceState & ~KUsbAlternateSetting); |
504 } |
472 } |
505 Activate(); |
473 Activate(); |
506 } |
474 } |
507 |
475 |
510 CActiveStallNotifier::CActiveStallNotifier() |
478 CActiveStallNotifier::CActiveStallNotifier() |
511 : CActive(EPriorityNormal), |
479 : CActive(EPriorityNormal), |
512 iEndpointState(0) |
480 iEndpointState(0) |
513 { |
481 { |
514 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::CActiveStallNotifier() \n"))); |
482 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::CActiveStallNotifier() \n"))); |
515 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVESTALLNOTIFIER_CACTIVESTALLNOTIFIER, "CActiveStallNotifier::CActiveStallNotifier() \n")); |
|
516 CActiveScheduler::Add(this); |
483 CActiveScheduler::Add(this); |
517 } |
484 } |
518 |
485 |
519 CActiveStallNotifier::~CActiveStallNotifier() |
486 CActiveStallNotifier::~CActiveStallNotifier() |
520 { |
487 { |
521 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::~CActiveStallNotifier() \n"))); |
488 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::~CActiveStallNotifier() \n"))); |
522 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVESTALLNOTIFIER_DCACTIVESTALLNOTIFIER, "CActiveStallNotifier::~CActiveStallNotifier() \n")); |
|
523 Cancel(); |
489 Cancel(); |
524 } |
490 } |
525 |
491 |
526 void CActiveStallNotifier::DoCancel() |
492 void CActiveStallNotifier::DoCancel() |
527 { |
493 { |
528 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::DoCancel() \n"))); |
494 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::DoCancel() \n"))); |
529 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVESTALLNOTIFIER_DOCANCEL, "CActiveStallNotifier::DoCancel() \n")); |
|
530 gPort.EndpointStatusNotifyCancel(); |
495 gPort.EndpointStatusNotifyCancel(); |
531 } |
496 } |
532 |
497 |
533 void CActiveStallNotifier::RunL() |
498 void CActiveStallNotifier::RunL() |
534 { |
499 { |
535 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::RunL() \n"))); |
500 DEBUGPRINT(test.Printf(_L("CActiveStallNotifier::RunL() \n"))); |
536 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVESTALLNOTIFIER_RUNL, "CActiveStallNotifier::RunL() \n")); |
|
537 test.Printf(_L("StallNotifier Endpointstate 0x%x\n"), iEndpointState); |
501 test.Printf(_L("StallNotifier Endpointstate 0x%x\n"), iEndpointState); |
538 OstTrace1(TRACE_NORMAL, CACTIVESTALLNOTIFIER_RUNL_DUP01, "StallNotifier Endpointstate 0x%x\n", iEndpointState); |
|
539 Activate(); |
502 Activate(); |
540 } |
503 } |
541 |
504 |
542 void CActiveStallNotifier::Activate() |
505 void CActiveStallNotifier::Activate() |
543 { |
506 { |
558 { } |
521 { } |
559 |
522 |
560 TInterface::~TInterface() |
523 TInterface::~TInterface() |
561 { |
524 { |
562 DEBUGPRINT(test.Printf(_L("TInterface::~TInterface()\n"))); |
525 DEBUGPRINT(test.Printf(_L("TInterface::~TInterface()\n"))); |
563 DEBUGPRINT(OstTrace0(TRACE_NORMAL, TINTERFACE_DTINTERFACE, "TInterface::~TInterface()\n")); |
|
564 iAlternateSetting.Reset(); |
526 iAlternateSetting.Reset(); |
565 } |
527 } |
566 |
528 |
567 void TInterface::AddAlternateSetting(TAlternateSetting &aAlternateSetting) |
529 void TInterface::AddAlternateSetting(TAlternateSetting &aAlternateSetting) |
568 { |
530 { |
574 { |
536 { |
575 if (aStartNextInAltSet) |
537 if (aStartNextInAltSet) |
576 { |
538 { |
577 IncrementAltSettingChangeSequenceNum(); |
539 IncrementAltSettingChangeSequenceNum(); |
578 test.Printf(_L("ALTERNATE SETTING CHANGE! Calling StartNextInAlternateSetting() \n")); |
540 test.Printf(_L("ALTERNATE SETTING CHANGE! Calling StartNextInAlternateSetting() \n")); |
579 OstTrace0(TRACE_NORMAL, TINTERFACE_SETACTIVEALTERNATESETTING, "ALTERNATE SETTING CHANGE! Calling StartNextInAlternateSetting() \n"); |
|
580 TInt r = gPort.StartNextInAlternateSetting(); |
541 TInt r = gPort.StartNextInAlternateSetting(); |
581 test_Compare((r&0xFFFF), ==, aSettingNum); |
542 test_Compare((r&0xFFFF), ==, aSettingNum); |
582 } |
543 } |
583 |
544 |
584 iAlternateSetting[aSettingNum].Activate(aStartNextInAltSet); |
545 iAlternateSetting[aSettingNum].Activate(aStartNextInAltSet); |
600 //Function definitions for Class TAlternateSetting |
561 //Function definitions for Class TAlternateSetting |
601 |
562 |
602 TAlternateSetting::~TAlternateSetting() |
563 TAlternateSetting::~TAlternateSetting() |
603 { |
564 { |
604 DEBUGPRINT(test.Printf(_L("TAlternateSetting::~TAlternateSetting() \n"))); |
565 DEBUGPRINT(test.Printf(_L("TAlternateSetting::~TAlternateSetting() \n"))); |
605 DEBUGPRINT(OstTrace0(TRACE_NORMAL, TALTERNATESETTING_DTALTERNATESETTING, "TAlternateSetting::~TAlternateSetting() \n")); |
|
606 iEndpoints.Reset(); |
566 iEndpoints.Reset(); |
607 } |
567 } |
608 |
568 |
609 void TAlternateSetting::AddEndpoint(CActiveRW &aEndpoint) |
569 void TAlternateSetting::AddEndpoint(CActiveRW &aEndpoint) |
610 { |
570 { |
647 break; |
607 break; |
648 } |
608 } |
649 } |
609 } |
650 |
610 |
651 if (gSpecTest == EAltSet) |
611 if (gSpecTest == EAltSet) |
652 { |
|
653 test.Printf(_L("On host side, on the Interface Tab, Change to a differnt Alternate Setting and read or write from an endpoint in the new alternate setting \n\n")); |
612 test.Printf(_L("On host side, on the Interface Tab, Change to a differnt Alternate Setting and read or write from an endpoint in the new alternate setting \n\n")); |
654 OstTrace0(TRACE_NORMAL, TALTERNATESETTING_ACTIVATE, "On host side, on the Interface Tab, Change to a differnt Alternate Setting and read or write from an endpoint in the new alternate setting \n\n"); |
613 |
655 } |
|
656 if (aStartNextInAltSet) |
614 if (aStartNextInAltSet) |
657 { |
615 { |
658 iEndpoints[0].iSettingChangeReceived = EFalse; |
616 iEndpoints[0].iSettingChangeReceived = EFalse; |
659 iEndpoints[0].iEp->QueueRequests(); |
617 iEndpoints[0].iEp->QueueRequests(); |
660 |
618 |
691 |
649 |
692 void CActiveRW::QueueRequests() |
650 void CActiveRW::QueueRequests() |
693 { |
651 { |
694 DEBUGPRINT(test.Printf(_L("CActiveRW::QueueRequests() for Buffer number iBufNum %d AlternateSetting %d iDirection %d\n"), |
652 DEBUGPRINT(test.Printf(_L("CActiveRW::QueueRequests() for Buffer number iBufNum %d AlternateSetting %d iDirection %d\n"), |
695 iBuffer->iBufNum, iAltSetting->GetAlternateSetting(), iDirection)); |
653 iBuffer->iBufNum, iAltSetting->GetAlternateSetting(), iDirection)); |
696 DEBUGPRINT(OstTraceExt3(TRACE_NORMAL, CACTIVERW_QUEUEREQUESTS, "CActiveRW::QueueRequests() for Buffer number iBufNum %d AlternateSetting %d iDirection %d\n", |
|
697 iBuffer->iBufNum, iAltSetting->GetAlternateSetting(), iDirection)); |
|
698 if (!IsActive()) |
654 if (!IsActive()) |
699 { |
655 { |
700 if (iDirection != KUsbScHdrEpDirectionIn) |
656 if (iDirection != KUsbScHdrEpDirectionIn) |
701 { |
657 { |
702 TInt r = StartRead(); |
658 TInt r = StartRead(); |
711 } |
667 } |
712 |
668 |
713 void TAlternateSetting::SetChangeRequestFlag(CActiveRW *aEp) |
669 void TAlternateSetting::SetChangeRequestFlag(CActiveRW *aEp) |
714 { |
670 { |
715 DEBUGPRINT(test.Printf(_L("Set ChangeRequestFlag to True for Buffer Number = %d \n"), aEp->iBuffer->iBufNum)); |
671 DEBUGPRINT(test.Printf(_L("Set ChangeRequestFlag to True for Buffer Number = %d \n"), aEp->iBuffer->iBufNum)); |
716 DEBUGPRINT(OstTrace1(TRACE_NORMAL, TALTERNATESETTING_SETCHANGEREQUESTFLAG, "Set ChangeRequestFlag to True for Buffer Number = %d \n", aEp->iBuffer->iBufNum)); |
|
717 |
672 |
718 TInt countOfEndpoints = iEndpoints.Count(); |
673 TInt countOfEndpoints = iEndpoints.Count(); |
719 |
674 |
720 for(TInt count = 0; count < countOfEndpoints; count++) |
675 for(TInt count = 0; count < countOfEndpoints; count++) |
721 { |
676 { |
760 } |
715 } |
761 |
716 |
762 CActiveRW::~CActiveRW() |
717 CActiveRW::~CActiveRW() |
763 { |
718 { |
764 DEBUGPRINT(test.Printf(_L("CActiveRW::~CActiveRW\n"))); |
719 DEBUGPRINT(test.Printf(_L("CActiveRW::~CActiveRW\n"))); |
765 DEBUGPRINT(OstTrace0(TRACE_NORMAL, CACTIVERW_DCACTIVERW, "CActiveRW::~CActiveRW\n")); |
|
766 Cancel(); |
720 Cancel(); |
767 } |
721 } |
768 |
722 |
769 void CActiveRW::DoCancel() |
723 void CActiveRW::DoCancel() |
770 { |
724 { |
771 DEBUGPRINT(test.Printf(_L("CActiveRW::DoCancel for Buffer number iBufNum %d AlternateSetting %d\n"), |
725 DEBUGPRINT(test.Printf(_L("CActiveRW::DoCancel for Buffer number iBufNum %d AlternateSetting %d\n"), |
772 iBuffer->iBufNum, iAltSetting->GetAlternateSetting())); |
|
773 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, CACTIVERW_DOCANCEL, "CActiveRW::DoCancel for Buffer number iBufNum %d AlternateSetting %d\n", |
|
774 iBuffer->iBufNum, iAltSetting->GetAlternateSetting())); |
726 iBuffer->iBufNum, iAltSetting->GetAlternateSetting())); |
775 if (IsActive()) |
727 if (IsActive()) |
776 { |
728 { |
777 if (iDirection == KUsbScHdrEpDirectionOut) |
729 if (iDirection == KUsbScHdrEpDirectionOut) |
778 gPort.ReadCancel(iBuffer->iBufNum); |
730 gPort.ReadCancel(iBuffer->iBufNum); |
875 if (gRealHardware) |
827 if (gRealHardware) |
876 { |
828 { |
877 TUsbcScChunkHeader chunkHeader(gChunk); |
829 TUsbcScChunkHeader chunkHeader(gChunk); |
878 |
830 |
879 test.Printf(_L("\n \n Trying hardware\nPlease start the Host side application...\n")); |
831 test.Printf(_L("\n \n Trying hardware\nPlease start the Host side application...\n")); |
880 OstTrace0(TRACE_NORMAL, TESTBUFFERHANDLING_TESTBUFFERHANDLING, "\n \n Trying hardware\nPlease start the Host side application...\n"); |
|
881 |
832 |
882 TRequestStatus status; |
833 TRequestStatus status; |
883 gPort.ReEnumerate(status); |
834 gPort.ReEnumerate(status); |
884 User::WaitForRequest(status); |
835 User::WaitForRequest(status); |
885 |
836 |
886 TUsbcDeviceState device_state = EUsbcDeviceStateUndefined; |
837 TUsbcDeviceState device_state = EUsbcDeviceStateUndefined; |
887 TInt r = gPort.DeviceStatus(device_state); |
838 TInt r = gPort.DeviceStatus(device_state); |
888 if (r != KErrNone) |
839 if (r != KErrNone) |
889 { |
840 { |
890 test.Printf(_L("Error %d on querying device state"), r); |
841 test.Printf(_L("Error %d on querying device state"), r); |
891 OstTrace1(TRACE_NORMAL, TESTBUFFERHANDLING_TESTBUFFERHANDLING_DUP01, "Error %d on querying device state", r); |
|
892 } |
842 } |
893 else |
843 else |
894 { |
844 { |
895 DEBUGPRINT(test.Printf(_L("Current device state: %s \n"), |
845 DEBUGPRINT(test.Printf(_L("Current device state: %s \n"), |
896 (device_state == EUsbcDeviceStateUndefined) ? _S("Undefined") : |
846 (device_state == EUsbcDeviceStateUndefined) ? _S("Undefined") : |
899 ((device_state == EUsbcDeviceStateDefault) ? _S("Default") : |
849 ((device_state == EUsbcDeviceStateDefault) ? _S("Default") : |
900 ((device_state == EUsbcDeviceStateAddress) ? _S("Address") : |
850 ((device_state == EUsbcDeviceStateAddress) ? _S("Address") : |
901 ((device_state == EUsbcDeviceStateConfigured) ? _S("Configured") : |
851 ((device_state == EUsbcDeviceStateConfigured) ? _S("Configured") : |
902 ((device_state == EUsbcDeviceStateSuspended) ? _S("Suspended") : |
852 ((device_state == EUsbcDeviceStateSuspended) ? _S("Suspended") : |
903 _S("Unknown"))))))))); |
853 _S("Unknown"))))))))); |
904 DEBUGPRINT(OstTraceExt1(TRACE_NORMAL, TESTBUFFERHANDLING_TESTBUFFERHANDLING_DUP02, "Current device state: %s \n", |
|
905 (device_state == EUsbcDeviceStateUndefined) ? _L("Undefined") : |
|
906 ((device_state == EUsbcDeviceStateAttached) ? _L("Attached") : |
|
907 ((device_state == EUsbcDeviceStatePowered) ? _L("Powered") : |
|
908 ((device_state == EUsbcDeviceStateDefault) ? _L("Default") : |
|
909 ((device_state == EUsbcDeviceStateAddress) ? _L("Address") : |
|
910 ((device_state == EUsbcDeviceStateConfigured) ? _L("Configured") : |
|
911 ((device_state == EUsbcDeviceStateSuspended) ? _L("Suspended") : |
|
912 _L("Unknown"))))))))); |
|
913 } |
854 } |
914 |
855 |
915 CActiveScheduler* myScheduler = new (ELeave) CActiveScheduler(); |
856 CActiveScheduler* myScheduler = new (ELeave) CActiveScheduler(); |
916 CActiveScheduler::Install(myScheduler); |
857 CActiveScheduler::Install(myScheduler); |
917 |
858 |
963 for (TInt epNum = 1; epNum <= chunkHeader.GetNumberOfEndpoints(i); epNum++) |
904 for (TInt epNum = 1; epNum <= chunkHeader.GetNumberOfEndpoints(i); epNum++) |
964 { |
905 { |
965 TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(iEp[epNum * chunkHeader.iAltSettings->iEpRecordSize]); |
906 TUsbcScHdrEndpointRecord* endpointInf = (TUsbcScHdrEndpointRecord*) &(iEp[epNum * chunkHeader.iAltSettings->iEpRecordSize]); |
966 DEBUGPRINT(test.Printf(_L("Endpoint %d owns buffer %d BufferOffset 0x%x Dir %d Type %d\n"), epNum, endpointInf->iBufferNo, chunkHeader.iBuffers->Buffers(endpointInf->iBufferNo)->Offset(), |
907 DEBUGPRINT(test.Printf(_L("Endpoint %d owns buffer %d BufferOffset 0x%x Dir %d Type %d\n"), epNum, endpointInf->iBufferNo, chunkHeader.iBuffers->Buffers(endpointInf->iBufferNo)->Offset(), |
967 endpointInf->Direction(), endpointInf->Type())); |
908 endpointInf->Direction(), endpointInf->Type())); |
968 DEBUGPRINT(OstTraceExt5(TRACE_NORMAL, TESTBUFFERHANDLING_TESTBUFFERHANDLING_DUP03, "Endpoint %d owns buffer %d BufferOffset 0x%x Dir %d Type %d\n", epNum, endpointInf->iBufferNo, chunkHeader.iBuffers->Buffers(endpointInf->iBufferNo)->Offset(), |
|
969 endpointInf->Direction(), endpointInf->Type())); |
|
970 CActiveRW *EndpointRW = new CActiveRW(epNum, endpointInf->Direction(), bufferArray[endpointInf->iBufferNo]); |
909 CActiveRW *EndpointRW = new CActiveRW(epNum, endpointInf->Direction(), bufferArray[endpointInf->iBufferNo]); |
971 alternateSetting->AddEndpoint(*EndpointRW); |
910 alternateSetting->AddEndpoint(*EndpointRW); |
972 array[count++] = EndpointRW; |
911 array[count++] = EndpointRW; |
973 } |
912 } |
974 altSetArray[number++] = alternateSetting; |
913 altSetArray[number++] = alternateSetting; |
978 interface1->SetActiveAlternateSetting(0); |
917 interface1->SetActiveAlternateSetting(0); |
979 CActiveScheduler::Start(); |
918 CActiveScheduler::Start(); |
980 // User::After(2000000); |
919 // User::After(2000000); |
981 |
920 |
982 test.Printf(_L("Cleaning Up \n")); |
921 test.Printf(_L("Cleaning Up \n")); |
983 OstTrace0(TRACE_NORMAL, USER_AFTER, "Cleaning Up \n"); |
|
984 |
922 |
985 test.Printf(_L("Delete endpoint array \n")); |
923 test.Printf(_L("Delete endpoint array \n")); |
986 OstTrace0(TRACE_NORMAL, USER_AFTER_DUP01, "Delete endpoint array \n"); |
|
987 for(TInt i = 0; i < count; i++) |
924 for(TInt i = 0; i < count; i++) |
988 { |
925 { |
989 delete array[i]; |
926 delete array[i]; |
990 } |
927 } |
991 delete [] array; |
928 delete [] array; |
992 |
929 |
993 test.Printf(_L("Delete altset array \n")); |
930 test.Printf(_L("Delete altset array \n")); |
994 OstTrace0(TRACE_NORMAL, USER_AFTER_DUP02, "Delete altset array \n"); |
|
995 for (TInt i = 0; i < number; i++) |
931 for (TInt i = 0; i < number; i++) |
996 { |
932 { |
997 delete altSetArray[i]; |
933 delete altSetArray[i]; |
998 } |
934 } |
999 delete [] altSetArray; |
935 delete [] altSetArray; |
1000 |
936 |
1001 delete interface1; |
937 delete interface1; |
1002 |
938 |
1003 test.Printf(_L("Delete buffer array \n")); |
939 test.Printf(_L("Delete buffer array \n")); |
1004 OstTrace0(TRACE_NORMAL, USER_AFTER_DUP03, "Delete buffer array \n"); |
|
1005 for(TInt i = 0; i < chunkHeader.iBuffers->NumberOfBuffers(); i++) |
940 for(TInt i = 0; i < chunkHeader.iBuffers->NumberOfBuffers(); i++) |
1006 { |
941 { |
1007 delete bufferArray[i]; |
942 delete bufferArray[i]; |
1008 } |
943 } |
1009 test.Printf(_L("Delete buffer ep0 \n")); |
944 test.Printf(_L("Delete buffer ep0 \n")); |
1010 OstTrace0(TRACE_NORMAL, USER_AFTER_DUP04, "Delete buffer ep0 \n"); |
|
1011 delete bufferEp0; |
945 delete bufferEp0; |
1012 |
946 |
1013 delete myEndpointStateNotifier; |
947 delete myEndpointStateNotifier; |
1014 delete myDeviceStateNotifier; |
948 delete myDeviceStateNotifier; |
1015 delete myActiveConsole; |
949 delete myActiveConsole; |
1016 |
950 |
1017 __UHEAP_MARKEND; |
951 __UHEAP_MARKEND; |
1018 |
952 |
1019 test.Printf(_L("Uninstalling scheduler \n")); |
953 test.Printf(_L("Uninstalling scheduler \n")); |
1020 OstTrace0(TRACE_NORMAL, USER_AFTER_DUP05, "Uninstalling scheduler \n"); |
|
1021 |
954 |
1022 CActiveScheduler::Install(NULL); // Uninstalling the scheduler |
955 CActiveScheduler::Install(NULL); // Uninstalling the scheduler |
1023 delete myScheduler; |
956 delete myScheduler; |
1024 } |
957 } |
1025 delete altSetConfig; |
958 delete altSetConfig; |
1072 if (testString[strPos]==0) |
1005 if (testString[strPos]==0) |
1073 strPos=0; |
1006 strPos=0; |
1074 data[i]=testString[strPos]; |
1007 data[i]=testString[strPos]; |
1075 } |
1008 } |
1076 test.Printf(_L("Sending data.....")); |
1009 test.Printf(_L("Sending data.....")); |
1077 OstTrace0(TRACE_NORMAL, TBUFFER_SENDEP0PACKET, "Sending data....."); |
|
1078 // copy data into buffer TO DO |
1010 // copy data into buffer TO DO |
1079 gPort.WriteData(KUsbcScEndpointZero, iBufferOffset, aLength, 0, iEndpoint->iStatus); |
1011 gPort.WriteData(KUsbcScEndpointZero, iBufferOffset, aLength, 0, iEndpoint->iStatus); |
1080 User::WaitForRequest(iEndpoint->iStatus); |
1012 User::WaitForRequest(iEndpoint->iStatus); |
1081 test_KErrNone(iEndpoint->iStatus.Int()); |
1013 test_KErrNone(iEndpoint->iStatus.Int()); |
1082 test.Printf(_L("Sent!\n")); |
1014 test.Printf(_L("Sent!\n")); |
1083 OstTrace0(TRACE_NORMAL, TBUFFER_SENDEP0PACKET_DUP01, "Sent!\n"); |
|
1084 } |
1015 } |
1085 |
1016 |
1086 _LIT(KUndefined,"Undefined"); _LIT(KAttached,"KAttached"); _LIT(KPowered,"KPowered"); _LIT(KDefault,"Default"); |
1017 _LIT(KUndefined,"Undefined"); _LIT(KAttached,"KAttached"); _LIT(KPowered,"KPowered"); _LIT(KDefault,"Default"); |
1087 _LIT(KAddress,"Address"); _LIT(KConfigured,"Configured"); _LIT(KSuspended,"Suspended"); _LIT(KOther," <?> "); |
1018 _LIT(KAddress,"Address"); _LIT(KConfigured,"Configured"); _LIT(KSuspended,"Suspended"); _LIT(KOther," <?> "); |
1088 const TDesC* const KStates[8] = {&KUndefined,&KAttached,&KPowered,&KDefault,&KAddress,&KConfigured,&KSuspended,&KOther}; |
1019 const TDesC* const KStates[8] = {&KUndefined,&KAttached,&KPowered,&KDefault,&KAddress,&KConfigured,&KSuspended,&KOther}; |
1089 |
1020 |
1090 void TBuffer::SetUpHeader() |
1021 void TBuffer::SetUpHeader() |
1091 { |
1022 { |
1092 DEBUGPRINT(test.Printf(_L("CActiveRW::SetUpHeader() for Buffer %d belonging to Endpoint %d in Alternate Setting %d \n"), |
1023 DEBUGPRINT(test.Printf(_L("CActiveRW::SetUpHeader() for Buffer %d belonging to Endpoint %d in Alternate Setting %d \n"), |
1093 iBufNum, iEndpoint->GetEndpointNumber(), iEndpoint->GetAlternateSettingOfEndpoint())); |
|
1094 DEBUGPRINT(OstTraceExt3(TRACE_NORMAL, TBUFFER_SETUPHEADER, "CActiveRW::SetUpHeader() for Buffer %d belonging to Endpoint %d in Alternate Setting %d \n", |
|
1095 iBufNum, iEndpoint->GetEndpointNumber(), iEndpoint->GetAlternateSettingOfEndpoint())); |
1024 iBufNum, iEndpoint->GetEndpointNumber(), iEndpoint->GetAlternateSettingOfEndpoint())); |
1096 TUsbcScChunkHeader chunkHeader(gChunk); |
1025 TUsbcScChunkHeader chunkHeader(gChunk); |
1097 TUsbcScHdrEndpointRecord* epInfo; |
1026 TUsbcScHdrEndpointRecord* epInfo; |
1098 |
1027 |
1099 #if _DEBUG |
1028 #if _DEBUG |
1111 // To check instance of Alternate Setting Sequence Number |
1040 // To check instance of Alternate Setting Sequence Number |
1112 iTransfer = (TUsbcScTransferHeader*) (iHeader->iTail + iBase); |
1041 iTransfer = (TUsbcScTransferHeader*) (iHeader->iTail + iBase); |
1113 |
1042 |
1114 iMaxBufferSize = chunkHeader.iBuffers->Ep0Out()->Size(); |
1043 iMaxBufferSize = chunkHeader.iBuffers->Ep0Out()->Size(); |
1115 DEBUGPRINT(test.Printf(_L("MaxBufferSize %d \n"), iMaxBufferSize)); |
1044 DEBUGPRINT(test.Printf(_L("MaxBufferSize %d \n"), iMaxBufferSize)); |
1116 DEBUGPRINT(OstTrace1(TRACE_NORMAL, TBUFFER_SETUPHEADER_DUP01, "MaxBufferSize %d \n", iMaxBufferSize)); |
|
1117 |
1045 |
1118 TUint ep0MaxPacketSize = gPort.EndpointZeroMaxPacketSizes(); |
1046 TUint ep0MaxPacketSize = gPort.EndpointZeroMaxPacketSizes(); |
1119 DEBUGPRINT(test.Printf(_L("ep0 Max Packet Size = %d\n"), ep0MaxPacketSize)); |
1047 DEBUGPRINT(test.Printf(_L("ep0 Max Packet Size = %d\n"), ep0MaxPacketSize)); |
1120 DEBUGPRINT(OstTrace1(TRACE_NORMAL, TBUFFER_SETUPHEADER_DUP02, "ep0 Max Packet Size = %d\n", ep0MaxPacketSize)); |
|
1121 |
1048 |
1122 iMaxPacketSize = (ep0MaxPacketSize == KUsbEpSize64) ? 64 : |
1049 iMaxPacketSize = (ep0MaxPacketSize == KUsbEpSize64) ? 64 : |
1123 ((ep0MaxPacketSize == KUsbEpSize32) ? 32 : |
1050 ((ep0MaxPacketSize == KUsbEpSize32) ? 32 : |
1124 ((ep0MaxPacketSize == KUsbEpSize16) ? 16 : |
1051 ((ep0MaxPacketSize == KUsbEpSize16) ? 16 : |
1125 ((ep0MaxPacketSize == KUsbEpSize8) ? 8 : 0))); |
1052 ((ep0MaxPacketSize == KUsbEpSize8) ? 8 : 0))); |
1126 |
1053 |
1127 test_Compare(iMaxPacketSize,>,0); |
1054 test_Compare(iMaxPacketSize,>,0); |
1128 if (gSpecTest == EEp0) |
1055 if (gSpecTest == EEp0) |
1129 { |
|
1130 test.Printf(_L("Writing from buffer %d \n On host side, on the Class or Vendor Request Tab, send a Vendor request from an Interface on Device-to-Host or Host-to-Device(to an Interface) \n\n"), iBufNum); |
1056 test.Printf(_L("Writing from buffer %d \n On host side, on the Class or Vendor Request Tab, send a Vendor request from an Interface on Device-to-Host or Host-to-Device(to an Interface) \n\n"), iBufNum); |
1131 OstTrace1(TRACE_NORMAL, TBUFFER_SETUPHEADER_DUP03, "Writing from buffer %d \n On host side, on the Class or Vendor Request Tab, send a Vendor request from an Interface on Device-to-Host or Host-to-Device(to an Interface) \n\n", iBufNum); |
|
1132 } |
|
1133 iEndpoint->QueueRequests(); |
1057 iEndpoint->QueueRequests(); |
1134 } |
1058 } |
1135 } |
1059 } |
1136 else |
1060 else |
1137 { |
1061 { |
1141 r = gPort.GetEndpointDescriptor(iEndpoint->GetAlternateSettingOfEndpoint(), iEndpoint->GetEndpointNumber(), endpointSizeDescriptor); |
1065 r = gPort.GetEndpointDescriptor(iEndpoint->GetAlternateSettingOfEndpoint(), iEndpoint->GetEndpointNumber(), endpointSizeDescriptor); |
1142 test_KErrNone(r); |
1066 test_KErrNone(r); |
1143 iMaxPacketSize = EpSize(endpointSizeDescriptor[KEpDesc_PacketSizeOffset], endpointSizeDescriptor[KEpDesc_PacketSizeOffset+1]); |
1067 iMaxPacketSize = EpSize(endpointSizeDescriptor[KEpDesc_PacketSizeOffset], endpointSizeDescriptor[KEpDesc_PacketSizeOffset+1]); |
1144 test_Compare(iMaxPacketSize,>,0); |
1068 test_Compare(iMaxPacketSize,>,0); |
1145 DEBUGPRINT(test.Printf(_L("Endpoint %d Max Packet Size = %d\n"), iEndpoint->GetEndpointNumber(), iMaxPacketSize)); |
1069 DEBUGPRINT(test.Printf(_L("Endpoint %d Max Packet Size = %d\n"), iEndpoint->GetEndpointNumber(), iMaxPacketSize)); |
1146 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TBUFFER_SETUPHEADER_DUP04, "Endpoint %d Max Packet Size = %d\n", iEndpoint->GetEndpointNumber(), iMaxPacketSize)); |
|
1147 |
1070 |
1148 if (iEndpoint->GetDirection() == KUsbScHdrEpDirectionOut) |
1071 if (iEndpoint->GetDirection() == KUsbScHdrEpDirectionOut) |
1149 { |
1072 { |
1150 if ((gSpecTest == EBufRead) || (gSpecTest == EAltSet)) |
1073 if ((gSpecTest == EBufRead) || (gSpecTest == EAltSet)) |
1151 { |
1074 { |
1155 // To check instance of Alternate Setting Sequence Number |
1078 // To check instance of Alternate Setting Sequence Number |
1156 iTransfer = (TUsbcScTransferHeader*) (iHeader->iTail + iBase); |
1079 iTransfer = (TUsbcScTransferHeader*) (iHeader->iTail + iBase); |
1157 iMaxBufferSize = buff->Size(); |
1080 iMaxBufferSize = buff->Size(); |
1158 |
1081 |
1159 if (gSpecTest == EBufRead) |
1082 if (gSpecTest == EBufRead) |
1160 { |
|
1161 test.Printf(_L("Reading from buffer %d \n On host side, on the Pipes Tab, please select endpoint %d and read from a file and send to pipe\n"), iBufNum, iEndpoint->GetEndpointNumber()); |
1083 test.Printf(_L("Reading from buffer %d \n On host side, on the Pipes Tab, please select endpoint %d and read from a file and send to pipe\n"), iBufNum, iEndpoint->GetEndpointNumber()); |
1162 OstTraceExt2(TRACE_NORMAL, TBUFFER_SETUPHEADER_DUP05, "Reading from buffer %d \n On host side, on the Pipes Tab, please select endpoint %d and read from a file and send to pipe\n", iBufNum, iEndpoint->GetEndpointNumber()); |
|
1163 } |
|
1164 iEndpoint->QueueRequests(); |
1084 iEndpoint->QueueRequests(); |
1165 } |
1085 } |
1166 } |
1086 } |
1167 |
1087 |
1168 if (iEndpoint->GetDirection() == KUsbScHdrEpDirectionIn) |
1088 if (iEndpoint->GetDirection() == KUsbScHdrEpDirectionIn) |
1185 strPos=0; |
1105 strPos=0; |
1186 buffer[i]=testString[strPos]; |
1106 buffer[i]=testString[strPos]; |
1187 } |
1107 } |
1188 buffer[iLength-1] = '$'; |
1108 buffer[iLength-1] = '$'; |
1189 if (gSpecTest == EBufWrite) |
1109 if (gSpecTest == EBufWrite) |
1190 { |
|
1191 test.Printf(_L("Writing from buffer %d \n On host side, on the Pipes Tab, please select endpoint %d and read from pipe and write to file \n"), iBufNum, iEndpoint->GetEndpointNumber()); |
1110 test.Printf(_L("Writing from buffer %d \n On host side, on the Pipes Tab, please select endpoint %d and read from pipe and write to file \n"), iBufNum, iEndpoint->GetEndpointNumber()); |
1192 OstTraceExt2(TRACE_NORMAL, TBUFFER_SETUPHEADER_DUP06, "Writing from buffer %d \n On host side, on the Pipes Tab, please select endpoint %d and read from pipe and write to file \n", iBufNum, iEndpoint->GetEndpointNumber()); |
|
1193 } |
|
1194 iEndpoint->QueueRequests(); |
1111 iEndpoint->QueueRequests(); |
1195 } |
1112 } |
1196 } |
1113 } |
1197 } |
1114 } |
1198 } |
1115 } |
1213 } |
1130 } |
1214 |
1131 |
1215 void CActiveRW::RunL() |
1132 void CActiveRW::RunL() |
1216 { |
1133 { |
1217 DEBUGPRINT(test.Printf(_L("CActiveRW::RunL for Buffer number iBufNum %d AlternateSetting %d iDirection %d\n"), |
1134 DEBUGPRINT(test.Printf(_L("CActiveRW::RunL for Buffer number iBufNum %d AlternateSetting %d iDirection %d\n"), |
1218 iBuffer->iBufNum, iAltSetting->GetAlternateSetting(), iDirection)); |
|
1219 DEBUGPRINT(OstTraceExt3(TRACE_NORMAL, CACTIVERW_RUNL, "CActiveRW::RunL for Buffer number iBufNum %d AlternateSetting %d iDirection %d\n", |
|
1220 iBuffer->iBufNum, iAltSetting->GetAlternateSetting(), iDirection)); |
1135 iBuffer->iBufNum, iAltSetting->GetAlternateSetting(), iDirection)); |
1221 test_Compare(IsActive(), ==, EFalse); |
1136 test_Compare(IsActive(), ==, EFalse); |
1222 if ((iLogicalEndpointNum == 0) || (iDirection == KUsbScHdrEpDirectionOut)) //RunL for ReadData |
1137 if ((iLogicalEndpointNum == 0) || (iDirection == KUsbScHdrEpDirectionOut)) //RunL for ReadData |
1223 { |
1138 { |
1224 TInt r = 0; |
1139 TInt r = 0; |
1251 else // RunL for WriteData |
1166 else // RunL for WriteData |
1252 { |
1167 { |
1253 if (iStatus.Int() != KErrCancel) |
1168 if (iStatus.Int() != KErrCancel) |
1254 { |
1169 { |
1255 test.Printf(_L("%c"), sym[iBuffer->iBufNum]); |
1170 test.Printf(_L("%c"), sym[iBuffer->iBufNum]); |
1256 OstTraceExt1(TRACE_NORMAL, CACTIVERW_RUNL_DUP01, "%c", sym[iBuffer->iBufNum]); |
|
1257 StartWrite(); |
1171 StartWrite(); |
1258 } |
1172 } |
1259 } |
1173 } |
1260 } |
1174 } |
1261 |
1175 |
1263 { |
1177 { |
1264 test_Compare(iOldTail, != , iHeader->iTail); // Should progress every time arroud the loop. |
1178 test_Compare(iOldTail, != , iHeader->iTail); // Should progress every time arroud the loop. |
1265 iOldTail = iHeader->iTail; |
1179 iOldTail = iHeader->iTail; |
1266 |
1180 |
1267 DEBUGPRINT(test.Printf(_L("iHeader->iTail 0x%x, iHeader->iHead 0x%x \n"), iHeader->iTail, iHeader->iHead)); |
1181 DEBUGPRINT(test.Printf(_L("iHeader->iTail 0x%x, iHeader->iHead 0x%x \n"), iHeader->iTail, iHeader->iHead)); |
1268 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TBUFFER_PROCESSDATA, "iHeader->iTail 0x%x, iHeader->iHead 0x%x \n", iHeader->iTail, iHeader->iHead)); |
|
1269 if (iHeader->iTail == iHeader->iHead) |
1182 if (iHeader->iTail == iHeader->iHead) |
1270 { |
1183 { |
1271 test.Printf(_L("No data after available, but returned. iHead 0x%x \n"),iHeader->iHead); |
1184 test.Printf(_L("No data after available, but returned. iHead 0x%x \n"),iHeader->iHead); |
1272 OstTrace1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP01, "No data after available, but returned. iHead 0x%x \n",iHeader->iHead); |
|
1273 test(0); |
1185 test(0); |
1274 } |
1186 } |
1275 |
1187 |
1276 iTransfer = (TUsbcScTransferHeader*) (iHeader->iTail + iBase); |
1188 iTransfer = (TUsbcScTransferHeader*) (iHeader->iTail + iBase); |
1277 |
1189 |
1283 if (iEp0Phase==EDataIn) |
1195 if (iEp0Phase==EDataIn) |
1284 { |
1196 { |
1285 iEp0Phase=EReady; |
1197 iEp0Phase=EReady; |
1286 gPort.SendEp0StatusPacket(); |
1198 gPort.SendEp0StatusPacket(); |
1287 if (iTransfer->iBytes) {test.Printf(_L("EP0 Data: "));} |
1199 if (iTransfer->iBytes) {test.Printf(_L("EP0 Data: "));} |
1288 if (iTransfer->iBytes) {OstTrace0(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP02, "EP0 Data: ");} |
|
1289 for (TUint ii=0; ii<iTransfer->iBytes; ii++) |
1200 for (TUint ii=0; ii<iTransfer->iBytes; ii++) |
1290 { |
|
1291 test.Printf(_L(" 0x%2x "),iTransfer->iData.b[ii]); |
1201 test.Printf(_L(" 0x%2x "),iTransfer->iData.b[ii]); |
1292 OstTrace1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP03, " 0x%2x ",iTransfer->iData.b[ii]); |
|
1293 } |
|
1294 test.Printf(_L("\n\n")); |
1202 test.Printf(_L("\n\n")); |
1295 OstTrace0(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP04, "\n\n"); |
|
1296 } |
1203 } |
1297 else |
1204 else |
1298 { |
1205 { |
1299 if (iTransfer->iFlags&KUsbcScStateChange) |
1206 if (iTransfer->iFlags&KUsbcScStateChange) |
1300 { |
1207 { |
1301 TInt s = *iTransfer->iData.i; |
1208 TInt s = *iTransfer->iData.i; |
1302 test.Printf(_L("STATE CHANGE! %d : %S \n"),s,((s<0) || (s>7))?KStates[8]:KStates[s]); |
1209 test.Printf(_L("STATE CHANGE! %d : %S \n"),s,((s<0) || (s>7))?KStates[8]:KStates[s]); |
1303 OstTraceExt2(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP05, "STATE CHANGE! %d : %S \n",s,((s<0) || (s>7))?(*KStates[8]):(*KStates[s])); |
|
1304 } |
1210 } |
1305 else |
1211 else |
1306 { |
1212 { |
1307 iSetup = (Sep0SetupPacket* ) iTransfer->iData.b; |
1213 iSetup = (Sep0SetupPacket* ) iTransfer->iData.b; |
1308 test.Printf(_L("EP0 Command: t %x r %x v %x i %x l %x :"), iSetup->iRequestType, iSetup->iRequest, iSetup->iwValue, iSetup->iwIndex, iSetup->iWlength); |
1214 test.Printf(_L("EP0 Command: t %x r %x v %x i %x l %x :"), iSetup->iRequestType, iSetup->iRequest, iSetup->iwValue, iSetup->iwIndex, iSetup->iWlength); |
1309 OstTraceExt5(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP06, "EP0 Command: t %x r %x v %x i %x l %x :", iSetup->iRequestType, iSetup->iRequest, iSetup->iwValue, iSetup->iwIndex, iSetup->iWlength); |
|
1310 if ((iSetup->iRequestType&KDeviceToHost))// && (iSetup->iWlength>0)) //Temp To do remove |
1215 if ((iSetup->iRequestType&KDeviceToHost))// && (iSetup->iWlength>0)) //Temp To do remove |
1311 { |
1216 { |
1312 test.Printf(_L("EP0 Command: Device to Host\n")); |
1217 test.Printf(_L("EP0 Command: Device to Host\n")); |
1313 OstTrace0(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP07, "EP0 Command: Device to Host\n"); |
|
1314 SendEP0Packet(iSetup->iWlength); |
1218 SendEP0Packet(iSetup->iWlength); |
1315 } |
1219 } |
1316 else |
1220 else |
1317 { |
1221 { |
1318 test.Printf(_L("EP0 Command: Host to Device. 0x%x bytes\n"), iSetup->iWlength); |
1222 test.Printf(_L("EP0 Command: Host to Device. 0x%x bytes\n"), iSetup->iWlength); |
1319 OstTrace1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP08, "EP0 Command: Host to Device. 0x%x bytes\n", iSetup->iWlength); |
|
1320 iEp0Phase=EDataIn; |
1223 iEp0Phase=EDataIn; |
1321 } |
1224 } |
1322 } |
1225 } |
1323 } // end EP0 phase |
1226 } // end EP0 phase |
1324 } // iLogicalEndpointNum = 0 |
1227 } // iLogicalEndpointNum = 0 |
1325 else // else, its not ep0 |
1228 else // else, its not ep0 |
1326 { |
1229 { |
1327 if ((++iTickCount)>100) |
1230 if ((++iTickCount)>100) |
1328 { |
1231 { |
1329 test.Printf(_L("%c"), sym[iBufNum]); |
1232 test.Printf(_L("%c"), sym[iBufNum]); |
1330 OstTraceExt1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP09, "%c", sym[iBufNum]); |
|
1331 iTickCount=0; |
1233 iTickCount=0; |
1332 } |
1234 } |
1333 } |
1235 } |
1334 } // end if data |
1236 } // end if data |
1335 else |
1237 else |
1336 { |
1238 { |
1337 test.Printf(_L("Empty Transfer received for buffer Num = %d as = %d\n"), iBufNum, iTransfer->iAltSetting); |
1239 test.Printf(_L("Empty Transfer received for buffer Num = %d as = %d\n"), iBufNum, iTransfer->iAltSetting); |
1338 OstTraceExt2(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP10, "Empty Transfer received for buffer Num = %d as = %d\n", iBufNum, iTransfer->iAltSetting); |
|
1339 if (iPrevAltSeq >= iTransfer->iAltSettingSeq) |
1240 if (iPrevAltSeq >= iTransfer->iAltSettingSeq) |
1340 { |
1241 { |
1341 test.Printf(_L("Empty Transfer *WAS NOT* an alt setting change!\n")); |
1242 test.Printf(_L("Empty Transfer *WAS NOT* an alt setting change!\n")); |
1342 OstTrace0(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP11, "Empty Transfer *WAS NOT* an alt setting change!\n"); |
|
1343 iPrevAltSeq = iTransfer->iAltSettingSeq; |
1243 iPrevAltSeq = iTransfer->iAltSettingSeq; |
1344 } |
1244 } |
1345 } |
1245 } |
1346 |
1246 |
1347 //Checking Transfer Header contents |
1247 //Checking Transfer Header contents |
1348 //Checking if Alternate Setting has changed |
1248 //Checking if Alternate Setting has changed |
1349 if ((iTransfer->iBytes == 0) && (iEndpoint->GetInterfaceAltSettingChangeSequenceNum() != iTransfer->iAltSettingSeq)) |
1249 if ((iTransfer->iBytes == 0) && (iEndpoint->GetInterfaceAltSettingChangeSequenceNum() != iTransfer->iAltSettingSeq)) |
1350 { |
1250 { |
1351 DEBUGPRINT(test.Printf(_L("Current Alternate Setting of Endpoint = %d iTransfer->iAltSetting = %d iTransfer->iAltSettingSeq = %d \n"), |
1251 DEBUGPRINT(test.Printf(_L("Current Alternate Setting of Endpoint = %d iTransfer->iAltSetting = %d iTransfer->iAltSettingSeq = %d \n"), |
1352 iEndpoint->GetAlternateSettingOfEndpoint(), iTransfer->iAltSetting, iTransfer->iAltSettingSeq)); |
1252 iEndpoint->GetAlternateSettingOfEndpoint(), iTransfer->iAltSetting, iTransfer->iAltSettingSeq)); |
1353 DEBUGPRINT(OstTraceExt3(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP12, "Current Alternate Setting of Endpoint = %d iTransfer->iAltSetting = %d iTransfer->iAltSettingSeq = %d \n", |
|
1354 iEndpoint->GetAlternateSettingOfEndpoint(), iTransfer->iAltSetting, iTransfer->iAltSettingSeq)); |
|
1355 test.Printf(_L("Empty Transfer received for buffer Num = %d \n"), iBufNum); |
1253 test.Printf(_L("Empty Transfer received for buffer Num = %d \n"), iBufNum); |
1356 OstTrace1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP13, "Empty Transfer received for buffer Num = %d \n", iBufNum); |
|
1357 test_Compare(iEndpoint->GetInterfaceAltSettingChangeSequenceNum(), +1== , iTransfer->iAltSettingSeq); |
1254 test_Compare(iEndpoint->GetInterfaceAltSettingChangeSequenceNum(), +1== , iTransfer->iAltSettingSeq); |
1358 |
1255 |
1359 |
1256 |
1360 #if _DEBUG |
1257 #if _DEBUG |
1361 // checking Sequence Numbers are in order i.e. One more than previous, Should enter this loop only the first time the buffer is ever used |
1258 // checking Sequence Numbers are in order i.e. One more than previous, Should enter this loop only the first time the buffer is ever used |
1377 iEndpoint->SetChangeRequestFlag(this); |
1274 iEndpoint->SetChangeRequestFlag(this); |
1378 |
1275 |
1379 //Function checks if alternate setting change request flag for all endpoints of this Alternate Setting is set to true |
1276 //Function checks if alternate setting change request flag for all endpoints of this Alternate Setting is set to true |
1380 TBool settingRequestReceivedForAllEps = iEndpoint->CheckFlagForAllOutEndpoints(); |
1277 TBool settingRequestReceivedForAllEps = iEndpoint->CheckFlagForAllOutEndpoints(); |
1381 DEBUGPRINT(test.Printf(_L("SettingRequestReceivedForAllEps = %d \n"),settingRequestReceivedForAllEps)); |
1278 DEBUGPRINT(test.Printf(_L("SettingRequestReceivedForAllEps = %d \n"),settingRequestReceivedForAllEps)); |
1382 DEBUGPRINT(OstTrace1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP14, "SettingRequestReceivedForAllEps = %d \n",settingRequestReceivedForAllEps)); |
|
1383 if(settingRequestReceivedForAllEps) |
1279 if(settingRequestReceivedForAllEps) |
1384 { |
1280 { |
1385 // change alternative setting |
1281 // change alternative setting |
1386 test.Printf(_L("AS!\n")); |
1282 test.Printf(_L("AS!\n")); |
1387 OstTrace0(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP15, "AS!\n"); |
|
1388 iEndpoint->CallChangeAlternateSetting(iTransfer->iAltSetting); |
1283 iEndpoint->CallChangeAlternateSetting(iTransfer->iAltSetting); |
1389 } |
1284 } |
1390 } |
1285 } |
1391 else |
1286 else |
1392 { |
1287 { |
1399 } |
1294 } |
1400 else |
1295 else |
1401 { |
1296 { |
1402 test_Compare((TInt) (iTransfer->iNext), >=, startOfBuf ); |
1297 test_Compare((TInt) (iTransfer->iNext), >=, startOfBuf ); |
1403 DEBUGPRINT(test.Printf(_L("Endpoint Buffer of size %d is filled. Next transfer from Start of Buffer \n"), iMaxBufferSize)); |
1298 DEBUGPRINT(test.Printf(_L("Endpoint Buffer of size %d is filled. Next transfer from Start of Buffer \n"), iMaxBufferSize)); |
1404 DEBUGPRINT(OstTrace1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP16, "Endpoint Buffer of size %d is filled. Next transfer from Start of Buffer \n", iMaxBufferSize)); |
|
1405 } |
1299 } |
1406 |
1300 |
1407 //Checking that no data or information goes beyond the end address of the buffer |
1301 //Checking that no data or information goes beyond the end address of the buffer |
1408 test_Compare(iTransfer->iNext + (TUint) iBase, <, (TUint) iHeader + iMaxBufferSize); |
1302 test_Compare(iTransfer->iNext + (TUint) iBase, <, (TUint) iHeader + iMaxBufferSize); |
1409 test_Compare(&(iTransfer->iData.b[iTransfer->iBytes - 1]), <=, (TUint) iHeader + iMaxBufferSize); |
1303 test_Compare(&(iTransfer->iData.b[iTransfer->iBytes - 1]), <=, (TUint) iHeader + iMaxBufferSize); |
1421 |
1315 |
1422 // Checking if first transfer greater than or equal to the lowest chunk offset a transfer can be |
1316 // Checking if first transfer greater than or equal to the lowest chunk offset a transfer can be |
1423 test_Compare(iHeader->iTail, >=, startOfBuf); |
1317 test_Compare(iHeader->iTail, >=, startOfBuf); |
1424 } |
1318 } |
1425 DEBUGPRINT(test.Printf(_L("Previous Sequence Number 0x%x Current Sequence Number 0x%x \n"), iPrevSequence, iTransfer->iSequence)); |
1319 DEBUGPRINT(test.Printf(_L("Previous Sequence Number 0x%x Current Sequence Number 0x%x \n"), iPrevSequence, iTransfer->iSequence)); |
1426 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP17, "Previous Sequence Number 0x%x Current Sequence Number 0x%x \n", iPrevSequence, iTransfer->iSequence)); |
|
1427 test_Compare((iTransfer->iSequence - iPrevSequence), ==, 1); |
1320 test_Compare((iTransfer->iSequence - iPrevSequence), ==, 1); |
1428 iPrevSequence = iTransfer->iSequence; |
1321 iPrevSequence = iTransfer->iSequence; |
1429 #endif |
1322 #endif |
1430 |
1323 |
1431 if (gVerbose) |
1324 if (gVerbose) |
1433 #if _DEBUG |
1326 #if _DEBUG |
1434 //Print transfer contents |
1327 //Print transfer contents |
1435 test.Printf(_L("Recieved packet Hash ID 0x%x Sequence Number 0x%x Bytes 0x%x Flags 0x%x Next 0x%x Alternate Setting Seq 0x%x Current Alternate Setting 0x%x \n"), |
1328 test.Printf(_L("Recieved packet Hash ID 0x%x Sequence Number 0x%x Bytes 0x%x Flags 0x%x Next 0x%x Alternate Setting Seq 0x%x Current Alternate Setting 0x%x \n"), |
1436 iTransfer->iHashId,iTransfer->iSequence, iTransfer->iBytes, iTransfer->iFlags, iTransfer->iNext, |
1329 iTransfer->iHashId,iTransfer->iSequence, iTransfer->iBytes, iTransfer->iFlags, iTransfer->iNext, |
1437 iTransfer->iAltSettingSeq, iTransfer->iAltSetting); |
1330 iTransfer->iAltSettingSeq, iTransfer->iAltSetting); |
1438 OstTraceExt5(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP18, "Recieved packet Hash ID 0x%x Sequence Number 0x%x Bytes 0x%x Flags 0x%x Next 0x%x ", |
|
1439 iTransfer->iHashId,iTransfer->iSequence, iTransfer->iBytes, iTransfer->iFlags, iTransfer->iNext); |
|
1440 OstTraceExt2(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP22, "Alternate Setting Seq 0x%x Current Alternate Setting 0x%x \n", |
|
1441 iTransfer->iAltSettingSeq, iTransfer->iAltSetting); |
|
1442 #else |
1331 #else |
1443 test.Printf(_L("Recieved packet Bytes 0x%x Flags 0x%x Next 0x%x Alternate Setting Seq 0x%x Current Alternate Setting 0x%x \n"), |
1332 test.Printf(_L("Recieved packet Bytes 0x%x Flags 0x%x Next 0x%x Alternate Setting Seq 0x%x Current Alternate Setting 0x%x \n"), |
1444 iTransfer->iBytes, iTransfer->iFlags, |
1333 iTransfer->iBytes, iTransfer->iFlags, |
1445 iTransfer->iNext, iTransfer->iAltSettingSeq, iTransfer->iAltSetting ); |
1334 iTransfer->iNext, iTransfer->iAltSettingSeq, iTransfer->iAltSetting ); |
1446 OstTraceExt5(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP19, "Recieved packet Bytes 0x%x Flags 0x%x Next 0x%x Alternate Setting Seq 0x%x Current Alternate Setting 0x%x \n", |
|
1447 iTransfer->iBytes, iTransfer->iFlags, |
|
1448 iTransfer->iNext, (TUint)iTransfer->iAltSettingSeq, (TUint)iTransfer->iAltSetting ); |
|
1449 #endif |
1335 #endif |
1450 if (gVerbose>1) |
1336 if (gVerbose>1) |
1451 { |
1337 { |
1452 for (TUint ii=0; ii<iTransfer->iBytes; ii++) |
1338 for (TUint ii=0; ii<iTransfer->iBytes; ii++) |
1453 { |
1339 { |
1454 test.Printf(_L(" %c "),iTransfer->iData.b[ii]); |
1340 test.Printf(_L(" %c "),iTransfer->iData.b[ii]); |
1455 OstTraceExt1(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP20, " %c ",iTransfer->iData.b[ii]); |
|
1456 } |
1341 } |
1457 test.Printf(_L("\n")); |
1342 test.Printf(_L("\n")); |
1458 OstTrace0(TRACE_NORMAL, TBUFFER_PROCESSDATA_DUP21, "\n"); |
|
1459 } |
1343 } |
1460 } // if verbose |
1344 } // if verbose |
1461 |
1345 |
1462 iBytesReceived += iTransfer->iBytes; |
1346 iBytesReceived += iTransfer->iBytes; |
1463 iHeader->iTail = iTransfer->iNext; |
1347 iHeader->iTail = iTransfer->iNext; |
1506 test_Equal(KErrUsbInterfaceNotReady, status.Int()); |
1390 test_Equal(KErrUsbInterfaceNotReady, status.Int()); |
1507 |
1391 |
1508 if (gRealHardware) |
1392 if (gRealHardware) |
1509 { |
1393 { |
1510 test.Printf(_L("\n\n Trying hardware\nPlease start the Host side application...\n")); |
1394 test.Printf(_L("\n\n Trying hardware\nPlease start the Host side application...\n")); |
1511 OstTrace0(TRACE_NORMAL, TESTCANCEL_TESTCANCEL, "\n\n Trying hardware\nPlease start the Host side application...\n"); |
|
1512 |
1395 |
1513 |
1396 |
1514 gPort.ReEnumerate(status); |
1397 gPort.ReEnumerate(status); |
1515 User::WaitForRequest(status); |
1398 User::WaitForRequest(status); |
1516 test.Printf(_L("Enumerated status = %d\n"), status.Int()); |
1399 test.Printf(_L("Enumerated status = %d\n"), status.Int()); |
1517 OstTrace1(TRACE_NORMAL, TESTCANCEL_TESTCANCEL_DUP01, "Enumerated status = %d\n", status.Int()); |
|
1518 |
1400 |
1519 test.Next(_L("ReadCancel Test after enumeration\n")); |
1401 test.Next(_L("ReadCancel Test after enumeration\n")); |
1520 do // Drain out all data in buffer first, then queue cancel |
1402 do // Drain out all data in buffer first, then queue cancel |
1521 { |
1403 { |
1522 r = gPort.ReadDataNotify(outBuffNum,status); |
1404 r = gPort.ReadDataNotify(outBuffNum,status); |
1523 DEBUGPRINT(test.Printf(_L("header->iTail 0x%x header->iHead 0x%x\n"), header->iTail, header->iHead)); |
1405 DEBUGPRINT(test.Printf(_L("header->iTail 0x%x header->iHead 0x%x\n"), header->iTail, header->iHead)); |
1524 DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TESTCANCEL_TESTCANCEL_DUP02, "header->iTail 0x%x header->iHead 0x%x\n", header->iTail, header->iHead)); |
|
1525 transfer = (TUsbcScTransferHeader*) (header->iTail + base); |
1406 transfer = (TUsbcScTransferHeader*) (header->iTail + base); |
1526 header->iTail = transfer->iNext; |
1407 header->iTail = transfer->iNext; |
1527 } |
1408 } |
1528 while (r != KErrNone); |
1409 while (r != KErrNone); |
1529 |
1410 |
1533 test_Equal(status.Int(), KErrCancel); |
1414 test_Equal(status.Int(), KErrCancel); |
1534 |
1415 |
1535 test.Next(_L("WriteCancel Test after enumeration\n")); |
1416 test.Next(_L("WriteCancel Test after enumeration\n")); |
1536 |
1417 |
1537 test.Printf(_L("Generating test data %x %d\n"), buffer, inBuffNum); |
1418 test.Printf(_L("Generating test data %x %d\n"), buffer, inBuffNum); |
1538 OstTraceExt2(TRACE_NORMAL, TESTCANCEL_TESTCANCEL_DUP03, "Generating test data %x %d\n", (TUint)buffer, inBuffNum); |
|
1539 for (TUint i=0; i<length; i++) |
1419 for (TUint i=0; i<length; i++) |
1540 { |
1420 { |
1541 buffer[i]=i; |
1421 buffer[i]=i; |
1542 } |
1422 } |
1543 buffer[length-1] = '$'; |
1423 buffer[length-1] = '$'; |
1612 TUint bufferOffset = buff->Offset(); |
1492 TUint bufferOffset = buff->Offset(); |
1613 TUint length = buff->Size(); |
1493 TUint length = buff->Size(); |
1614 |
1494 |
1615 // Testing with invalid buffer values |
1495 // Testing with invalid buffer values |
1616 test.Printf(_L("Test Buffer Writing with invalid buffer values\n")); |
1496 test.Printf(_L("Test Buffer Writing with invalid buffer values\n")); |
1617 OstTrace0(TRACE_NORMAL, TESTINVALIDAPI_TESTINVALIDAPI, "Test Buffer Writing with invalid buffer values\n"); |
|
1618 gPort.WriteData(out_buf, bufferOffset, length, 0, status); |
1497 gPort.WriteData(out_buf, bufferOffset, length, 0, status); |
1619 User::WaitForRequest(status); |
1498 User::WaitForRequest(status); |
1620 test_Compare(status.Int(), ==, KErrArgument); |
1499 test_Compare(status.Int(), ==, KErrArgument); |
1621 |
1500 |
1622 gPort.WriteData(KMaxEndpointsPerClient + 1, bufferOffset, length, 0, status); |
1501 gPort.WriteData(KMaxEndpointsPerClient + 1, bufferOffset, length, 0, status); |
1627 User::WaitForRequest(status); |
1506 User::WaitForRequest(status); |
1628 test_Compare(status.Int(), ==, KErrArgument); |
1507 test_Compare(status.Int(), ==, KErrArgument); |
1629 /* |
1508 /* |
1630 // Unaligned argument |
1509 // Unaligned argument |
1631 test.Printf(_L("Test Buffer Writing with invalid buffer offsets\n")); |
1510 test.Printf(_L("Test Buffer Writing with invalid buffer offsets\n")); |
1632 OstTrace0(TRACE_NORMAL, TESTINVALIDAPI_TESTINVALIDAPI_DUP01, "Test Buffer Writing with invalid buffer offsets\n"); |
|
1633 gPort.WriteData(in_buf, bufferOffset + sizeof(TUint), length, 0,status); |
1511 gPort.WriteData(in_buf, bufferOffset + sizeof(TUint), length, 0,status); |
1634 User::WaitForRequest(status); |
1512 User::WaitForRequest(status); |
1635 test_Compare(status.Int(), ==, KErrArgument); |
1513 test_Compare(status.Int(), ==, KErrArgument); |
1636 */ |
1514 */ |
1637 //Offset passed is greater than end offset |
1515 //Offset passed is greater than end offset |
1668 test_KErrNone(r); |
1546 test_KErrNone(r); |
1669 r = SettingOne(++altSetNo); |
1547 r = SettingOne(++altSetNo); |
1670 test_KErrNone(r); |
1548 test_KErrNone(r); |
1671 |
1549 |
1672 test.Printf(_L("Release Interface %d\n"), --altSetNo); |
1550 test.Printf(_L("Release Interface %d\n"), --altSetNo); |
1673 OstTrace1(TRACE_NORMAL, TESTSETINTERFACE_TESTSETINTERFACE, "Release Interface %d\n", --altSetNo); |
|
1674 r = gPort.ReleaseInterface(altSetNo); |
1551 r = gPort.ReleaseInterface(altSetNo); |
1675 test_Compare(r, !=, KErrNone); |
1552 test_Compare(r, !=, KErrNone); |
1676 |
1553 |
1677 test.Printf(_L("Release Interface %d\n"), ++altSetNo); |
1554 test.Printf(_L("Release Interface %d\n"), ++altSetNo); |
1678 OstTrace1(TRACE_NORMAL, TESTSETINTERFACE_TESTSETINTERFACE_DUP01, "Release Interface %d\n", ++altSetNo); |
|
1679 r = gPort.ReleaseInterface(altSetNo); |
1555 r = gPort.ReleaseInterface(altSetNo); |
1680 test_KErrNone(r); |
1556 test_KErrNone(r); |
1681 |
1557 |
1682 altSetConfig->iNumOfAltSet = 1; |
1558 altSetConfig->iNumOfAltSet = 1; |
1683 TEndpointDescription temp = {2,1,1}; |
1559 TEndpointDescription temp = {2,1,1}; |
1689 r = SettingOne(altSetNo); |
1565 r = SettingOne(altSetNo); |
1690 test_Compare(r, ==, KErrUsbAlreadyRealized); |
1566 test_Compare(r, ==, KErrUsbAlreadyRealized); |
1691 |
1567 |
1692 // Should not be allowed to release Interface once Chunk Realized |
1568 // Should not be allowed to release Interface once Chunk Realized |
1693 test.Printf(_L("Release Interface %d \n"), altSetNo); |
1569 test.Printf(_L("Release Interface %d \n"), altSetNo); |
1694 OstTrace1(TRACE_NORMAL, TESTSETINTERFACE_TESTSETINTERFACE_DUP02, "Release Interface %d \n", altSetNo); |
|
1695 r = gPort.ReleaseInterface(altSetNo); |
1570 r = gPort.ReleaseInterface(altSetNo); |
1696 test_Compare(r, ==, KErrUsbAlreadyRealized); |
1571 test_Compare(r, ==, KErrUsbAlreadyRealized); |
1697 CloseChannel(); |
1572 CloseChannel(); |
1698 UnloadDriver(); |
1573 UnloadDriver(); |
1699 |
1574 |
1761 |
1636 |
1762 altSetConfig->iNumOfAltSet = 1; |
1637 altSetConfig->iNumOfAltSet = 1; |
1763 altSetConfig->iEpsDesc[0] = temp; //{2,1,1}; |
1638 altSetConfig->iEpsDesc[0] = temp; //{2,1,1}; |
1764 |
1639 |
1765 test.Printf(_L("Check chunk still populated with one interface\n")); |
1640 test.Printf(_L("Check chunk still populated with one interface\n")); |
1766 OstTrace0(TRACE_NORMAL, TESTSETINTERFACE_TESTSETINTERFACE_DUP03, "Check chunk still populated with one interface\n"); |
|
1767 TestBufferConstruction(altSetConfig); |
1641 TestBufferConstruction(altSetConfig); |
1768 |
1642 |
1769 CloseChannel(); |
1643 CloseChannel(); |
1770 UnloadDriver(); |
1644 UnloadDriver(); |
1771 |
1645 |
1780 altSetNo++; |
1654 altSetNo++; |
1781 r = InvalidSettingTwo(altSetNo); |
1655 r = InvalidSettingTwo(altSetNo); |
1782 test_Compare(r, !=, KErrNone); |
1656 test_Compare(r, !=, KErrNone); |
1783 |
1657 |
1784 test.Printf(_L("Check chunk still populated with one interface \n")); |
1658 test.Printf(_L("Check chunk still populated with one interface \n")); |
1785 OstTrace0(TRACE_NORMAL, TESTSETINTERFACE_TESTSETINTERFACE_DUP04, "Check chunk still populated with one interface \n"); |
|
1786 TestBufferConstruction(altSetConfig); |
1659 TestBufferConstruction(altSetConfig); |
1787 |
1660 |
1788 CloseChannel(); |
1661 CloseChannel(); |
1789 UnloadDriver(); |
1662 UnloadDriver(); |
1790 |
1663 |
1798 altSetConfig->iNumOfAltSet = 0; |
1671 altSetConfig->iNumOfAltSet = 0; |
1799 TEndpointDescription temp2 = {0,0,0}; |
1672 TEndpointDescription temp2 = {0,0,0}; |
1800 altSetConfig->iEpsDesc[0] = temp2; //{0,0,0}; |
1673 altSetConfig->iEpsDesc[0] = temp2; //{0,0,0}; |
1801 |
1674 |
1802 test.Printf(_L("Check chunk not populated with any valid data as all interfaces would be destroyed \n")); |
1675 test.Printf(_L("Check chunk not populated with any valid data as all interfaces would be destroyed \n")); |
1803 OstTrace0(TRACE_NORMAL, TESTSETINTERFACE_TESTSETINTERFACE_DUP05, "Check chunk not populated with any valid data as all interfaces would be destroyed \n"); |
|
1804 TestBufferConstruction(altSetConfig); |
1676 TestBufferConstruction(altSetConfig); |
1805 |
1677 |
1806 CloseChannel(); |
1678 CloseChannel(); |
1807 UnloadDriver(); |
1679 UnloadDriver(); |
1808 test.Next(_L("Test Release Interface, No interface set but call Release interface and test Chunk construction \n")); |
1680 test.Next(_L("Test Release Interface, No interface set but call Release interface and test Chunk construction \n")); |
1857 |
1729 |
1858 // Global variable - we'll need this value later. |
1730 // Global variable - we'll need this value later. |
1859 gSupportsHighSpeed = d_caps().iHighSpeed; |
1731 gSupportsHighSpeed = d_caps().iHighSpeed; |
1860 |
1732 |
1861 test.Printf(_L("USB device capabilities:\n")); |
1733 test.Printf(_L("USB device capabilities:\n")); |
1862 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES, "USB device capabilities:\n"); |
|
1863 test.Printf(_L("Number of endpoints: %d\n"), numOfEndPoints); |
1734 test.Printf(_L("Number of endpoints: %d\n"), numOfEndPoints); |
1864 OstTrace1(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP01, "Number of endpoints: %d\n", numOfEndPoints); |
|
1865 test.Printf(_L("Supports Software-Connect: %s\n"), |
1735 test.Printf(_L("Supports Software-Connect: %s\n"), |
1866 d_caps().iConnect ? _S("yes") : _S("no")); |
1736 d_caps().iConnect ? _S("yes") : _S("no")); |
1867 OstTraceExt1(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP02, "Supports Software-Connect: %s\n", |
|
1868 d_caps().iConnect ? _L("yes") : _L("no")); |
|
1869 test.Printf(_L("Device is Self-Powered: %s\n"), |
1737 test.Printf(_L("Device is Self-Powered: %s\n"), |
1870 d_caps().iSelfPowered ? _S("yes") : _S("no")); |
1738 d_caps().iSelfPowered ? _S("yes") : _S("no")); |
1871 OstTraceExt1(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP03, "Device is Self-Powered: %s\n", |
|
1872 d_caps().iSelfPowered ? _L("yes") : _L("no")); |
|
1873 test.Printf(_L("Supports Remote-Wakeup: %s\n"), |
1739 test.Printf(_L("Supports Remote-Wakeup: %s\n"), |
1874 d_caps().iRemoteWakeup ? _S("yes") : _S("no")); |
1740 d_caps().iRemoteWakeup ? _S("yes") : _S("no")); |
1875 OstTraceExt1(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP04, "Supports Remote-Wakeup: %s\n", |
|
1876 d_caps().iRemoteWakeup ? _L("yes") : _L("no")); |
|
1877 test.Printf(_L("Supports High-speed: %s\n"), |
1741 test.Printf(_L("Supports High-speed: %s\n"), |
1878 gSupportsHighSpeed ? _S("yes") : _S("no")); |
1742 gSupportsHighSpeed ? _S("yes") : _S("no")); |
1879 OstTraceExt1(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP05, "Supports High-speed: %s\n", |
|
1880 gSupportsHighSpeed ? _L("yes") : _L("no")); |
|
1881 test.Printf(_L("Supports unpowered cable detection: %s\n"), |
1743 test.Printf(_L("Supports unpowered cable detection: %s\n"), |
1882 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
1744 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
1883 _S("yes") : _S("no")); |
1745 _S("yes") : _S("no")); |
1884 OstTraceExt1(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP06, "Supports unpowered cable detection: %s\n", |
|
1885 (d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ? |
|
1886 _L("yes") : _L("no")); |
|
1887 |
1746 |
1888 test_Compare(numOfEndPoints, >=, 2); |
1747 test_Compare(numOfEndPoints, >=, 2); |
1889 test.Printf(_L("(Device has sufficient endpoints.)\n")); |
1748 test.Printf(_L("(Device has sufficient endpoints.)\n")); |
1890 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP07, "(Device has sufficient endpoints.)\n"); |
|
1891 |
1749 |
1892 // Endpoint caps |
1750 // Endpoint caps |
1893 test.Next(_L("Query USB endpoint caps")); |
1751 test.Next(_L("Query USB endpoint caps")); |
1894 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
1752 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
1895 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
1753 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
1896 r = gPort.EndpointCaps(dataptr); |
1754 r = gPort.EndpointCaps(dataptr); |
1897 test_KErrNone(r); |
1755 test_KErrNone(r); |
1898 |
1756 |
1899 test.Printf(_L("USB device endpoint capabilities:\n")); |
1757 test.Printf(_L("USB device endpoint capabilities:\n")); |
1900 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP08, "USB device endpoint capabilities:\n"); |
|
1901 |
1758 |
1902 TInt dir; |
1759 TInt dir; |
1903 for (TInt i = 0; i < numOfEndPoints; i++) |
1760 for (TInt i = 0; i < numOfEndPoints; i++) |
1904 { |
1761 { |
1905 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
1762 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
1906 dir = caps->iTypesAndDir; |
1763 dir = caps->iTypesAndDir; |
1907 test.Printf(_L("Endpoint: SizeBf= 0x%08x Type/Dir= 0x%08x"), |
1764 test.Printf(_L("Endpoint: SizeBf= 0x%08x Type/Dir= 0x%08x"), |
1908 caps->iSizes, dir); |
1765 caps->iSizes, dir); |
1909 OstTraceExt2(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP09, "Endpoint: SizeBf= 0x%08x Type/Dir= 0x%08x", |
|
1910 caps->iSizes, dir); |
|
1911 |
1766 |
1912 if (dir&KUsbEpDirIn) |
1767 if (dir&KUsbEpDirIn) |
1913 { |
|
1914 test.Printf(_L(" In ")); |
1768 test.Printf(_L(" In ")); |
1915 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP10, " In "); |
|
1916 } |
|
1917 if (dir&KUsbEpDirOut) |
1769 if (dir&KUsbEpDirOut) |
1918 { |
|
1919 test.Printf(_L(" Out")); |
1770 test.Printf(_L(" Out")); |
1920 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP11, " Out"); |
|
1921 } |
|
1922 if (dir&KUsbEpDirBidirect) |
1771 if (dir&KUsbEpDirBidirect) |
1923 { |
|
1924 test.Printf(_L(" Bi ")); |
1772 test.Printf(_L(" Bi ")); |
1925 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP12, " Bi "); |
|
1926 } |
|
1927 |
1773 |
1928 if (dir&KUsbEpTypeControl) |
1774 if (dir&KUsbEpTypeControl) |
1929 { |
1775 { |
1930 test.Printf(_L(" Control")); |
1776 test.Printf(_L(" Control")); |
1931 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP13, " Control"); |
|
1932 } |
1777 } |
1933 if (dir&KUsbEpTypeIsochronous) |
1778 if (dir&KUsbEpTypeIsochronous) |
1934 { |
1779 { |
1935 test.Printf(_L(" Isochronus")); |
1780 test.Printf(_L(" Isochronus")); |
1936 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP14, " Isochronus"); |
|
1937 } |
1781 } |
1938 if (dir&KUsbEpTypeBulk) |
1782 if (dir&KUsbEpTypeBulk) |
1939 { |
1783 { |
1940 test.Printf(_L(" Bulk")); |
1784 test.Printf(_L(" Bulk")); |
1941 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP15, " Bulk"); |
|
1942 } |
1785 } |
1943 if (dir&KUsbEpTypeInterrupt) |
1786 if (dir&KUsbEpTypeInterrupt) |
1944 { |
1787 { |
1945 test.Printf(_L(" Interrupt")); |
1788 test.Printf(_L(" Interrupt")); |
1946 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP16, " Interrupt"); |
|
1947 } |
1789 } |
1948 |
1790 |
1949 test.Printf(_L("\n")); |
1791 test.Printf(_L("\n")); |
1950 OstTrace0(TRACE_NORMAL, CHECKDEVICECAPABILITIES_CHECKDEVICECAPABILITIES_DUP17, "\n"); |
|
1951 |
1792 |
1952 if (caps->iHighBandwidth) |
1793 if (caps->iHighBandwidth) |
1953 { |
1794 { |
1954 // Must be HS Int or Iso ep |
1795 // Must be HS Int or Iso ep |
1955 test(gSupportsHighSpeed); |
1796 test(gSupportsHighSpeed); |
1963 |
1804 |
1964 |
1805 |
1965 TInt SettingOne(TInt aAltSetNo) |
1806 TInt SettingOne(TInt aAltSetNo) |
1966 { |
1807 { |
1967 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S1)\n")); |
1808 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S1)\n")); |
1968 OstTrace0(TRACE_NORMAL, SETTINGONE_SETTINGONE, "RTEST: Interigate Endpoint Capabilities (S1)\n"); |
|
1969 TInt r; |
1809 TInt r; |
1970 TUsbcScInterfaceInfoBuf ifc; |
1810 TUsbcScInterfaceInfoBuf ifc; |
1971 // Endpoint 0 |
1811 // Endpoint 0 |
1972 ifc().iEndpointData[0].iType = KUsbEpTypeBulk; |
1812 ifc().iEndpointData[0].iType = KUsbEpTypeBulk; |
1973 ifc().iEndpointData[0].iDir = KUsbEpDirIn; |
1813 ifc().iEndpointData[0].iDir = KUsbEpDirIn; |
1976 ifc().iEndpointData[1].iType = KUsbEpTypeBulk; |
1816 ifc().iEndpointData[1].iType = KUsbEpTypeBulk; |
1977 ifc().iEndpointData[1].iDir = KUsbEpDirOut; |
1817 ifc().iEndpointData[1].iDir = KUsbEpDirOut; |
1978 ifc().iEndpointData[1].iSize = KUsbEpSize64; |
1818 ifc().iEndpointData[1].iSize = KUsbEpSize64; |
1979 |
1819 |
1980 test.Printf(_L("RTEST: Setting up interface %d with two endpoints (s1)\n"), aAltSetNo); |
1820 test.Printf(_L("RTEST: Setting up interface %d with two endpoints (s1)\n"), aAltSetNo); |
1981 OstTrace1(TRACE_NORMAL, SETTINGONE_SETTINGONE_DUP01, "RTEST: Setting up interface %d with two endpoints (s1)\n", aAltSetNo); |
|
1982 _LIT16(string, "T_USBCSC Test Interface"); |
1821 _LIT16(string, "T_USBCSC Test Interface"); |
1983 ifc().iString = const_cast<TDesC16*>(&string); |
1822 ifc().iString = const_cast<TDesC16*>(&string); |
1984 ifc().iTotalEndpointsUsed = 2; |
1823 ifc().iTotalEndpointsUsed = 2; |
1985 ifc().iClass.iClassNum = 0xff; |
1824 ifc().iClass.iClassNum = 0xff; |
1986 ifc().iClass.iSubClassNum = 0xff; |
1825 ifc().iClass.iSubClassNum = 0xff; |
1994 } |
1833 } |
1995 |
1834 |
1996 TInt SettingTwo(TInt aAltSetNo) |
1835 TInt SettingTwo(TInt aAltSetNo) |
1997 { |
1836 { |
1998 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S2)\n")); |
1837 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S2)\n")); |
1999 OstTrace0(TRACE_NORMAL, SETTINGTWO_SETTINGTWO, "RTEST: Interigate Endpoint Capabilities (S2)\n"); |
|
2000 TUsbcScInterfaceInfoBuf ifc; |
1838 TUsbcScInterfaceInfoBuf ifc; |
2001 TInt ep_found = 0; |
1839 TInt ep_found = 0; |
2002 if (gInterruptInEpFound) |
1840 if (gInterruptInEpFound) |
2003 { |
1841 { |
2004 ifc().iEndpointData[ep_found].iType = KUsbEpTypeInterrupt; |
1842 ifc().iEndpointData[ep_found].iType = KUsbEpTypeInterrupt; |
2024 ifc().iEndpointData[ep_found].iDir = KUsbEpDirOut; |
1862 ifc().iEndpointData[ep_found].iDir = KUsbEpDirOut; |
2025 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
1863 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
2026 } while (++ep_found < 5); |
1864 } while (++ep_found < 5); |
2027 |
1865 |
2028 test.Printf(_L("Setting up interface %d with Five Endpoints (s2)\n"), aAltSetNo); |
1866 test.Printf(_L("Setting up interface %d with Five Endpoints (s2)\n"), aAltSetNo); |
2029 OstTrace1(TRACE_NORMAL, SETTINGTWO_SETTINGTWO_DUP01, "Setting up interface %d with Five Endpoints (s2)\n", aAltSetNo); |
|
2030 _LIT16(string, "T_USBSC API Test Interface"); |
1867 _LIT16(string, "T_USBSC API Test Interface"); |
2031 ifc().iString = const_cast<TDesC16*>(&string); |
1868 ifc().iString = const_cast<TDesC16*>(&string); |
2032 ifc().iTotalEndpointsUsed = ep_found; |
1869 ifc().iTotalEndpointsUsed = ep_found; |
2033 ifc().iClass.iClassNum = 0x08; |
1870 ifc().iClass.iClassNum = 0x08; |
2034 ifc().iClass.iSubClassNum = 0x06; |
1871 ifc().iClass.iSubClassNum = 0x06; |
2039 } |
1876 } |
2040 |
1877 |
2041 TInt SettingThreeIn(TInt aAltSetNo) |
1878 TInt SettingThreeIn(TInt aAltSetNo) |
2042 { |
1879 { |
2043 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S3)\n")); |
1880 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S3)\n")); |
2044 OstTrace0(TRACE_NORMAL, SETTINGTHREEIN_SETTINGTHREEIN, "RTEST: Interigate Endpoint Capabilities (S3)\n"); |
|
2045 TInt r; |
1881 TInt r; |
2046 TUsbcScInterfaceInfoBuf ifc; |
1882 TUsbcScInterfaceInfoBuf ifc; |
2047 TInt ep_found = 0; |
1883 TInt ep_found = 0; |
2048 do |
1884 do |
2049 { |
1885 { |
2051 ifc().iEndpointData[ep_found].iDir = KUsbEpDirIn; |
1887 ifc().iEndpointData[ep_found].iDir = KUsbEpDirIn; |
2052 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
1888 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
2053 } while (++ep_found < 3); |
1889 } while (++ep_found < 3); |
2054 |
1890 |
2055 test.Printf(_L("Setting up interface %d with three Bulk In endpoints(s3)\n"), aAltSetNo); |
1891 test.Printf(_L("Setting up interface %d with three Bulk In endpoints(s3)\n"), aAltSetNo); |
2056 OstTrace1(TRACE_NORMAL, SETTINGTHREEIN_SETTINGTHREEIN_DUP01, "Setting up interface %d with three Bulk In endpoints(s3)\n", aAltSetNo); |
|
2057 _LIT16(string, "T_USBCSC Test Interface"); |
1892 _LIT16(string, "T_USBCSC Test Interface"); |
2058 ifc().iString = const_cast<TDesC16*>(&string); |
1893 ifc().iString = const_cast<TDesC16*>(&string); |
2059 ifc().iTotalEndpointsUsed = ep_found; |
1894 ifc().iTotalEndpointsUsed = ep_found; |
2060 ifc().iClass.iClassNum = 0xff; |
1895 ifc().iClass.iClassNum = 0xff; |
2061 ifc().iClass.iSubClassNum = 0xff; |
1896 ifc().iClass.iSubClassNum = 0xff; |
2067 } |
1902 } |
2068 |
1903 |
2069 TInt SettingFourOut(TInt aAltSetNo) |
1904 TInt SettingFourOut(TInt aAltSetNo) |
2070 { |
1905 { |
2071 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S4)\n")); |
1906 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S4)\n")); |
2072 OstTrace0(TRACE_NORMAL, SETTINGFOUROUT_SETTINGFOUROUT, "RTEST: Interigate Endpoint Capabilities (S4)\n"); |
|
2073 TInt r; |
1907 TInt r; |
2074 TUsbcScInterfaceInfoBuf ifc; |
1908 TUsbcScInterfaceInfoBuf ifc; |
2075 TInt ep_found = 0; |
1909 TInt ep_found = 0; |
2076 do |
1910 do |
2077 { |
1911 { |
2079 ifc().iEndpointData[ep_found].iDir = KUsbEpDirOut; |
1913 ifc().iEndpointData[ep_found].iDir = KUsbEpDirOut; |
2080 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
1914 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
2081 } while (++ep_found < 3); |
1915 } while (++ep_found < 3); |
2082 |
1916 |
2083 test.Printf(_L("Setting up interface %d with three Bulk Out endpoints(s4)\n"), aAltSetNo); |
1917 test.Printf(_L("Setting up interface %d with three Bulk Out endpoints(s4)\n"), aAltSetNo); |
2084 OstTrace1(TRACE_NORMAL, SETTINGFOUROUT_SETTINGFOUROUT_DUP01, "Setting up interface %d with three Bulk Out endpoints(s4)\n", aAltSetNo); |
|
2085 _LIT16(string, "T_USBCSC Test Interface"); |
1918 _LIT16(string, "T_USBCSC Test Interface"); |
2086 ifc().iString = const_cast<TDesC16*>(&string); |
1919 ifc().iString = const_cast<TDesC16*>(&string); |
2087 ifc().iTotalEndpointsUsed = ep_found; |
1920 ifc().iTotalEndpointsUsed = ep_found; |
2088 ifc().iClass.iClassNum = 0xff; |
1921 ifc().iClass.iClassNum = 0xff; |
2089 ifc().iClass.iSubClassNum = 0xff; |
1922 ifc().iClass.iSubClassNum = 0xff; |
2095 } |
1928 } |
2096 |
1929 |
2097 TInt SettingFive(TInt aAltSetNo) |
1930 TInt SettingFive(TInt aAltSetNo) |
2098 { |
1931 { |
2099 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S5)\n")); |
1932 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (S5)\n")); |
2100 OstTrace0(TRACE_NORMAL, SETTINGFIVE_SETTINGFIVE, "RTEST: Interigate Endpoint Capabilities (S5)\n"); |
|
2101 TUsbcScInterfaceInfoBuf ifc; |
1933 TUsbcScInterfaceInfoBuf ifc; |
2102 TInt ep_found = 0; |
1934 TInt ep_found = 0; |
2103 if (gInterruptInEpFound) |
1935 if (gInterruptInEpFound) |
2104 { |
1936 { |
2105 ifc().iEndpointData[ep_found].iType = KUsbEpTypeInterrupt; |
1937 ifc().iEndpointData[ep_found].iType = KUsbEpTypeInterrupt; |
2131 ifc().iEndpointData[ep_found].iType = KUsbEpTypeBulk; |
1963 ifc().iEndpointData[ep_found].iType = KUsbEpTypeBulk; |
2132 ifc().iEndpointData[ep_found].iDir = KUsbEpDirIn; |
1964 ifc().iEndpointData[ep_found].iDir = KUsbEpDirIn; |
2133 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
1965 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
2134 |
1966 |
2135 test.Printf(_L("Setting up interface %d with Five Endpoints(s5)\n"), aAltSetNo); |
1967 test.Printf(_L("Setting up interface %d with Five Endpoints(s5)\n"), aAltSetNo); |
2136 OstTrace1(TRACE_NORMAL, SETTINGFIVE_SETTINGFIVE_DUP01, "Setting up interface %d with Five Endpoints(s5)\n", aAltSetNo); |
|
2137 _LIT16(string, "T_USBSC API Test Interface"); |
1968 _LIT16(string, "T_USBSC API Test Interface"); |
2138 ifc().iString = const_cast<TDesC16*>(&string); |
1969 ifc().iString = const_cast<TDesC16*>(&string); |
2139 ifc().iTotalEndpointsUsed = ep_found; |
1970 ifc().iTotalEndpointsUsed = ep_found; |
2140 ifc().iClass.iClassNum = 0x01; |
1971 ifc().iClass.iClassNum = 0x01; |
2141 ifc().iClass.iSubClassNum = 0x02; |
1972 ifc().iClass.iSubClassNum = 0x02; |
2148 TInt InvalidSettingOne(TInt aAltSetNo) // Invalid Interface - request more than what is available on device. |
1979 TInt InvalidSettingOne(TInt aAltSetNo) // Invalid Interface - request more than what is available on device. |
2149 // This will not be a valid test on the current high speed platform as the size requested is not available |
1980 // This will not be a valid test on the current high speed platform as the size requested is not available |
2150 // and will however return with an error, not because we are requesting one more than what is available of an interrupt endpoint |
1981 // and will however return with an error, not because we are requesting one more than what is available of an interrupt endpoint |
2151 { |
1982 { |
2152 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (I1)\n")); |
1983 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (I1)\n")); |
2153 OstTrace0(TRACE_NORMAL, INVALIDSETTINGONE_INVALIDSETTINGONE, "RTEST: Interigate Endpoint Capabilities (I1)\n"); |
|
2154 TUsbcScInterfaceInfoBuf ifc; |
1984 TUsbcScInterfaceInfoBuf ifc; |
2155 TInt interruptInEpFound = gInterruptInEpFound + 1; |
1985 TInt interruptInEpFound = gInterruptInEpFound + 1; |
2156 |
1986 |
2157 if (interruptInEpFound>KMaxEndpointsPerClient) |
1987 if (interruptInEpFound>KMaxEndpointsPerClient) |
2158 interruptInEpFound = KMaxEndpointsPerClient; |
1988 interruptInEpFound = KMaxEndpointsPerClient; |
2180 |
2010 |
2181 TInt InvalidSettingTwo(TInt aAltSetNo) //Invalid Setting by requesting an endpoint that is not available. |
2011 TInt InvalidSettingTwo(TInt aAltSetNo) //Invalid Setting by requesting an endpoint that is not available. |
2182 //Only control endpoints are bi-directional. Request any other type which has bidirectional capability. |
2012 //Only control endpoints are bi-directional. Request any other type which has bidirectional capability. |
2183 { |
2013 { |
2184 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (I2)\n")); |
2014 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (I2)\n")); |
2185 OstTrace0(TRACE_NORMAL, INVALIDSETTINGTWO_INVALIDSETTINGTWO, "RTEST: Interigate Endpoint Capabilities (I2)\n"); |
|
2186 |
2015 |
2187 TUsbcScInterfaceInfoBuf ifc; |
2016 TUsbcScInterfaceInfoBuf ifc; |
2188 // Endpoint 0 |
2017 // Endpoint 0 |
2189 ifc().iEndpointData[0].iType = KUsbEpTypeInterrupt; |
2018 ifc().iEndpointData[0].iType = KUsbEpTypeInterrupt; |
2190 ifc().iEndpointData[0].iDir = KUsbEpDirIn; |
2019 ifc().iEndpointData[0].iDir = KUsbEpDirIn; |
2208 } |
2037 } |
2209 |
2038 |
2210 TInt InvalidSettingThree(TInt aAltSetNo) |
2039 TInt InvalidSettingThree(TInt aAltSetNo) |
2211 { |
2040 { |
2212 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (I3)\n")); |
2041 test.Printf(_L("RTEST: Interigate Endpoint Capabilities (I3)\n")); |
2213 OstTrace0(TRACE_NORMAL, INVALIDSETTINGTHREE_INVALIDSETTINGTHREE, "RTEST: Interigate Endpoint Capabilities (I3)\n"); |
|
2214 TInt r; |
2042 TInt r; |
2215 TUsbcScInterfaceInfoBuf ifc; |
2043 TUsbcScInterfaceInfoBuf ifc; |
2216 TInt ep_found = 0; |
2044 TInt ep_found = 0; |
2217 do |
2045 do |
2218 { |
2046 { |
2226 ifc().iEndpointData[ep_found].iDir = KUsbEpDirOut; |
2054 ifc().iEndpointData[ep_found].iDir = KUsbEpDirOut; |
2227 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
2055 ifc().iEndpointData[ep_found].iSize = KUsbEpSize64; |
2228 } while (++ep_found < 5); |
2056 } while (++ep_found < 5); |
2229 |
2057 |
2230 test.Printf(_L("RTEST: Setting up interface %d, with invalid setting three (I3).\n"), aAltSetNo); |
2058 test.Printf(_L("RTEST: Setting up interface %d, with invalid setting three (I3).\n"), aAltSetNo); |
2231 OstTrace1(TRACE_NORMAL, INVALIDSETTINGTHREE_INVALIDSETTINGTHREE_DUP01, "RTEST: Setting up interface %d, with invalid setting three (I3).\n", aAltSetNo); |
|
2232 _LIT16(string, "T_USBCSC Test Interface"); |
2059 _LIT16(string, "T_USBCSC Test Interface"); |
2233 ifc().iString = const_cast<TDesC16*>(&string); |
2060 ifc().iString = const_cast<TDesC16*>(&string); |
2234 ifc().iTotalEndpointsUsed = ep_found+1; |
2061 ifc().iTotalEndpointsUsed = ep_found+1; |
2235 ifc().iClass.iClassNum = 0x01; |
2062 ifc().iClass.iClassNum = 0x01; |
2236 ifc().iClass.iSubClassNum = 0x02; |
2063 ifc().iClass.iSubClassNum = 0x02; |
2295 test.Start(_L("Device_Qualifier Descriptor Manipulation")); |
2122 test.Start(_L("Device_Qualifier Descriptor Manipulation")); |
2296 |
2123 |
2297 if (!gSupportsHighSpeed) |
2124 if (!gSupportsHighSpeed) |
2298 { |
2125 { |
2299 test.Printf(_L("*** Not supported - skipping Device_Qualifier descriptor tests\n")); |
2126 test.Printf(_L("*** Not supported - skipping Device_Qualifier descriptor tests\n")); |
2300 OstTrace0(TRACE_NORMAL, TESTDEVICEQUALIFIERDESCRIPTOR_TESTDEVICEQUALIFIERDESCRIPTOR, "*** Not supported - skipping Device_Qualifier descriptor tests\n"); |
|
2301 test.End(); |
2127 test.End(); |
2302 return; |
2128 return; |
2303 } |
2129 } |
2304 |
2130 |
2305 test.Next(_L("GetDeviceQualifierDescriptor()")); |
2131 test.Next(_L("GetDeviceQualifierDescriptor()")); |
2371 test.Start(_L("Other_Speed_Configuration Desc Manipulation")); |
2197 test.Start(_L("Other_Speed_Configuration Desc Manipulation")); |
2372 |
2198 |
2373 if (!gSupportsHighSpeed) |
2199 if (!gSupportsHighSpeed) |
2374 { |
2200 { |
2375 test.Printf(_L("*** Not supported - skipping Other_Speed_Configuration desc tests\n")); |
2201 test.Printf(_L("*** Not supported - skipping Other_Speed_Configuration desc tests\n")); |
2376 OstTrace0(TRACE_NORMAL, TESTOTHERSPEEDCONFIGURATIONDESCRIPTOR_TESTOTHERSPEEDCONFIGURATIONDESCRIPTOR, "*** Not supported - skipping Other_Speed_Configuration desc tests\n"); |
|
2377 test.End(); |
2202 test.End(); |
2378 return; |
2203 return; |
2379 } |
2204 } |
2380 |
2205 |
2381 test.Next(_L("GetOtherSpeedConfigurationDescriptor()")); |
2206 test.Next(_L("GetOtherSpeedConfigurationDescriptor()")); |
2504 test.Start(_L("Alternate Interface Setting Manipulation")); |
2329 test.Start(_L("Alternate Interface Setting Manipulation")); |
2505 |
2330 |
2506 if (!SupportsAlternateInterfaces()) |
2331 if (!SupportsAlternateInterfaces()) |
2507 { |
2332 { |
2508 test.Printf(_L("*** Not supported - skipping alternate interface settings tests\n")); |
2333 test.Printf(_L("*** Not supported - skipping alternate interface settings tests\n")); |
2509 OstTrace0(TRACE_NORMAL, TESTALTERNATEINTERFACEMANIPULATION_TESTALTERNATEINTERFACEMANIPULATION, "*** Not supported - skipping alternate interface settings tests\n"); |
|
2510 test.End(); |
2334 test.End(); |
2511 return; |
2335 return; |
2512 } |
2336 } |
2513 test_KErrNone(SettingFive(1)); |
2337 test_KErrNone(SettingFive(1)); |
2514 |
2338 |
2602 test.Start(_L("Extended Endpoint Descriptor Manipulation")); |
2426 test.Start(_L("Extended Endpoint Descriptor Manipulation")); |
2603 |
2427 |
2604 if (!SupportsAlternateInterfaces()) |
2428 if (!SupportsAlternateInterfaces()) |
2605 { |
2429 { |
2606 test.Printf(_L("*** Not supported - skipping Extended Endpoint descriptor tests\n")); |
2430 test.Printf(_L("*** Not supported - skipping Extended Endpoint descriptor tests\n")); |
2607 OstTrace0(TRACE_NORMAL, TESTEXTENDEDENDPOINTDESCRIPTOR_TESTEXTENDEDENDPOINTDESCRIPTOR, "*** Not supported - skipping Extended Endpoint descriptor tests\n"); |
|
2608 test.End(); |
2431 test.End(); |
2609 return; |
2432 return; |
2610 } |
2433 } |
2611 |
2434 |
2612 // Extended Endpoint Descriptor manipulation (Audio class endpoint) |
2435 // Extended Endpoint Descriptor manipulation (Audio class endpoint) |
2652 test.Next(_L("GetStringDescriptorLangId()")); |
2475 test.Next(_L("GetStringDescriptorLangId()")); |
2653 TUint16 rd_langid_orig; |
2476 TUint16 rd_langid_orig; |
2654 TInt r = gPort.GetStringDescriptorLangId(rd_langid_orig); |
2477 TInt r = gPort.GetStringDescriptorLangId(rd_langid_orig); |
2655 test_KErrNone(r); |
2478 test_KErrNone(r); |
2656 test.Printf(_L("Original LANGID code: 0x%04X\n"), rd_langid_orig); |
2479 test.Printf(_L("Original LANGID code: 0x%04X\n"), rd_langid_orig); |
2657 OstTrace1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS, "Original LANGID code: 0x%04X\n", rd_langid_orig); |
|
2658 |
2480 |
2659 test.Next(_L("SetStringDescriptorLangId()")); |
2481 test.Next(_L("SetStringDescriptorLangId()")); |
2660 TUint16 wr_langid = 0x0809; // English (UK) Language ID |
2482 TUint16 wr_langid = 0x0809; // English (UK) Language ID |
2661 if (wr_langid == rd_langid_orig) |
2483 if (wr_langid == rd_langid_orig) |
2662 wr_langid = 0x0444; // Tatar Language ID |
2484 wr_langid = 0x0444; // Tatar Language ID |
2666 test.Next(_L("GetStringDescriptorLangId()")); |
2488 test.Next(_L("GetStringDescriptorLangId()")); |
2667 TUint16 rd_langid; |
2489 TUint16 rd_langid; |
2668 r = gPort.GetStringDescriptorLangId(rd_langid); |
2490 r = gPort.GetStringDescriptorLangId(rd_langid); |
2669 test_KErrNone(r); |
2491 test_KErrNone(r); |
2670 test.Printf(_L("New LANGID code: 0x%04X\n"), rd_langid); |
2492 test.Printf(_L("New LANGID code: 0x%04X\n"), rd_langid); |
2671 OstTrace1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP01, "New LANGID code: 0x%04X\n", rd_langid); |
|
2672 |
2493 |
2673 test.Next(_L("Compare LANGID codes")); |
2494 test.Next(_L("Compare LANGID codes")); |
2674 test(rd_langid == wr_langid); |
2495 test(rd_langid == wr_langid); |
2675 |
2496 |
2676 test.Next(_L("Restore original LANGID code")); |
2497 test.Next(_L("Restore original LANGID code")); |
2687 test(r == KErrNone || r == KErrNotFound); |
2508 test(r == KErrNone || r == KErrNotFound); |
2688 TBool restore_string; |
2509 TBool restore_string; |
2689 if (r == KErrNone) |
2510 if (r == KErrNone) |
2690 { |
2511 { |
2691 test.Printf(_L("Original Manufacturer string: \"%lS\"\n"), &rd_str_orig); |
2512 test.Printf(_L("Original Manufacturer string: \"%lS\"\n"), &rd_str_orig); |
2692 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP02, "Original Manufacturer string: \"%lS\"\n", rd_str_orig); |
|
2693 restore_string = ETrue; |
2513 restore_string = ETrue; |
2694 } |
2514 } |
2695 else |
2515 else |
2696 { |
2516 { |
2697 test.Printf(_L("No Manufacturer string set\n")); |
2517 test.Printf(_L("No Manufacturer string set\n")); |
2698 OstTrace0(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP03, "No Manufacturer string set\n"); |
|
2699 restore_string = EFalse; |
2518 restore_string = EFalse; |
2700 } |
2519 } |
2701 |
2520 |
2702 test.Next(_L("SetManufacturerStringDescriptor()")); |
2521 test.Next(_L("SetManufacturerStringDescriptor()")); |
2703 _LIT16(manufacturer, "Manufacturer Which Manufactures Devices"); |
2522 _LIT16(manufacturer, "Manufacturer Which Manufactures Devices"); |
2708 test.Next(_L("GetManufacturerStringDescriptor()")); |
2527 test.Next(_L("GetManufacturerStringDescriptor()")); |
2709 TBuf16<KUsbStringDescStringMaxSize / 2> rd_str; |
2528 TBuf16<KUsbStringDescStringMaxSize / 2> rd_str; |
2710 r = gPort.GetManufacturerStringDescriptor(rd_str); |
2529 r = gPort.GetManufacturerStringDescriptor(rd_str); |
2711 test_KErrNone(r); |
2530 test_KErrNone(r); |
2712 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
2531 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
2713 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP04, "New Manufacturer string: \"%lS\"\n", rd_str); |
|
2714 |
2532 |
2715 test.Next(_L("Compare Manufacturer strings")); |
2533 test.Next(_L("Compare Manufacturer strings")); |
2716 r = rd_str.Compare(wr_str); |
2534 r = rd_str.Compare(wr_str); |
2717 test_KErrNone(r); |
2535 test_KErrNone(r); |
2718 |
2536 |
2726 test.Next(_L("GetManufacturerStringDescriptor()")); |
2544 test.Next(_L("GetManufacturerStringDescriptor()")); |
2727 rd_str.FillZ(rd_str.MaxLength()); |
2545 rd_str.FillZ(rd_str.MaxLength()); |
2728 r = gPort.GetManufacturerStringDescriptor(rd_str); |
2546 r = gPort.GetManufacturerStringDescriptor(rd_str); |
2729 test_KErrNone(r); |
2547 test_KErrNone(r); |
2730 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
2548 test.Printf(_L("New Manufacturer string: \"%lS\"\n"), &rd_str); |
2731 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP05, "New Manufacturer string: \"%lS\"\n", rd_str); |
|
2732 |
2549 |
2733 test.Next(_L("Compare Manufacturer strings")); |
2550 test.Next(_L("Compare Manufacturer strings")); |
2734 r = rd_str.Compare(wr_str); |
2551 r = rd_str.Compare(wr_str); |
2735 test_KErrNone(r); |
2552 test_KErrNone(r); |
2736 |
2553 |
2757 r = gPort.GetProductStringDescriptor(rd_str_orig); |
2574 r = gPort.GetProductStringDescriptor(rd_str_orig); |
2758 test(r == KErrNone || r == KErrNotFound); |
2575 test(r == KErrNone || r == KErrNotFound); |
2759 if (r == KErrNone) |
2576 if (r == KErrNone) |
2760 { |
2577 { |
2761 test.Printf(_L("Old Product string: \"%lS\"\n"), &rd_str_orig); |
2578 test.Printf(_L("Old Product string: \"%lS\"\n"), &rd_str_orig); |
2762 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP06, "Old Product string: \"%lS\"\n", rd_str_orig); |
|
2763 restore_string = ETrue; |
2579 restore_string = ETrue; |
2764 } |
2580 } |
2765 else |
2581 else |
2766 restore_string = EFalse; |
2582 restore_string = EFalse; |
2767 |
2583 |
2775 test.Next(_L("GetProductStringDescriptor()")); |
2591 test.Next(_L("GetProductStringDescriptor()")); |
2776 rd_str.FillZ(rd_str.MaxLength()); |
2592 rd_str.FillZ(rd_str.MaxLength()); |
2777 r = gPort.GetProductStringDescriptor(rd_str); |
2593 r = gPort.GetProductStringDescriptor(rd_str); |
2778 test_KErrNone(r); |
2594 test_KErrNone(r); |
2779 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
2595 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
2780 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP07, "New Product string: \"%lS\"\n", rd_str); |
|
2781 |
2596 |
2782 test.Next(_L("Compare Product strings")); |
2597 test.Next(_L("Compare Product strings")); |
2783 r = rd_str.Compare(wr_str); |
2598 r = rd_str.Compare(wr_str); |
2784 test_KErrNone(r); |
2599 test_KErrNone(r); |
2785 |
2600 |
2793 test.Next(_L("GetProductStringDescriptor()")); |
2608 test.Next(_L("GetProductStringDescriptor()")); |
2794 rd_str.FillZ(rd_str.MaxLength()); |
2609 rd_str.FillZ(rd_str.MaxLength()); |
2795 r = gPort.GetProductStringDescriptor(rd_str); |
2610 r = gPort.GetProductStringDescriptor(rd_str); |
2796 test_KErrNone(r); |
2611 test_KErrNone(r); |
2797 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
2612 test.Printf(_L("New Product string: \"%lS\"\n"), &rd_str); |
2798 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP08, "New Product string: \"%lS\"\n", rd_str); |
|
2799 |
2613 |
2800 test.Next(_L("Compare Product strings")); |
2614 test.Next(_L("Compare Product strings")); |
2801 r = rd_str.Compare(wr_str); |
2615 r = rd_str.Compare(wr_str); |
2802 test_KErrNone(r); |
2616 test_KErrNone(r); |
2803 |
2617 |
2824 r = gPort.GetSerialNumberStringDescriptor(rd_str_orig); |
2638 r = gPort.GetSerialNumberStringDescriptor(rd_str_orig); |
2825 test(r == KErrNone || r == KErrNotFound); |
2639 test(r == KErrNone || r == KErrNotFound); |
2826 if (r == KErrNone) |
2640 if (r == KErrNone) |
2827 { |
2641 { |
2828 test.Printf(_L("Old Serial Number: \"%lS\"\n"), &rd_str_orig); |
2642 test.Printf(_L("Old Serial Number: \"%lS\"\n"), &rd_str_orig); |
2829 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP09, "Old Serial Number: \"%lS\"\n", rd_str_orig); |
|
2830 restore_string = ETrue; |
2643 restore_string = ETrue; |
2831 } |
2644 } |
2832 else |
2645 else |
2833 restore_string = EFalse; |
2646 restore_string = EFalse; |
2834 |
2647 |
2842 test.Next(_L("GetSerialNumberStringDescriptor()")); |
2655 test.Next(_L("GetSerialNumberStringDescriptor()")); |
2843 rd_str.FillZ(rd_str.MaxLength()); |
2656 rd_str.FillZ(rd_str.MaxLength()); |
2844 r = gPort.GetSerialNumberStringDescriptor(rd_str); |
2657 r = gPort.GetSerialNumberStringDescriptor(rd_str); |
2845 test_KErrNone(r); |
2658 test_KErrNone(r); |
2846 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
2659 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
2847 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP10, "New Serial Number: \"%lS\"\n", rd_str); |
|
2848 |
2660 |
2849 test.Next(_L("Compare Serial Number strings")); |
2661 test.Next(_L("Compare Serial Number strings")); |
2850 r = rd_str.Compare(wr_str); |
2662 r = rd_str.Compare(wr_str); |
2851 test_KErrNone(r); |
2663 test_KErrNone(r); |
2852 |
2664 |
2860 test.Next(_L("GetSerialNumberStringDescriptor()")); |
2672 test.Next(_L("GetSerialNumberStringDescriptor()")); |
2861 rd_str.FillZ(rd_str.MaxLength()); |
2673 rd_str.FillZ(rd_str.MaxLength()); |
2862 r = gPort.GetSerialNumberStringDescriptor(rd_str); |
2674 r = gPort.GetSerialNumberStringDescriptor(rd_str); |
2863 test_KErrNone(r); |
2675 test_KErrNone(r); |
2864 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
2676 test.Printf(_L("New Serial Number: \"%lS\"\n"), &rd_str); |
2865 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP11, "New Serial Number: \"%lS\"\n", rd_str); |
|
2866 |
2677 |
2867 test.Next(_L("Compare Serial Number strings")); |
2678 test.Next(_L("Compare Serial Number strings")); |
2868 r = rd_str.Compare(wr_str); |
2679 r = rd_str.Compare(wr_str); |
2869 test_KErrNone(r); |
2680 test_KErrNone(r); |
2870 |
2681 |
2891 r = gPort.GetConfigurationStringDescriptor(rd_str_orig); |
2702 r = gPort.GetConfigurationStringDescriptor(rd_str_orig); |
2892 test(r == KErrNone || r == KErrNotFound); |
2703 test(r == KErrNone || r == KErrNotFound); |
2893 if (r == KErrNone) |
2704 if (r == KErrNone) |
2894 { |
2705 { |
2895 test.Printf(_L("Old Configuration string: \"%lS\"\n"), &rd_str_orig); |
2706 test.Printf(_L("Old Configuration string: \"%lS\"\n"), &rd_str_orig); |
2896 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP12, "Old Configuration string: \"%lS\"\n", rd_str_orig); |
|
2897 restore_string = ETrue; |
2707 restore_string = ETrue; |
2898 } |
2708 } |
2899 else |
2709 else |
2900 restore_string = EFalse; |
2710 restore_string = EFalse; |
2901 |
2711 |
2909 test.Next(_L("GetConfigurationStringDescriptor()")); |
2719 test.Next(_L("GetConfigurationStringDescriptor()")); |
2910 rd_str.FillZ(rd_str.MaxLength()); |
2720 rd_str.FillZ(rd_str.MaxLength()); |
2911 r = gPort.GetConfigurationStringDescriptor(rd_str); |
2721 r = gPort.GetConfigurationStringDescriptor(rd_str); |
2912 test_KErrNone(r); |
2722 test_KErrNone(r); |
2913 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
2723 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
2914 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP13, "New Configuration string: \"%lS\"\n", rd_str); |
|
2915 |
2724 |
2916 test.Next(_L("Compare Configuration strings")); |
2725 test.Next(_L("Compare Configuration strings")); |
2917 r = rd_str.Compare(wr_str); |
2726 r = rd_str.Compare(wr_str); |
2918 test_KErrNone(r); |
2727 test_KErrNone(r); |
2919 |
2728 |
2927 test.Next(_L("GetConfigurationStringDescriptor()")); |
2736 test.Next(_L("GetConfigurationStringDescriptor()")); |
2928 rd_str.FillZ(rd_str.MaxLength()); |
2737 rd_str.FillZ(rd_str.MaxLength()); |
2929 r = gPort.GetConfigurationStringDescriptor(rd_str); |
2738 r = gPort.GetConfigurationStringDescriptor(rd_str); |
2930 test_KErrNone(r); |
2739 test_KErrNone(r); |
2931 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
2740 test.Printf(_L("New Configuration string: \"%lS\"\n"), &rd_str); |
2932 OstTraceExt1(TRACE_NORMAL, TESTSTANDARDSTRINGDESCRIPTORS_TESTSTANDARDSTRINGDESCRIPTORS_DUP14, "New Configuration string: \"%lS\"\n", rd_str); |
|
2933 |
2741 |
2934 test.Next(_L("Compare Configuration strings")); |
2742 test.Next(_L("Compare Configuration strings")); |
2935 r = rd_str.Compare(wr_str); |
2743 r = rd_str.Compare(wr_str); |
2936 test_KErrNone(r); |
2744 test_KErrNone(r); |
2937 |
2745 |
2978 |
2786 |
2979 test.Next(_L("GetStringDescriptor() 1")); |
2787 test.Next(_L("GetStringDescriptor() 1")); |
2980 r = gPort.GetStringDescriptor(stridx1, rd_str); |
2788 r = gPort.GetStringDescriptor(stridx1, rd_str); |
2981 test_KErrNone(r); |
2789 test_KErrNone(r); |
2982 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx1, &rd_str); |
2790 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx1, &rd_str); |
2983 OstTraceExt2(TRACE_NORMAL, TESTARBITRARYSTRINGDESCRIPTORS_TESTARBITRARYSTRINGDESCRIPTORS, "New test string @ idx %d: \"%lS\"\n", stridx1, rd_str); |
|
2984 |
2791 |
2985 test.Next(_L("Compare test strings 1")); |
2792 test.Next(_L("Compare test strings 1")); |
2986 r = rd_str.Compare(wr_str); |
2793 r = rd_str.Compare(wr_str); |
2987 test_KErrNone(r); |
2794 test_KErrNone(r); |
2988 |
2795 |
3016 |
2823 |
3017 test.Next(_L("GetStringDescriptor() 2")); |
2824 test.Next(_L("GetStringDescriptor() 2")); |
3018 r = gPort.GetStringDescriptor(stridx2, rd_str); |
2825 r = gPort.GetStringDescriptor(stridx2, rd_str); |
3019 test_KErrNone(r); |
2826 test_KErrNone(r); |
3020 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx2, &rd_str); |
2827 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx2, &rd_str); |
3021 OstTraceExt2(TRACE_NORMAL, TESTARBITRARYSTRINGDESCRIPTORS_TESTARBITRARYSTRINGDESCRIPTORS_DUP01, "New test string @ idx %d: \"%lS\"\n", stridx2, rd_str); |
|
3022 |
2828 |
3023 test.Next(_L("Compare test strings 2")); |
2829 test.Next(_L("Compare test strings 2")); |
3024 r = rd_str.Compare(wr_str); |
2830 r = rd_str.Compare(wr_str); |
3025 test_KErrNone(r); |
2831 test_KErrNone(r); |
3026 |
2832 |
3039 |
2845 |
3040 test.Next(_L("GetStringDescriptor() 3")); |
2846 test.Next(_L("GetStringDescriptor() 3")); |
3041 r = gPort.GetStringDescriptor(stridx3, rd_str); |
2847 r = gPort.GetStringDescriptor(stridx3, rd_str); |
3042 test_KErrNone(r); |
2848 test_KErrNone(r); |
3043 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx3, &rd_str); |
2849 test.Printf(_L("New test string @ idx %d: \"%lS\"\n"), stridx3, &rd_str); |
3044 OstTraceExt2(TRACE_NORMAL, TESTARBITRARYSTRINGDESCRIPTORS_TESTARBITRARYSTRINGDESCRIPTORS_DUP02, "New test string @ idx %d: \"%lS\"\n", stridx3, rd_str); |
|
3045 |
2850 |
3046 test.Next(_L("Compare test strings 3")); |
2851 test.Next(_L("Compare test strings 3")); |
3047 r = rd_str.Compare(wr_str); |
2852 r = rd_str.Compare(wr_str); |
3048 test_KErrNone(r); |
2853 test_KErrNone(r); |
3049 |
2854 |
3080 test(r == KErrNone); |
2885 test(r == KErrNone); |
3081 test.Printf(_L("Endpoint %d state: %s\n"), aEndpoint, |
2886 test.Printf(_L("Endpoint %d state: %s\n"), aEndpoint, |
3082 (ep_state == EEndpointStateNotStalled) ? _S("Not stalled") : |
2887 (ep_state == EEndpointStateNotStalled) ? _S("Not stalled") : |
3083 ((ep_state == EEndpointStateStalled) ? _S("Stalled") : |
2888 ((ep_state == EEndpointStateStalled) ? _S("Stalled") : |
3084 _S("Unknown..."))); |
2889 _S("Unknown..."))); |
3085 OstTraceExt2(TRACE_NORMAL, QUERYENDPOINTSTATE_QUERYENDPOINTSTATE, "Endpoint %d state: %s\n", aEndpoint, |
|
3086 (ep_state == EEndpointStateNotStalled) ? _L("Not stalled") : |
|
3087 ((ep_state == EEndpointStateStalled) ? _L("Stalled") : |
|
3088 _L("Unknown..."))); |
|
3089 return ep_state; |
2890 return ep_state; |
3090 } |
2891 } |
3091 |
2892 |
3092 static void TestEndpointStallStatus() |
2893 static void TestEndpointStallStatus() |
3093 { |
2894 { |
3094 test.Start(_L("Test Endpoint Stall Status")); |
2895 test.Start(_L("Test Endpoint Stall Status")); |
3095 |
2896 |
3096 if (!SupportsEndpointStall()) |
2897 if (!SupportsEndpointStall()) |
3097 { |
2898 { |
3098 test.Printf(_L("*** Not supported - skipping endpoint stall status tests\n")); |
2899 test.Printf(_L("*** Not supported - skipping endpoint stall status tests\n")); |
3099 OstTrace0(TRACE_NORMAL, TESTENDPOINTSTALLSTATUS_TESTENDPOINTSTALLSTATUS, "*** Not supported - skipping endpoint stall status tests\n"); |
|
3100 test.End(); |
2900 test.End(); |
3101 return; |
2901 return; |
3102 } |
2902 } |
3103 |
2903 |
3104 test.Next(_L("Endpoint stall status")); |
2904 test.Next(_L("Endpoint stall status")); |
3149 for (TInt i = 0; i <= 2; i++) |
2949 for (TInt i = 0; i <= 2; i++) |
3150 { |
2950 { |
3151 if ((epStateBitmap & (1 << i)) == EEndpointStateNotStalled) |
2951 if ((epStateBitmap & (1 << i)) == EEndpointStateNotStalled) |
3152 { |
2952 { |
3153 test.Printf(_L("EndpointStatusNotify: Ep %d NOT STALLED\n"), i); |
2953 test.Printf(_L("EndpointStatusNotify: Ep %d NOT STALLED\n"), i); |
3154 OstTrace1(TRACE_NORMAL, TESTENDPOINTSTATUSNOTIFY_TESTENDPOINTSTATUSNOTIFY, "EndpointStatusNotify: Ep %d NOT STALLED\n", i); |
|
3155 } |
2954 } |
3156 else |
2955 else |
3157 { |
2956 { |
3158 test.Printf(_L("EndpointStatusNotify: Ep %d STALLED\n"), i); |
2957 test.Printf(_L("EndpointStatusNotify: Ep %d STALLED\n"), i); |
3159 OstTrace1(TRACE_NORMAL, TESTENDPOINTSTATUSNOTIFY_TESTENDPOINTSTATUSNOTIFY_DUP01, "EndpointStatusNotify: Ep %d STALLED\n", i); |
|
3160 } |
2958 } |
3161 } |
2959 } |
3162 |
2960 |
3163 test.End(); |
2961 test.End(); |
3164 } |
2962 } |
3177 test(dev_status == KErrCancel || dev_status == KErrNone); |
2975 test(dev_status == KErrCancel || dev_status == KErrNone); |
3178 if (deviceState & KUsbAlternateSetting) |
2976 if (deviceState & KUsbAlternateSetting) |
3179 { |
2977 { |
3180 TUint setting = (deviceState & ~KUsbAlternateSetting); |
2978 TUint setting = (deviceState & ~KUsbAlternateSetting); |
3181 test.Printf(_L("Alternate setting change to setting %d - unexpected"), setting); |
2979 test.Printf(_L("Alternate setting change to setting %d - unexpected"), setting); |
3182 OstTrace1(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY, "Alternate setting change to setting %d - unexpected", setting); |
|
3183 test(EFalse); |
2980 test(EFalse); |
3184 } |
2981 } |
3185 else |
2982 else |
3186 { |
2983 { |
3187 switch (deviceState) |
2984 switch (deviceState) |
3188 { |
2985 { |
3189 case EUsbcDeviceStateUndefined: |
2986 case EUsbcDeviceStateUndefined: |
3190 test.Printf(_L("TestAlternateDeviceStatusNotify: Undefined state\n")); |
2987 test.Printf(_L("TestAlternateDeviceStatusNotify: Undefined state\n")); |
3191 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP01, "TestAlternateDeviceStatusNotify: Undefined state\n"); |
|
3192 break; |
2988 break; |
3193 case EUsbcDeviceStateAttached: |
2989 case EUsbcDeviceStateAttached: |
3194 test.Printf(_L("TestAlternateDeviceStatusNotify: Attached state\n")); |
2990 test.Printf(_L("TestAlternateDeviceStatusNotify: Attached state\n")); |
3195 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP02, "TestAlternateDeviceStatusNotify: Attached state\n"); |
|
3196 break; |
2991 break; |
3197 case EUsbcDeviceStatePowered: |
2992 case EUsbcDeviceStatePowered: |
3198 test.Printf(_L("TestAlternateDeviceStatusNotify: Powered state\n")); |
2993 test.Printf(_L("TestAlternateDeviceStatusNotify: Powered state\n")); |
3199 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP03, "TestAlternateDeviceStatusNotify: Powered state\n"); |
|
3200 break; |
2994 break; |
3201 case EUsbcDeviceStateDefault: |
2995 case EUsbcDeviceStateDefault: |
3202 test.Printf(_L("TestAlternateDeviceStatusNotify: Default state\n")); |
2996 test.Printf(_L("TestAlternateDeviceStatusNotify: Default state\n")); |
3203 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP04, "TestAlternateDeviceStatusNotify: Default state\n"); |
|
3204 break; |
2997 break; |
3205 case EUsbcDeviceStateAddress: |
2998 case EUsbcDeviceStateAddress: |
3206 test.Printf(_L("TestAlternateDeviceStatusNotify: Address state\n")); |
2999 test.Printf(_L("TestAlternateDeviceStatusNotify: Address state\n")); |
3207 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP05, "TestAlternateDeviceStatusNotify: Address state\n"); |
|
3208 break; |
3000 break; |
3209 case EUsbcDeviceStateConfigured: |
3001 case EUsbcDeviceStateConfigured: |
3210 test.Printf(_L("TestAlternateDeviceStatusNotify: Configured state\n")); |
3002 test.Printf(_L("TestAlternateDeviceStatusNotify: Configured state\n")); |
3211 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP06, "TestAlternateDeviceStatusNotify: Configured state\n"); |
|
3212 break; |
3003 break; |
3213 case EUsbcDeviceStateSuspended: |
3004 case EUsbcDeviceStateSuspended: |
3214 test.Printf(_L("TestAlternateDeviceStatusNotify: Suspended state\n")); |
3005 test.Printf(_L("TestAlternateDeviceStatusNotify: Suspended state\n")); |
3215 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP07, "TestAlternateDeviceStatusNotify: Suspended state\n"); |
|
3216 break; |
3006 break; |
3217 case EUsbcNoState: |
3007 case EUsbcNoState: |
3218 test.Printf(_L("TestAlternateDeviceStatusNotify: State buffering error\n")); |
3008 test.Printf(_L("TestAlternateDeviceStatusNotify: State buffering error\n")); |
3219 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP08, "TestAlternateDeviceStatusNotify: State buffering error\n"); |
|
3220 test(EFalse); |
3009 test(EFalse); |
3221 break; |
3010 break; |
3222 default: |
3011 default: |
3223 test.Printf(_L("TestAlternateDeviceStatusNotify: Unknown state\n")); |
3012 test.Printf(_L("TestAlternateDeviceStatusNotify: Unknown state\n")); |
3224 OstTrace0(TRACE_NORMAL, TESTALTERNATEDEVICESTATUSNOTIFY_TESTALTERNATEDEVICESTATUSNOTIFY_DUP09, "TestAlternateDeviceStatusNotify: Unknown state\n"); |
|
3225 test(EFalse); |
3013 test(EFalse); |
3226 } |
3014 } |
3227 } |
3015 } |
3228 test.End(); |
3016 test.End(); |
3229 } |
3017 } |
3351 } |
3139 } |
3352 |
3140 |
3353 void SetupBulkInterfaces(TUint aInterfaceNo,TUint nReadEps, TUint nWriteEps) |
3141 void SetupBulkInterfaces(TUint aInterfaceNo,TUint nReadEps, TUint nWriteEps) |
3354 { |
3142 { |
3355 test.Printf(_L("SetupBulkInterfaces: %d, %d, %d\n"),aInterfaceNo,nReadEps,nWriteEps); |
3143 test.Printf(_L("SetupBulkInterfaces: %d, %d, %d\n"),aInterfaceNo,nReadEps,nWriteEps); |
3356 OstTraceExt3(TRACE_NORMAL, SETUPBULKINTERFACES_SETUPBULKINTERFACES, "SetupBulkInterfaces: %u, %u, %u\n",aInterfaceNo,nReadEps,nWriteEps); |
|
3357 TUsbcScInterfaceInfoBuf ifc; |
3144 TUsbcScInterfaceInfoBuf ifc; |
3358 TUint i; |
3145 TUint i; |
3359 for(i=0; i<nWriteEps;i++) |
3146 for(i=0; i<nWriteEps;i++) |
3360 { |
3147 { |
3361 ifc().iEndpointData[i].iType = KUsbEpTypeBulk; |
3148 ifc().iEndpointData[i].iType = KUsbEpTypeBulk; |
3382 } |
3169 } |
3383 |
3170 |
3384 void PrintBILTestOptions() |
3171 void PrintBILTestOptions() |
3385 { |
3172 { |
3386 test.Printf(_L("Select an option\n")); |
3173 test.Printf(_L("Select an option\n")); |
3387 OstTrace0(TRACE_NORMAL, PRINTBILTESTOPTIONS_PRINTBILTESTOPTIONS, "Select an option\n"); |
|
3388 test.Printf(_L("1.Test BIL API\n")); //unimplemented |
3174 test.Printf(_L("1.Test BIL API\n")); //unimplemented |
3389 OstTrace0(TRACE_NORMAL, PRINTBILTESTOPTIONS_PRINTBILTESTOPTIONS_DUP01, "1.Test BIL API\n"); //unimplemented |
|
3390 test.Printf(_L("2.Test BIL Read Write\n")); |
3175 test.Printf(_L("2.Test BIL Read Write\n")); |
3391 OstTrace0(TRACE_NORMAL, PRINTBILTESTOPTIONS_PRINTBILTESTOPTIONS_DUP02, "2.Test BIL Read Write\n"); |
|
3392 test.Printf(_L("3.Test EP0 using BIL API's\n")); |
3176 test.Printf(_L("3.Test EP0 using BIL API's\n")); |
3393 OstTrace0(TRACE_NORMAL, PRINTBILTESTOPTIONS_PRINTBILTESTOPTIONS_DUP03, "3.Test EP0 using BIL API's\n"); |
|
3394 test.Printf(_L("4.Test AlternateSetting Change BIL API's\n")); //unimplemented |
3177 test.Printf(_L("4.Test AlternateSetting Change BIL API's\n")); //unimplemented |
3395 OstTrace0(TRACE_NORMAL, PRINTBILTESTOPTIONS_PRINTBILTESTOPTIONS_DUP04, "4.Test AlternateSetting Change BIL API's\n"); //unimplemented |
|
3396 test.Printf(_L("5.Run All\n")); |
3178 test.Printf(_L("5.Run All\n")); |
3397 OstTrace0(TRACE_NORMAL, PRINTBILTESTOPTIONS_PRINTBILTESTOPTIONS_DUP05, "5.Run All\n"); |
|
3398 test.Printf(_L("6.Quit\n")); |
3179 test.Printf(_L("6.Quit\n")); |
3399 OstTrace0(TRACE_NORMAL, PRINTBILTESTOPTIONS_PRINTBILTESTOPTIONS_DUP06, "6.Quit\n"); |
|
3400 } |
3180 } |
3401 |
3181 |
3402 void PrintWriteOptions() |
3182 void PrintWriteOptions() |
3403 { |
3183 { |
3404 test.Printf(_L("Select an option\n")); |
3184 test.Printf(_L("Select an option\n")); |
3405 OstTrace0(TRACE_NORMAL, PRINTWRITEOPTIONS_PRINTWRITEOPTIONS, "Select an option\n"); |
|
3406 test.Printf(_L("1.Test single buffer write\n")); |
3185 test.Printf(_L("1.Test single buffer write\n")); |
3407 OstTrace0(TRACE_NORMAL, PRINTWRITEOPTIONS_PRINTWRITEOPTIONS_DUP01, "1.Test single buffer write\n"); |
|
3408 test.Printf(_L("2.Test double buffer write\n")); |
3186 test.Printf(_L("2.Test double buffer write\n")); |
3409 OstTrace0(TRACE_NORMAL, PRINTWRITEOPTIONS_PRINTWRITEOPTIONS_DUP02, "2.Test double buffer write\n"); |
|
3410 test.Printf(_L("3.Test multiple queing write\n")); |
3187 test.Printf(_L("3.Test multiple queing write\n")); |
3411 OstTrace0(TRACE_NORMAL, PRINTWRITEOPTIONS_PRINTWRITEOPTIONS_DUP03, "3.Test multiple queing write\n"); |
|
3412 } |
3188 } |
3413 |
3189 |
3414 |
3190 |
3415 _LIT(KLitHostToDev,"Host to Device"); |
3191 _LIT(KLitHostToDev,"Host to Device"); |
3416 _LIT(KLitDevToHost,"Device to Host"); |
3192 _LIT(KLitDevToHost,"Device to Host"); |
3433 { |
3209 { |
3434 |
3210 |
3435 if(setup != NULL) |
3211 if(setup != NULL) |
3436 { |
3212 { |
3437 test.Printf(_L("EP0 command:\n")); |
3213 test.Printf(_L("EP0 command:\n")); |
3438 OstTrace0(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT, "EP0 command:\n"); |
|
3439 test.Printf(_L("Direction: %S, "),KLitDirections[(setup->iRequestType>>KDirBit) & 0x1]); |
3214 test.Printf(_L("Direction: %S, "),KLitDirections[(setup->iRequestType>>KDirBit) & 0x1]); |
3440 OstTraceExt1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP01, "Direction: %S, ",*KLitDirections[(setup->iRequestType>>KDirBit) & 0x1]); |
|
3441 test.Printf(_L("Request type: %S, "), KLitType[((setup->iRequestType>>KReqTypeBit) & 0x3)]); |
3215 test.Printf(_L("Request type: %S, "), KLitType[((setup->iRequestType>>KReqTypeBit) & 0x3)]); |
3442 OstTraceExt1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP02, "Request type: %S, ", *KLitType[((setup->iRequestType>>KReqTypeBit) & 0x3)]); |
|
3443 |
3216 |
3444 if (setup->iRequestType & KRecepientReservedMask) |
3217 if (setup->iRequestType & KRecepientReservedMask) |
3445 { |
|
3446 test.Printf(_L("Recepient: Unknown (0x%x), "), setup->iRequestType & KRecepientMask); |
3218 test.Printf(_L("Recepient: Unknown (0x%x), "), setup->iRequestType & KRecepientMask); |
3447 OstTrace1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP03, "Recepient: Unknown (0x%x), ", setup->iRequestType & KRecepientMask); |
|
3448 } |
|
3449 else |
3219 else |
3450 { |
|
3451 test.Printf(_L("Recepient: %S\n"), KLitDest[(setup->iRequestType & KRecepientMask)]); |
3220 test.Printf(_L("Recepient: %S\n"), KLitDest[(setup->iRequestType & KRecepientMask)]); |
3452 OstTraceExt1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP04, "Recepient: %S\n", *KLitDest[(setup->iRequestType & KRecepientMask)]); |
|
3453 } |
|
3454 |
3221 |
3455 test.Printf(_L("bRequest:0x%x, "),setup->iRequest); |
3222 test.Printf(_L("bRequest:0x%x, "),setup->iRequest); |
3456 OstTrace1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP05, "bRequest:0x%x, ",setup->iRequest); |
|
3457 test.Printf(_L("wValue:0x%x, "),setup->iwValue); |
3223 test.Printf(_L("wValue:0x%x, "),setup->iwValue); |
3458 OstTrace1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP06, "wValue:0x%x, ",setup->iwValue); |
|
3459 test.Printf(_L("wIndex:0x%x, "),setup->iwIndex); |
3224 test.Printf(_L("wIndex:0x%x, "),setup->iwIndex); |
3460 OstTrace1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP07, "wIndex:0x%x, ",setup->iwIndex); |
|
3461 test.Printf(_L("wLength:0x%x\n"),setup->iWlength); |
3225 test.Printf(_L("wLength:0x%x\n"),setup->iWlength); |
3462 OstTrace1(TRACE_NORMAL, PRINTSETUPPKT_PRINTSETUPPKT_DUP08, "wLength:0x%x\n",setup->iWlength); |
|
3463 } |
3226 } |
3464 } |
3227 } |
3465 |
3228 |
3466 void WriteDataToBuffer(TAny* aBufferStartAddr,TUint aLength,TDes8& aWriteBuf) |
3229 void WriteDataToBuffer(TAny* aBufferStartAddr,TUint aLength,TDes8& aWriteBuf) |
3467 { |
3230 { |
3471 for(i=0;i<aLength;i++) |
3234 for(i=0;i<aLength;i++) |
3472 { |
3235 { |
3473 aWriteBuf.Append(i); //data is duplicated here in writebuffer and sc location, cant think of anyth better at the moment; |
3236 aWriteBuf.Append(i); //data is duplicated here in writebuffer and sc location, cant think of anyth better at the moment; |
3474 *(scBufferAddr) = i; |
3237 *(scBufferAddr) = i; |
3475 //test.Printf(_L("Addr:0x%x, data[i]:%d "),scBufferAddr,*(scBufferAddr)); |
3238 //test.Printf(_L("Addr:0x%x, data[i]:%d "),scBufferAddr,*(scBufferAddr)); |
3476 //OstTraceExt2(TRACE_NORMAL, WRITEDATATOBUFFER_WRITEDATATOBUFFER, "Addr:0x%x, data[i]:%d ",scBufferAddr,*(scBufferAddr)); |
|
3477 scBufferAddr += 1; |
3239 scBufferAddr += 1; |
3478 } |
3240 } |
3479 } |
3241 } |
3480 void BILWrite(TDes8& aWriteBuf) |
3242 void BILWrite(TDes8& aWriteBuf) |
3481 { |
3243 { |
3482 TInt ret = KErrNone; |
3244 TInt ret = KErrNone; |
3483 test.Printf(_L("TestBILWrite\n")); |
3245 test.Printf(_L("TestBILWrite\n")); |
3484 OstTrace0(TRACE_NORMAL, BILWRITE_BILWRITE, "TestBILWrite\n"); |
|
3485 TEndpointBuffer epBuf; |
3246 TEndpointBuffer epBuf; |
3486 const TUint KWriteEp = 1; |
3247 const TUint KWriteEp = 1; |
3487 TRequestStatus status; |
3248 TRequestStatus status; |
3488 TRequestStatus status1,status2; |
3249 TRequestStatus status1,status2; |
3489 TUint length; |
3250 TUint length; |
3500 switch(ch) |
3261 switch(ch) |
3501 { |
3262 { |
3502 case '1': |
3263 case '1': |
3503 //case 1: Write a buffer fulll of data to USBIO demo app: Total data written- 1xBuffersize |
3264 //case 1: Write a buffer fulll of data to USBIO demo app: Total data written- 1xBuffersize |
3504 test.Printf(_L("Length to be written: %d\n"),length); |
3265 test.Printf(_L("Length to be written: %d\n"),length); |
3505 OstTrace1(TRACE_NORMAL, BILWRITE_BILWRITE_DUP01, "Length to be written: %d\n",length); |
|
3506 WriteDataToBuffer(buffer,length,aWriteBuf); |
3266 WriteDataToBuffer(buffer,length,aWriteBuf); |
3507 //need to check allignment |
3267 //need to check allignment |
3508 test.Printf(_L("Data ready to be written out, Start 'read to file' on an IN endpoint onthe USBIO demo application then press a key when ready to proceed\n")); |
3268 test.Printf(_L("Data ready to be written out, Start 'read to file' on an IN endpoint onthe USBIO demo application then press a key when ready to proceed\n")); |
3509 OstTrace0(TRACE_NORMAL, BILWRITE_BILWRITE_DUP02, "Data ready to be written out, Start 'read to file' on an IN endpoint onthe USBIO demo application then press a key when ready to proceed\n"); |
|
3510 test.Getch(); |
3269 test.Getch(); |
3511 test_KErrNone(epBuf.WriteBuffer(buffer,length,ETrue,status)); |
3270 test_KErrNone(epBuf.WriteBuffer(buffer,length,ETrue,status)); |
3512 //Note-Till here is common for all options and can be put in a common place. Repeating the code for the sake of better understanding |
3271 //Note-Till here is common for all options and can be put in a common place. Repeating the code for the sake of better understanding |
3513 User::WaitForRequest(status); |
3272 User::WaitForRequest(status); |
3514 if(gVerbose) |
3273 if(gVerbose) |
3515 test.Printf(_L("Write status %d\n"),status.Int()); |
3274 test.Printf(_L("Write status %d\n"),status.Int()); |
3516 OstTrace1(TRACE_NORMAL, BILWRITE_BILWRITE_DUP03, "Write status %d\n",status.Int()); |
|
3517 test_KErrNone(status.Int()); |
3275 test_KErrNone(status.Int()); |
3518 test.Printf(_L("Total bytes written:%d\n"),aWriteBuf.Length()); |
3276 test.Printf(_L("Total bytes written:%d\n"),aWriteBuf.Length()); |
3519 OstTrace1(TRACE_NORMAL, BILWRITE_BILWRITE_DUP04, "Total bytes written:%d\n",aWriteBuf.Length()); |
|
3520 test.Printf(_L("Stop writing at the USBIO demo dialog window, Press a key to continue##\n")); |
3277 test.Printf(_L("Stop writing at the USBIO demo dialog window, Press a key to continue##\n")); |
3521 OstTrace0(TRACE_NORMAL, BILWRITE_BILWRITE_DUP05, "Stop writing at the USBIO demo dialog window, Press a key to continue##\n"); |
|
3522 test.Getch(); |
3278 test.Getch(); |
3523 break; |
3279 break; |
3524 |
3280 |
3525 case '2': |
3281 case '2': |
3526 //case 2: Write a buffer fulll of data to USBIO demo app wait until it is written out, write a second buffer full of data: Total data written- 2xBuffersize |
3282 //case 2: Write a buffer fulll of data to USBIO demo app wait until it is written out, write a second buffer full of data: Total data written- 2xBuffersize |
3527 WriteDataToBuffer(buffer,length,aWriteBuf); |
3283 WriteDataToBuffer(buffer,length,aWriteBuf); |
3528 test.Printf(_L("Data ready to be written out, Start the write mode on USBIO demo application and press a key when ready to proceed\n")); |
3284 test.Printf(_L("Data ready to be written out, Start the write mode on USBIO demo application and press a key when ready to proceed\n")); |
3529 OstTrace0(TRACE_NORMAL, BILWRITE_BILWRITE_DUP06, "Data ready to be written out, Start the write mode on USBIO demo application and press a key when ready to proceed\n"); |
|
3530 test.Getch(); |
3285 test.Getch(); |
3531 ret = epBuf.WriteBuffer(buffer,length,EFalse,status); |
3286 ret = epBuf.WriteBuffer(buffer,length,EFalse,status); |
3532 test_KErrNone(ret); |
3287 test_KErrNone(ret); |
3533 User::WaitForRequest(status); |
3288 User::WaitForRequest(status); |
3534 test_KErrNone(status.Int()); |
3289 test_KErrNone(status.Int()); |
3538 test_KErrNone(ret); |
3293 test_KErrNone(ret); |
3539 User::WaitForRequest(status); |
3294 User::WaitForRequest(status); |
3540 test_KErrNone(status.Int()); |
3295 test_KErrNone(status.Int()); |
3541 |
3296 |
3542 test.Printf(_L("Total bytes written:%d\n"),aWriteBuf.Length()); |
3297 test.Printf(_L("Total bytes written:%d\n"),aWriteBuf.Length()); |
3543 OstTrace1(TRACE_NORMAL, BILWRITE_BILWRITE_DUP07, "Total bytes written:%d\n",aWriteBuf.Length()); |
|
3544 test.Printf(_L("Stop writing at the USBIO demo dialog window,Press a key to continue\n")); |
3298 test.Printf(_L("Stop writing at the USBIO demo dialog window,Press a key to continue\n")); |
3545 OstTrace0(TRACE_NORMAL, BILWRITE_BILWRITE_DUP08, "Stop writing at the USBIO demo dialog window,Press a key to continue\n"); |
|
3546 test.Getch(); |
3299 test.Getch(); |
3547 break; |
3300 break; |
3548 |
3301 |
3549 case '3': |
3302 case '3': |
3550 //case 3: Write maxpacketsize (64 bytes) of data to USBIO demo app, queue remianing data in buffer (full buffer length-maxpacket size), wait for results: Total data written- 1xBuffersize |
3303 //case 3: Write maxpacketsize (64 bytes) of data to USBIO demo app, queue remianing data in buffer (full buffer length-maxpacket size), wait for results: Total data written- 1xBuffersize |
3551 WriteDataToBuffer(buffer,64,aWriteBuf); |
3304 WriteDataToBuffer(buffer,64,aWriteBuf); |
3552 test.Printf(_L("Data ready to be written out, Start the write mode on USBIO demo application and press a key when ready to proceed\n")); |
3305 test.Printf(_L("Data ready to be written out, Start the write mode on USBIO demo application and press a key when ready to proceed\n")); |
3553 OstTrace0(TRACE_NORMAL, BILWRITE_BILWRITE_DUP09, "Data ready to be written out, Start the write mode on USBIO demo application and press a key when ready to proceed\n"); |
|
3554 test.Getch(); |
3306 test.Getch(); |
3555 |
3307 |
3556 ret = epBuf.WriteBuffer(buffer,64,EFalse,status1); |
3308 ret = epBuf.WriteBuffer(buffer,64,EFalse,status1); |
3557 test_KErrNone(ret); |
3309 test_KErrNone(ret); |
3558 |
3310 |
3564 test_KErrNone(status1.Int()); |
3316 test_KErrNone(status1.Int()); |
3565 User::WaitForRequest(status2); |
3317 User::WaitForRequest(status2); |
3566 test_KErrNone(status2.Int()); |
3318 test_KErrNone(status2.Int()); |
3567 |
3319 |
3568 test.Printf(_L("Total bytes written: %d\n"),aWriteBuf.Length()); |
3320 test.Printf(_L("Total bytes written: %d\n"),aWriteBuf.Length()); |
3569 OstTrace1(TRACE_NORMAL, BILWRITE_BILWRITE_DUP10, "Total bytes written: %d\n",aWriteBuf.Length()); |
|
3570 test.Printf(_L("Stop writing at the USBIO demo dialog window,Press a key to continue\n")); |
3321 test.Printf(_L("Stop writing at the USBIO demo dialog window,Press a key to continue\n")); |
3571 OstTrace0(TRACE_NORMAL, BILWRITE_BILWRITE_DUP11, "Stop writing at the USBIO demo dialog window,Press a key to continue\n"); |
|
3572 test.Getch(); |
3322 test.Getch(); |
3573 break; |
3323 break; |
3574 |
3324 |
3575 default: |
3325 default: |
3576 ch='R'; //repeat |
3326 ch='R'; //repeat |
3584 |
3334 |
3585 |
3335 |
3586 void BILRead(TDes8& aReadBuf) |
3336 void BILRead(TDes8& aReadBuf) |
3587 { |
3337 { |
3588 test.Printf(_L("TestBILRead\n")); |
3338 test.Printf(_L("TestBILRead\n")); |
3589 OstTrace0(TRACE_NORMAL, BILREAD_BILREAD, "TestBILRead\n"); |
|
3590 TEndpointBuffer epBuf; |
3339 TEndpointBuffer epBuf; |
3591 const TUint KReadEp = 2; |
3340 const TUint KReadEp = 2; |
3592 TRequestStatus status; |
3341 TRequestStatus status; |
3593 |
3342 |
3594 //Open endpoint |
3343 //Open endpoint |
3595 gPort.OpenEndpoint(epBuf,KReadEp); |
3344 gPort.OpenEndpoint(epBuf,KReadEp); |
3596 test.Printf(_L("Open endpoint results for read endpoint\n")); |
3345 test.Printf(_L("Open endpoint results for read endpoint\n")); |
3597 OstTrace0(TRACE_NORMAL, BILREAD_BILREAD_DUP01, "Open endpoint results for read endpoint\n"); |
|
3598 |
3346 |
3599 //call GetBuffer, loop as long as EoF is not received |
3347 //call GetBuffer, loop as long as EoF is not received |
3600 TAny *readBuf; |
3348 TAny *readBuf; |
3601 TUint aSize; |
3349 TUint aSize; |
3602 TBool aZlp; |
3350 TBool aZlp; |
3606 aSize = 0; |
3354 aSize = 0; |
3607 aZlp = EFalse; |
3355 aZlp = EFalse; |
3608 TInt ret = KErrGeneral; |
3356 TInt ret = KErrGeneral; |
3609 ret = epBuf.GetBuffer(readBuf,aSize,aZlp,status); |
3357 ret = epBuf.GetBuffer(readBuf,aSize,aZlp,status); |
3610 if(gVerbose) |
3358 if(gVerbose) |
3611 { |
|
3612 test.Printf(_L("Getbuffer call returned %d, aSize: %d, aZlp: %d\n"),ret, aSize,aZlp); |
3359 test.Printf(_L("Getbuffer call returned %d, aSize: %d, aZlp: %d\n"),ret, aSize,aZlp); |
3613 OstTraceExt3(TRACE_NORMAL, BILREAD_BILREAD_DUP02, "Getbuffer call returned %d, aSize: %u, aZlp: %d\n",ret, aSize,aZlp); |
|
3614 } |
|
3615 |
3360 |
3616 if(ret == KErrCompletion) |
3361 if(ret == KErrCompletion) |
3617 { |
3362 { |
3618 //add the data to read buffer |
3363 //add the data to read buffer |
3619 TUint8 *buffer = (TUint8 *)readBuf; |
3364 TUint8 *buffer = (TUint8 *)readBuf; |
3621 } |
3366 } |
3622 else |
3367 else |
3623 { |
3368 { |
3624 test_KErrNone(ret); |
3369 test_KErrNone(ret); |
3625 test.Printf(_L("Waiting for Data, Data read so far: %d\n"),aReadBuf.Length()); |
3370 test.Printf(_L("Waiting for Data, Data read so far: %d\n"),aReadBuf.Length()); |
3626 OstTrace1(TRACE_NORMAL, BILREAD_BILREAD_DUP03, "Waiting for Data, Data read so far: %d\n",aReadBuf.Length()); |
|
3627 User::WaitForRequest(status); |
3371 User::WaitForRequest(status); |
3628 } |
3372 } |
3629 } |
3373 } |
3630 while(!aZlp); |
3374 while(!aZlp); |
3631 |
3375 |
3637 TInt wrLength = aWriteBuf.Length(); |
3381 TInt wrLength = aWriteBuf.Length(); |
3638 TInt rdLength = aReadBuf.Length(); |
3382 TInt rdLength = aReadBuf.Length(); |
3639 if(wrLength != rdLength) |
3383 if(wrLength != rdLength) |
3640 { |
3384 { |
3641 test.Printf(_L("Error: Disparity between length of data written and read back!")); |
3385 test.Printf(_L("Error: Disparity between length of data written and read back!")); |
3642 OstTrace0(TRACE_NORMAL, BILREAD_BILREAD_DUP04, "Error: Disparity between length of data written and read back!"); |
|
3643 return EFalse; |
3386 return EFalse; |
3644 } |
3387 } |
3645 for(TInt i=0; i < wrLength; i++) |
3388 for(TInt i=0; i < wrLength; i++) |
3646 { |
3389 { |
3647 if (aReadBuf[i] != aWriteBuf[i]) |
3390 if (aReadBuf[i] != aWriteBuf[i]) |
3648 { |
3391 { |
3649 test.Printf(_L("Error: for i = %d:"), i); |
3392 test.Printf(_L("Error: for i = %d:"), i); |
3650 OstTrace1(TRACE_NORMAL, BILREAD_BILREAD_DUP05, "Error: for i = %d:", i); |
|
3651 test.Printf(_L("aReadBuf: %d != aWriteBuf: %d"), |
3393 test.Printf(_L("aReadBuf: %d != aWriteBuf: %d"), |
3652 aReadBuf[i], aWriteBuf[i]); |
|
3653 OstTraceExt2(TRACE_NORMAL, BILREAD_BILREAD_DUP06, "aReadBuf: %d != aWriteBuf: %d", |
|
3654 aReadBuf[i], aWriteBuf[i]); |
3394 aReadBuf[i], aWriteBuf[i]); |
3655 return EFalse; |
3395 return EFalse; |
3656 } |
3396 } |
3657 } |
3397 } |
3658 return ETrue; |
3398 return ETrue; |
3671 { |
3411 { |
3672 TRequestStatus status; |
3412 TRequestStatus status; |
3673 |
3413 |
3674 test.Next(_L("TestBILReadWrite")); |
3414 test.Next(_L("TestBILReadWrite")); |
3675 test.Printf(_L("Open global USB channel")); |
3415 test.Printf(_L("Open global USB channel")); |
3676 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE, "Open global USB channel"); |
|
3677 TInt r = gPort.Open(0); |
3416 TInt r = gPort.Open(0); |
3678 test_KErrNone(r); |
3417 test_KErrNone(r); |
3679 //Test for a simple interface with 2 endpoints |
3418 //Test for a simple interface with 2 endpoints |
3680 test.Printf(_L("Set up interface\n")); |
3419 test.Printf(_L("Set up interface\n")); |
3681 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP01, "Set up interface\n"); |
|
3682 SetupBulkInterfaces(0,1,1); |
3420 SetupBulkInterfaces(0,1,1); |
3683 RChunk *tChunk = &gChunk; |
3421 RChunk *tChunk = &gChunk; |
3684 test.Printf(_L("Finalize Interface\n")); |
3422 test.Printf(_L("Finalize Interface\n")); |
3685 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP02, "Finalize Interface\n"); |
|
3686 gPort.FinalizeInterface(tChunk); |
3423 gPort.FinalizeInterface(tChunk); |
3687 |
3424 |
3688 if(gRealHardware) |
3425 if(gRealHardware) |
3689 { |
3426 { |
3690 test.Printf(_L("Please Start the USBIO demo application on the host side \n")); |
3427 test.Printf(_L("Please Start the USBIO demo application on the host side \n")); |
3691 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP03, "Please Start the USBIO demo application on the host side \n"); |
|
3692 gPort.ReEnumerate(status); |
3428 gPort.ReEnumerate(status); |
3693 User::WaitForRequest(status); |
3429 User::WaitForRequest(status); |
3694 test.Printf(_L("Enumerated. status = %d\n"), status.Int()); |
3430 test.Printf(_L("Enumerated. status = %d\n"), status.Int()); |
3695 OstTrace1(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP04, "Enumerated. status = %d\n", status.Int()); |
|
3696 test.Printf(_L("The following test attempts to write data to the host application. USBIO demo application is used on the PC side.\ |
3431 test.Printf(_L("The following test attempts to write data to the host application. USBIO demo application is used on the PC side.\ |
3697 Using USBIO demo app, user should capture data to a file. When prompted, use USBIO application to send the recorded file back to device.\ |
3432 Using USBIO demo app, user should capture data to a file. When prompted, use USBIO application to send the recorded file back to device.\ |
3698 The device side application will compare the data and show the result\n")); |
3433 The device side application will compare the data and show the result\n")); |
3699 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP05, "The following test attempts to write data to the host application. USBIO demo application is used on the PC side."\ |
|
3700 L"Using USBIO demo app, user should capture data to a file. When prompted, use USBIO application to send the recorded file back to device."\ |
|
3701 L"The device side application will compare the data and show the result\n"); |
|
3702 test.Printf(_L("Test Write using BIL apis\n")); |
3434 test.Printf(_L("Test Write using BIL apis\n")); |
3703 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP06, "Test Write using BIL apis\n"); |
|
3704 BILWrite(iWriteBuf); |
3435 BILWrite(iWriteBuf); |
3705 |
3436 |
3706 test.Printf(_L("Test Read using BIL api's\n")); |
3437 test.Printf(_L("Test Read using BIL api's\n")); |
3707 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP07, "Test Read using BIL api's\n"); |
|
3708 BILRead(iReadBuf); |
3438 BILRead(iReadBuf); |
3709 |
3439 |
3710 test.Printf(_L("Compare Read and Write buffers\n")); |
3440 test.Printf(_L("Compare Read and Write buffers\n")); |
3711 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP08, "Compare Read and Write buffers\n"); |
|
3712 TBool ret = CompareBuffs(iReadBuf, iWriteBuf); |
3441 TBool ret = CompareBuffs(iReadBuf, iWriteBuf); |
3713 if(!ret) |
3442 if(!ret) |
3714 { |
3443 { |
3715 test.Printf(_L("!!warning- compare buffers found discrepancies!\n")); |
3444 test.Printf(_L("!!warning- compare buffers found discrepancies!\n")); |
3716 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP09, "!!warning- compare buffers found discrepancies!\n"); |
|
3717 } |
3445 } |
3718 } |
3446 } |
3719 gChunk.Close(); |
3447 gChunk.Close(); |
3720 test.Printf(_L("Close global USB channel\n")); |
3448 test.Printf(_L("Close global USB channel\n")); |
3721 OstTrace0(TRACE_NORMAL, TESTBILREADWRITE_TESTBILREADWRITE_DUP10, "Close global USB channel\n"); |
|
3722 gPort.Close(); |
3449 gPort.Close(); |
3723 } |
3450 } |
3724 |
3451 |
3725 //At present, test only tests that multiple intefaces can be set up. |
3452 //At present, test only tests that multiple intefaces can be set up. |
3726 void TestBILAlternateSettingChange() |
3453 void TestBILAlternateSettingChange() |
3727 { |
3454 { |
3728 TRequestStatus status; |
3455 TRequestStatus status; |
3729 |
3456 |
3730 test.Next(_L("BIL Alternate Setting Change")); |
3457 test.Next(_L("BIL Alternate Setting Change")); |
3731 test.Printf(_L("Open global USB channel")); |
3458 test.Printf(_L("Open global USB channel")); |
3732 OstTrace0(TRACE_NORMAL, TESTBILALTERNATESETTINGCHANGE_TESTBILALTERNATESETTINGCHANGE, "Open global USB channel"); |
|
3733 TInt r = gPort.Open(0); |
3459 TInt r = gPort.Open(0); |
3734 test_KErrNone(r); |
3460 test_KErrNone(r); |
3735 //Test for a simple interface with 2 endpoints |
3461 //Test for a simple interface with 2 endpoints |
3736 test.Printf(_L("Set up interface 0\n")); |
3462 test.Printf(_L("Set up interface 0\n")); |
3737 OstTrace0(TRACE_NORMAL, TESTBILALTERNATESETTINGCHANGE_TESTBILALTERNATESETTINGCHANGE_DUP01, "Set up interface 0\n"); |
|
3738 SetupBulkInterfaces(0,1,1); |
3463 SetupBulkInterfaces(0,1,1); |
3739 test.Printf(_L("Set up interface 1\n")); |
3464 test.Printf(_L("Set up interface 1\n")); |
3740 OstTrace0(TRACE_NORMAL, TESTBILALTERNATESETTINGCHANGE_TESTBILALTERNATESETTINGCHANGE_DUP02, "Set up interface 1\n"); |
|
3741 SetupBulkInterfaces(1,1,1); |
3465 SetupBulkInterfaces(1,1,1); |
3742 RChunk *tChunk = &gChunk; |
3466 RChunk *tChunk = &gChunk; |
3743 test.Printf(_L("Finalize Interface\n")); |
3467 test.Printf(_L("Finalize Interface\n")); |
3744 OstTrace0(TRACE_NORMAL, TESTBILALTERNATESETTINGCHANGE_TESTBILALTERNATESETTINGCHANGE_DUP03, "Finalize Interface\n"); |
|
3745 gPort.FinalizeInterface(tChunk); |
3468 gPort.FinalizeInterface(tChunk); |
3746 |
3469 |
3747 if(gRealHardware) |
3470 if(gRealHardware) |
3748 { |
3471 { |
3749 gPort.ReEnumerate(status); |
3472 gPort.ReEnumerate(status); |
3750 User::WaitForRequest(status); |
3473 User::WaitForRequest(status); |
3751 test.Printf(_L("Enumerated. status = %d\n"), status.Int()); |
3474 test.Printf(_L("Enumerated. status = %d\n"), status.Int()); |
3752 OstTrace1(TRACE_NORMAL, TESTBILALTERNATESETTINGCHANGE_TESTBILALTERNATESETTINGCHANGE_DUP04, "Enumerated. status = %d\n", status.Int()); |
|
3753 } |
3475 } |
3754 gChunk.Close(); |
3476 gChunk.Close(); |
3755 test.Printf(_L("Close global USB channel\n")); |
3477 test.Printf(_L("Close global USB channel\n")); |
3756 OstTrace0(TRACE_NORMAL, TESTBILALTERNATESETTINGCHANGE_TESTBILALTERNATESETTINGCHANGE_DUP05, "Close global USB channel\n"); |
|
3757 gPort.Close(); |
3478 gPort.Close(); |
3758 } |
3479 } |
3759 |
3480 |
3760 /** |
3481 /** |
3761 Test EP0 Read/write using BIL api's |
3482 Test EP0 Read/write using BIL api's |
3778 test_KErrNone(gPort.FinalizeInterface(tChunk)); |
3499 test_KErrNone(gPort.FinalizeInterface(tChunk)); |
3779 |
3500 |
3780 if(gRealHardware) |
3501 if(gRealHardware) |
3781 { |
3502 { |
3782 test.Printf(_L("With USBIO, open and configure the device, then send then and then recieve at lest 4 class/vendor requests to interface 0\n")); |
3503 test.Printf(_L("With USBIO, open and configure the device, then send then and then recieve at lest 4 class/vendor requests to interface 0\n")); |
3783 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0, "With USBIO, open and configure the device, then send then and then recieve at lest 4 class/vendor requests to interface 0\n"); |
|
3784 |
3504 |
3785 TBool passed=EFalse; |
3505 TBool passed=EFalse; |
3786 TBool error=EFalse; |
3506 TBool error=EFalse; |
3787 gPort.ReEnumerate(status); |
3507 gPort.ReEnumerate(status); |
3788 User::WaitForRequest(status); |
3508 User::WaitForRequest(status); |
3817 if (keyStatus.Int()!=KRequestPending) |
3537 if (keyStatus.Int()!=KRequestPending) |
3818 { |
3538 { |
3819 if (test.Console()->KeyCode() == EKeyEscape) |
3539 if (test.Console()->KeyCode() == EKeyEscape) |
3820 break; |
3540 break; |
3821 else |
3541 else |
3822 { |
|
3823 test.Printf(_L("Press escape to end EP0 testing\n")); |
3542 test.Printf(_L("Press escape to end EP0 testing\n")); |
3824 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP01, "Press escape to end EP0 testing\n"); |
3543 |
3825 } |
|
3826 test.Console()->Read(keyStatus); |
3544 test.Console()->Read(keyStatus); |
3827 } |
3545 } |
3828 |
3546 |
3829 if (reqNeeded) |
3547 if (reqNeeded) |
3830 { |
3548 { |
3831 ret = epBuf.GetBuffer((TAny*&)readBuf,aSize,aZlp,status); |
3549 ret = epBuf.GetBuffer((TAny*&)readBuf,aSize,aZlp,status); |
3832 if(gVerbose) |
3550 if(gVerbose) |
3833 { |
|
3834 test.Printf(_L("Getbuffer returned %d, aSize: %d, aZlp: %d\n"),ret, aSize,aZlp); |
3551 test.Printf(_L("Getbuffer returned %d, aSize: %d, aZlp: %d\n"),ret, aSize,aZlp); |
3835 OstTraceExt3(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP02, "Getbuffer returned %d, aSize: %d, aZlp: %d\n",ret, aSize,aZlp); |
|
3836 } |
|
3837 } |
3552 } |
3838 |
3553 |
3839 if (ret==KErrNone) |
3554 if (ret==KErrNone) |
3840 { |
3555 { |
3841 User::WaitForRequest(status, keyStatus); |
3556 User::WaitForRequest(status, keyStatus); |
3846 } |
3561 } |
3847 else if (ret==TEndpointBuffer::KStateChange) |
3562 else if (ret==TEndpointBuffer::KStateChange) |
3848 { |
3563 { |
3849 TInt state = *((TInt*) readBuf); |
3564 TInt state = *((TInt*) readBuf); |
3850 test.Printf(_L("Status Change:! %d : %S \n"),state,((state<0) || (state>7))?KStates[8]:KStates[state]); |
3565 test.Printf(_L("Status Change:! %d : %S \n"),state,((state<0) || (state>7))?KStates[8]:KStates[state]); |
3851 OstTraceExt2(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP03, "Status Change:! %d : %S \n",state,((state<0) || (state>7))?*KStates[8]:*KStates[state]); |
|
3852 test_Equal(aSize, 4); |
3566 test_Equal(aSize, 4); |
3853 goodStateChange++; |
3567 goodStateChange++; |
3854 } |
3568 } |
3855 else |
3569 else |
3856 { |
3570 { |
3859 if (phase==0) //Header |
3573 if (phase==0) //Header |
3860 { |
3574 { |
3861 if (aSize!=8) |
3575 if (aSize!=8) |
3862 { |
3576 { |
3863 test.Printf(_L("Error: Malformed control packet of size %d.\n"),aSize); |
3577 test.Printf(_L("Error: Malformed control packet of size %d.\n"),aSize); |
3864 OstTrace1(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP04, "Error: Malformed control packet of size %d.\n",aSize); |
|
3865 error = ETrue; |
3578 error = ETrue; |
3866 } |
3579 } |
3867 else |
3580 else |
3868 { |
3581 { |
3869 setup = (Sep0SetupPacket* ) readBuf; |
3582 setup = (Sep0SetupPacket* ) readBuf; |
3871 |
3584 |
3872 if (setup->iRequestType&KDeviceToHost) |
3585 if (setup->iRequestType&KDeviceToHost) |
3873 { |
3586 { |
3874 // Send data |
3587 // Send data |
3875 test.Printf(_L("Sending %d bytes of data value increasing from 0x0 in 1 step. Verify data is received at the host\n"),setup->iWlength); |
3588 test.Printf(_L("Sending %d bytes of data value increasing from 0x0 in 1 step. Verify data is received at the host\n"),setup->iWlength); |
3876 OstTrace1(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP05, "Sending %d bytes of data value increasing from 0x0 in 1 step. Verify data is received at the host\n",setup->iWlength); |
|
3877 TUint8 *ep0Buffer; // = (TUint8 *)epBuf.Ep0In()BufferStart; |
3589 TUint8 *ep0Buffer; // = (TUint8 *)epBuf.Ep0In()BufferStart; |
3878 TUint ep0Length; |
3590 TUint ep0Length; |
3879 epBuf.GetInBufferRange(((TAny*&)ep0Buffer),ep0Length); |
3591 epBuf.GetInBufferRange(((TAny*&)ep0Buffer),ep0Length); |
3880 TUint8 *ep0Data = ep0Buffer; |
3592 TUint8 *ep0Data = ep0Buffer; |
3881 for(TUint8 i=0;i< setup->iWlength;i++) |
3593 for(TUint8 i=0;i< setup->iWlength;i++) |
3897 } |
3609 } |
3898 else |
3610 else |
3899 { |
3611 { |
3900 gPort.SendEp0StatusPacket(); |
3612 gPort.SendEp0StatusPacket(); |
3901 test.Printf(_L("No Data.\n")); |
3613 test.Printf(_L("No Data.\n")); |
3902 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP06, "No Data.\n"); |
|
3903 } |
3614 } |
3904 } // end HostToDevice type |
3615 } // end HostToDevice type |
3905 } //packet Correct length |
3616 } //packet Correct length |
3906 } |
3617 } |
3907 else // DataPhase |
3618 else // DataPhase |
3912 phase=0; |
3623 phase=0; |
3913 |
3624 |
3914 if (aZlp && dataLength) |
3625 if (aZlp && dataLength) |
3915 { |
3626 { |
3916 test.Printf(_L("\nError: ZLP received before enough data is read out!\nFailing Test!\n")); |
3627 test.Printf(_L("\nError: ZLP received before enough data is read out!\nFailing Test!\n")); |
3917 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP07, "\nError: ZLP received before enough data is read out!\nFailing Test!\n"); |
|
3918 error=ETrue; |
3628 error=ETrue; |
3919 phase=0; |
3629 phase=0; |
3920 } |
3630 } |
3921 |
3631 |
3922 if (!phase) |
3632 if (!phase) |
3923 { |
3633 { |
3924 gPort.SendEp0StatusPacket(); |
3634 gPort.SendEp0StatusPacket(); |
3925 //Print read out values |
3635 //Print read out values |
3926 test.Printf(_L("Data Read:")); |
3636 test.Printf(_L("Data Read:")); |
3927 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP08, "Data Read:"); |
|
3928 for(TInt i=0; i < iReadBuf.Length(); i++) |
3637 for(TInt i=0; i < iReadBuf.Length(); i++) |
3929 { |
3638 { |
3930 test.Printf(_L("0x%x "),iReadBuf[i]); |
3639 test.Printf(_L("0x%x "),iReadBuf[i]); |
3931 OstTrace1(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP09, "0x%x ",iReadBuf[i]); |
|
3932 } |
3640 } |
3933 test.Printf(_L("\n")); |
3641 test.Printf(_L("\n")); |
3934 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP10, "\n"); |
|
3935 goodReads++; |
3642 goodReads++; |
3936 } |
3643 } |
3937 |
3644 |
3938 } // end DataPhase |
3645 } // end DataPhase |
3939 } |
3646 } |
3946 |
3653 |
3947 if ((!passed) || (error)) |
3654 if ((!passed) || (error)) |
3948 { |
3655 { |
3949 if (!error) |
3656 if (!error) |
3950 test.Printf(_L("\nInsifishant reads/writes where seen to work, to pass test.\n")); |
3657 test.Printf(_L("\nInsifishant reads/writes where seen to work, to pass test.\n")); |
3951 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP11, "\nInsifishant reads/writes where seen to work, to pass test.\n"); |
|
3952 |
3658 |
3953 test.Printf(_L("\n ***************\n")); |
3659 test.Printf(_L("\n ***************\n")); |
3954 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP12, "\n ***************\n"); |
|
3955 test.Printf(_L(" * FAILED TEST *\n")); |
3660 test.Printf(_L(" * FAILED TEST *\n")); |
3956 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP13, " * FAILED TEST *\n"); |
|
3957 test.Printf(_L(" ***************\n\nKey to Continue.")); |
3661 test.Printf(_L(" ***************\n\nKey to Continue.")); |
3958 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP14, " ***************\n\nKey to Continue."); |
|
3959 } |
3662 } |
3960 else |
3663 else |
3961 { |
3664 { |
3962 test.Printf(_L("\nIf the USBIO demo application responded as expected, then this can be called a passed test.\n\nKey to Continue.\n")); |
3665 test.Printf(_L("\nIf the USBIO demo application responded as expected, then this can be called a passed test.\n\nKey to Continue.\n")); |
3963 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP15, "\nIf the USBIO demo application responded as expected, then this can be called a passed test.\n\nKey to Continue.\n"); |
|
3964 } |
3666 } |
3965 |
3667 |
3966 //Note- A disturbing fact! If host aborts data transmission and send a new setup packet, the userside is clueless as to what it's reading is |
3668 //Note- A disturbing fact! If host aborts data transmission and send a new setup packet, the userside is clueless as to what it's reading is |
3967 // data/setup data. |
3669 // data/setup data. |
3968 test.Getch(); |
3670 test.Getch(); |
3969 } // end if-real-hardware |
3671 } // end if-real-hardware |
3970 gChunk.Close(); |
3672 gChunk.Close(); |
3971 test.Printf(_L("Close global USB channel\n")); |
3673 test.Printf(_L("Close global USB channel\n")); |
3972 OstTrace0(TRACE_NORMAL, TESTBILEP0_TESTBILEP0_DUP16, "Close global USB channel\n"); |
|
3973 gPort.Close(); |
3674 gPort.Close(); |
3974 } // end funcion |
3675 } // end funcion |
3975 |
3676 |
3976 |
3677 |
3977 |
3678 |
4225 } |
3926 } |
4226 default: |
3927 default: |
4227 if (gSpecTest>=EBilRw) |
3928 if (gSpecTest>=EBilRw) |
4228 TestBIL(); |
3929 TestBIL(); |
4229 else |
3930 else |
4230 { |
|
4231 test.Printf(_L("No such option \n")); |
3931 test.Printf(_L("No such option \n")); |
4232 OstTrace0(TRACE_NORMAL, STARTTESTS_STARTTESTS, "No such option \n"); |
|
4233 } |
|
4234 } |
3932 } |
4235 |
3933 |
4236 |
3934 |
4237 } |
3935 } |
4238 |
3936 |
4315 if(token.Length()!=0) |
4013 if(token.Length()!=0) |
4316 { |
4014 { |
4317 if ((token==_L("help")) || (token==_L("-h")) || (token==_L("/h")) || (token==_L("-?")) || (token==_L("/?"))) |
4015 if ((token==_L("help")) || (token==_L("-h")) || (token==_L("/h")) || (token==_L("-?")) || (token==_L("/?"))) |
4318 { |
4016 { |
4319 test.Printf(_L("\nThis tests the Shared chunk version of the USBC driver. It focuses on the elements specific to this driver and should be used in conjuntion with other USBC tests in order to validate the driver.\n\n")); |
4017 test.Printf(_L("\nThis tests the Shared chunk version of the USBC driver. It focuses on the elements specific to this driver and should be used in conjuntion with other USBC tests in order to validate the driver.\n\n")); |
4320 OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE, "\nThis tests the Shared chunk version of the USBC driver. It focuses on the elements specific to this driver and should be used in conjuntion with other USBC tests in order to validate the driver.\n\n"); |
|
4321 test.Printf(_L("\n -h : Help.\n -r : test on Real hardware\n -v : Verbose\n -V : Very verbose\n-t <test> : Run a specific test.\n")); |
4018 test.Printf(_L("\n -h : Help.\n -r : test on Real hardware\n -v : Verbose\n -V : Very verbose\n-t <test> : Run a specific test.\n")); |
4322 OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP01, "\n -h : Help.\n -r : test on Real hardware\n -v : Verbose\n -V : Very verbose\n-t <test> : Run a specific test.\n"); |
|
4323 test.Printf(_L("\nAvailable tests: buf_read, buf_write, ep0, altset, interface, cancel, api, descriptor, bil_rw, bil_ep0, bil_alt\n")); |
4019 test.Printf(_L("\nAvailable tests: buf_read, buf_write, ep0, altset, interface, cancel, api, descriptor, bil_rw, bil_ep0, bil_alt\n")); |
4324 OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP02, "\nAvailable tests: buf_read, buf_write, ep0, altset, interface, cancel, api, descriptor, bil_rw, bil_ep0, bil_alt\n"); |
|
4325 err=KErrCancel; |
4020 err=KErrCancel; |
4326 } |
4021 } |
4327 else |
4022 else |
4328 if (token==_L("-r")) |
4023 if (token==_L("-r")) |
4329 gRealHardware = ETrue; |
4024 gRealHardware = ETrue; |
4404 break; |
4099 break; |
4405 |
4100 |
4406 if (err!=KErrNone) |
4101 if (err!=KErrNone) |
4407 { |
4102 { |
4408 if (err==KErrArgument) |
4103 if (err==KErrArgument) |
4409 { |
|
4410 test.Printf(_L("\nUnknown argument '%S%s%S'\n"), &token, (subtoken.Length()==0)?"":" ", &subtoken); |
4104 test.Printf(_L("\nUnknown argument '%S%s%S'\n"), &token, (subtoken.Length()==0)?"":" ", &subtoken); |
4411 OstTraceExt3(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP03, "\nUnknown argument '%S%S%S'\n", token, (subtoken.Length()==0)?_L(""):_L(" "), subtoken); |
|
4412 } |
|
4413 test.Printf(_L("\nUsage: t_usbcsc [-hrvVt]\n\n")); |
4105 test.Printf(_L("\nUsage: t_usbcsc [-hrvVt]\n\n")); |
4414 OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP04, "\nUsage: t_usbcsc [-hrvVt]\n\n"); |
|
4415 test.Getch(); |
4106 test.Getch(); |
4416 return err; |
4107 return err; |
4417 } |
4108 } |
4418 } |
4109 } |
4419 return KErrNone; |
4110 return KErrNone; |
4431 TInt muid = 0; |
4122 TInt muid = 0; |
4432 TInt r = HAL::Get(HAL::EMachineUid, muid); |
4123 TInt r = HAL::Get(HAL::EMachineUid, muid); |
4433 if (r != KErrNone) |
4124 if (r != KErrNone) |
4434 { |
4125 { |
4435 test.Printf(_L("Unable to get Platform ID. Skipping tests\n")); |
4126 test.Printf(_L("Unable to get Platform ID. Skipping tests\n")); |
4436 OstTrace0(TRACE_NORMAL, E32MAIN_E32MAIN, "Unable to get Platform ID. Skipping tests\n"); |
|
4437 return KErrNone; |
4127 return KErrNone; |
4438 } |
4128 } |
4439 if (SupportsUsb() && (muid != HAL::EMachineUid_Lubbock)) |
4129 if (SupportsUsb() && (muid != HAL::EMachineUid_Lubbock)) |
4440 { |
4130 { |
4441 ProcessCommandLineOptions(); |
4131 ProcessCommandLineOptions(); |
4442 } |
4132 } |
4443 else |
4133 else |
4444 { |
4134 { |
4445 test.Printf(_L("USB is not supported on this platform. Skipping test\n")); |
4135 test.Printf(_L("USB is not supported on this platform. Skipping test\n")); |
4446 OstTrace0(TRACE_NORMAL, E32MAIN_E32MAIN_DUP01, "USB is not supported on this platform. Skipping test\n"); |
|
4447 } |
4136 } |
4448 |
4137 |
4449 test.End(); |
4138 test.End(); |
4450 __UHEAP_MARKEND; |
4139 __UHEAP_MARKEND; |
4451 |
4140 |