usbmgmt/usbmgrtest/t_catc/src/t_catc.cpp
branchRCL_3
changeset 43 012cc2ee6408
parent 42 f92a4f87e424
equal deleted inserted replaced
42:f92a4f87e424 43:012cc2ee6408
    35 
    35 
    36 TCommConfig TheConfigBuf;
    36 TCommConfig TheConfigBuf;
    37 TCommConfigV01& TheConfig = TheConfigBuf();
    37 TCommConfigV01& TheConfig = TheConfigBuf();
    38 
    38 
    39 const TInt KReceiveBufferLength = 65536/*16384*/; // TODO: speed enhancement!
    39 const TInt KReceiveBufferLength = 65536/*16384*/; // TODO: speed enhancement!
       
    40 //const TInt KMaxBufferSize = 8192; // TODO: speed enhancement!
    40 const TUint KChunkSize = 65536;
    41 const TUint KChunkSize = 65536;
    41 
    42 
    42 ////////////////////////////////////////////////////////////////////////////////
    43 ////////////////////////////////////////////////////////////////////////////////
    43 
    44 
       
    45 //_LIT(KUsbCsyName, "ECACM");
    44 _LIT(KUsbPortName, "ACM::0");
    46 _LIT(KUsbPortName, "ACM::0");
    45 _LIT(KUsbLddName, "EUSBC");
    47 _LIT(KUsbLddName, "EUSBC");
    46 
    48 
    47 ////////////////////////////////////////////////////////////////////////////////
    49 ////////////////////////////////////////////////////////////////////////////////
    48 
    50 
   133 	{
   135 	{
   134 	TRequestStatus consoleStatus;
   136 	TRequestStatus consoleStatus;
   135 	TRequestStatus status;
   137 	TRequestStatus status;
   136 	RComm port;
   138 	RComm port;
   137 
   139 
       
   140 //	static TBuf8<1024> OUT_Buf; // TODO: speed enhancement!
   138 	static TBuf8<KChunkSize> OUT_Buf;
   141 	static TBuf8<KChunkSize> OUT_Buf;
   139 
   142 
   140 	_printf(_L("\n"));
   143 	_printf(_L("\n"));
   141 	_printf(_L("+-----------------------------------------+\n"));
   144 	_printf(_L("+-----------------------------------------+\n"));
   142 	_printf(_L("|+---------------------------------------+|\n"));
   145 	_printf(_L("|+---------------------------------------+|\n"));
   157 	// prime the console for the abandon-ship
   160 	// prime the console for the abandon-ship
   158 
   161 
   159 	console->Read(consoleStatus);
   162 	console->Read(consoleStatus);
   160 	
   163 	
   161 	TInt uReadCount = 0 ;
   164 	TInt uReadCount = 0 ;
       
   165 	//TInt uThermoBar = 0 ; // TODO: speed enhancement! (remove ThermoBar fnality)
   162 
   166 
   163 	_printf(_L("\tWatch :  "));
   167 	_printf(_L("\tWatch :  "));
   164 
   168 
   165 	TInt uAvgCount = 0 ;
   169 	TInt uAvgCount = 0 ;
   166 	TInt uNumReads = 0 ;
   170 	TInt uNumReads = 0 ;
   210 				{
   214 				{
   211 				uAvgCount = ( ( 9 * uAvgCount ) + OUT_Buf.Length() ) / 10 ;
   215 				uAvgCount = ( ( 9 * uAvgCount ) + OUT_Buf.Length() ) / 10 ;
   212 				}
   216 				}
   213 
   217 
   214 			uReadCount += OUT_Buf.Length() ;
   218 			uReadCount += OUT_Buf.Length() ;
       
   219 
       
   220 /*			if( uReadCount >= 1024 )
       
   221 				{
       
   222 				// uThermoBar runs from 0..63
       
   223 
       
   224 				uThermoBar = ( uThermoBar + 1 ) & 0x3F ;
       
   225 
       
   226 				if( uThermoBar < 32 )
       
   227 					{
       
   228 					_printf(_L("*"));
       
   229 					}
       
   230 				else
       
   231 					{
       
   232 					_printf(_L("\b \b"));
       
   233 					}
       
   234 
       
   235 				uReadCount -= 1024 ;
       
   236 				}
       
   237 				*/
   215 			}
   238 			}
   216 		else
   239 		else
   217 			{
   240 			{
   218 			// user must have wanted to stop, shut down the reader
   241 			// user must have wanted to stop, shut down the reader
   219 
   242 
   245 	{
   268 	{
   246 	TRequestStatus consoleStatus;
   269 	TRequestStatus consoleStatus;
   247 	TRequestStatus status;
   270 	TRequestStatus status;
   248 	RComm port;
   271 	RComm port;
   249 
   272 
       
   273 //#define uInBufSize 4096 // TODO: speed enhancement! reduce number of IPC calls
   250 #define uInBufSize 65536
   274 #define uInBufSize 65536
   251 
   275 
   252 	static TBuf8<uInBufSize> IN_Buf;
   276 	static TBuf8<uInBufSize> IN_Buf;
   253 	static TBuf8<uInBufSize> ZLP_Buf;
   277 	static TBuf8<uInBufSize> ZLP_Buf;
   254 
   278 
   311 	TInt bDoneBlock = EFalse ;
   335 	TInt bDoneBlock = EFalse ;
   312 
   336 
   313 	TInt bNeedZLP = bUseZLP && ((IN_Buf.Length()%64)==0);
   337 	TInt bNeedZLP = bUseZLP && ((IN_Buf.Length()%64)==0);
   314 
   338 
   315 	TInt uWriteCount = 0 ;
   339 	TInt uWriteCount = 0 ;
       
   340 //	TInt uThermoBar = 0 ; // TODO: speed enhancement!
   316 
   341 
   317 	_printf(_L("\tWatch :  "));
   342 	_printf(_L("\tWatch :  "));
   318 
   343 
   319 	while (1)
   344 	while (1)
   320 		{
   345 		{
   351 				LEAVE(status.Int());
   376 				LEAVE(status.Int());
   352 				}
   377 				}
   353 
   378 
   354 			// reassure watcher that there is something happening...
   379 			// reassure watcher that there is something happening...
   355 
   380 
       
   381 /*			while( uWriteCount >= 1024 )
       
   382 				{
       
   383 				// uThermoBar runs from 0..63
       
   384 
       
   385 				uThermoBar = ( uThermoBar + 1 ) & 0x3F ;
       
   386 
       
   387 				if( uThermoBar < 32 )
       
   388 					{
       
   389 					_printf(_L("*"));
       
   390 					}
       
   391 				else
       
   392 					{
       
   393 					_printf(_L("\b \b"));
       
   394 					}
       
   395   
       
   396 				uWriteCount -= 1024 ;
       
   397 				}
       
   398 				*/
   356 			}
   399 			}
   357 		else
   400 		else
   358 			{
   401 			{
   359 			_printf(_L("\n\n\tCancelling Write()"));
   402 			_printf(_L("\n\n\tCancelling Write()"));
   360 
   403 
   453 	LEAVEIFERROR(status.Int());
   496 	LEAVEIFERROR(status.Int());
   454 
   497 
   455 	_printf(_L("Restarted USB.\n"));
   498 	_printf(_L("Restarted USB.\n"));
   456 	}
   499 	}
   457 
   500 
   458 
   501 ////////////////////////////////////////////////////////////////////////////////
       
   502 
       
   503 /*void ThermoBar()
       
   504 	{
       
   505 	TUint uCol = 0 ;
       
   506 
       
   507 	TTime		now;
       
   508 
       
   509 	TDateTime	WasDT;
       
   510 	TDateTime	NowDT;
       
   511 
       
   512 	now.HomeTime(); 
       
   513 	WasDT = now.DateTime();
       
   514 
       
   515 	for( TUint line = 0 ; line < 30 ; )
       
   516 		{
       
   517 		for( TUint dotO = 0 ; dotO < 1000 ; dotO++ )
       
   518 			{
       
   519 			for( TUint dotI = 0 ; dotI < 1000 ; dotI++ )
       
   520 				{
       
   521 				;
       
   522 				}
       
   523 			}
       
   524 
       
   525 		_printf(_L("*"));
       
   526 
       
   527 		now.HomeTime(); 
       
   528 		NowDT = now.DateTime();
       
   529 
       
   530 		if( ( ++uCol >= 79 ) || ( WasDT.Second() != NowDT.Second() ) )
       
   531 			{
       
   532 			_printf(_L("\n"));
       
   533 
       
   534 			uCol = 0 ;
       
   535 
       
   536 			line++ ;
       
   537 
       
   538 			WasDT = now.DateTime() ;
       
   539 			}
       
   540 		}
       
   541 	}
       
   542 */
       
   543 ////////////////////////////////////////////////////////////////////////////////
   459 
   544 
   460 void ToggleTermL()
   545 void ToggleTermL()
   461 	{
   546 	{
   462 	bUseTerm = ( bUseTerm == EFalse ) ;
   547 	bUseTerm = ( bUseTerm == EFalse ) ;
   463 
   548 
   572 		_printf(_L("\n"));
   657 		_printf(_L("\n"));
   573 		_printf(_L("1. Bulk OUT test    \n"));
   658 		_printf(_L("1. Bulk OUT test    \n"));
   574 		_printf(_L("2. Bulk IN  test    \n"));
   659 		_printf(_L("2. Bulk IN  test    \n"));
   575 		_printf(_L("3. Set handshaking  \n"));
   660 		_printf(_L("3. Set handshaking  \n"));
   576 		_printf(_L("4. Restart USB      \n"));
   661 		_printf(_L("4. Restart USB      \n"));
       
   662 //		_printf(_L("5. Run ThermoBar    \n"));
   577 		_printf(_L("6. Swap Read Method \n"));
   663 		_printf(_L("6. Swap Read Method \n"));
   578 		_printf(_L("7. Swap ZLP Method  \n"));
   664 		_printf(_L("7. Swap ZLP Method  \n"));
   579 		_printf(_L("8. Swap Term Method \n"));
   665 		_printf(_L("8. Swap Term Method \n"));
   580 		_printf(_L("\n"));
   666 		_printf(_L("\n"));
   581 		_printf(_L("Select (q to quit): "));
   667 		_printf(_L("Select (q to quit): "));
   587 			{
   673 			{
   588 		case '1': Bulk_OUT_TestL();							break;
   674 		case '1': Bulk_OUT_TestL();							break;
   589 		case '2': Bulk_IN_TestL();							break;
   675 		case '2': Bulk_IN_TestL();							break;
   590 		case '3': SetHandshakingL();						break;
   676 		case '3': SetHandshakingL();						break;
   591 		case '4': RestartUsbL();							break;
   677 		case '4': RestartUsbL();							break;
       
   678 //		case '5': ThermoBar();								break;
   592 		case '6': bReadCall = ( bReadCall == EFalse ) ;		break;
   679 		case '6': bReadCall = ( bReadCall == EFalse ) ;		break;
   593 		case '7': bUseZLP   = ( bUseZLP == EFalse ) ;		break;
   680 		case '7': bUseZLP   = ( bUseZLP == EFalse ) ;		break;
   594 		case '8': ToggleTermL() ;							break;
   681 		case '8': ToggleTermL() ;							break;
   595 
   682 
   596 		case 'q':
   683 		case 'q':