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