os/kernelhwsrv/kerneltest/e32test/device/t_firco.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/device/t_firco.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,673 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\device\t_firco.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "t_fir.h"
    1.22 +
    1.23 +#if defined(__VC32__) && _MSC_VER==1100
    1.24 +// Disable MSVC++ 5.0 aggressive warnings about non-expansion of inline functions. 
    1.25 +#pragma warning(disable : 4710)	// function '...' not expanded
    1.26 +#endif
    1.27 +
    1.28 +#ifdef __WINS__
    1.29 +	#include <es_sock.h>
    1.30 +	RSocketServ ss;
    1.31 +#endif
    1.32 +
    1.33 +TBuf8<2060> WriteBuf;
    1.34 +TBuf8<2060> ReadBuf;
    1.35 +TInt iTimeDelay=1000000;
    1.36 +TInt iBufSz=2000;
    1.37 +
    1.38 +CActiveConsole::CActiveConsole(CConsoleBase* aConsole) 
    1.39 +	: CActive(EPriorityNormal)
    1.40 +	{
    1.41 +	iConsole=aConsole;
    1.42 +	iInit1  =EFalse;
    1.43 +	iInit2  =EFalse;
    1.44 +	iInit3	=EFalse;
    1.45 +	}
    1.46 +
    1.47 +CActiveConsole* CActiveConsole::NewLC(CConsoleBase* aConsole)
    1.48 +	{
    1.49 +	CActiveConsole* self = new (ELeave) CActiveConsole(aConsole);
    1.50 +	self->ConstructL();
    1.51 +	return self;
    1.52 +	}
    1.53 +
    1.54 +void CActiveConsole::ConstructL ()
    1.55 +	{ 
    1.56 +	TFirCaps aCapsBuf;
    1.57 +	TFirCapsV01& aCaps=aCapsBuf();
    1.58 +	TFirConfig aConfigBuf;
    1.59 +	TFirConfigV01& aConfig=aConfigBuf();
    1.60 +
    1.61 +	iConsole->Printf(_L("\r\n"));
    1.62 +	CActiveScheduler::Add(this);			// Add to active scheduler
    1.63 +
    1.64 +	// Load Driver
    1.65 +	TInt ret=User::LoadPhysicalDevice(_L("Difir"));
    1.66 +	if (ret!=KErrNone)
    1.67 +		iConsole->Printf(_L("Error %d on loading Fir PDD\r\n"),ret);
    1.68 +	else
    1.69 +		iConsole->Printf(_L("Successfully loaded Fir PDD\r\n"));
    1.70 +
    1.71 +	ret=User::LoadLogicalDevice(_L("Efir"));
    1.72 +	if (ret!=KErrNone)
    1.73 +		iConsole->Printf(_L("Error %d on loading Fir LDD\r\n"),ret);
    1.74 +	else
    1.75 +		iConsole->Printf(_L("Successfully loaded Fir LDD\r\n"));
    1.76 +
    1.77 +	SetUpBuffers();
    1.78 +
    1.79 +	ret=iPort.Open(0);
    1.80 +	if (ret!=KErrNone)
    1.81 +		iConsole->Printf(_L("Error %d on opening Fastir port\r\n"),ret);
    1.82 +	else
    1.83 +		iConsole->Printf(_L("Successfully opened Fastir port\r\n"));
    1.84 +
    1.85 +
    1.86 +	ret=iPort.Caps(aCapsBuf);
    1.87 +	if (ret!=KErrNone)
    1.88 +		iConsole->Printf(_L("Error %d on getting caps\r\n"),ret);
    1.89 +	else
    1.90 +		iConsole->Printf(_L("Fir Caps: %d\r\n"),aCaps.iRate);
    1.91 +
    1.92 +/*	ret=iPort.Config(aConfigBuf);
    1.93 +	if (ret!=KErrNone)
    1.94 +		iConsole->Printf(_L("Error %d getting config\r\n"),ret);
    1.95 +	else
    1.96 +		{
    1.97 +		if(aConfig.iRate==EBps4000000)
    1.98 +			iConsole->Printf(_L("Fir config is 4Mbps\r\n"));
    1.99 +		}
   1.100 +
   1.101 +	aConfig.iRate=EBps4000000;
   1.102 +	ret=iPort.SetConfig(aConfigBuf);
   1.103 +	iConsole->Printf(_L("Error %d on SetConfig\r\n"),ret);*/
   1.104 +
   1.105 +	iWriter=CActiveWriter::NewL(iConsole,&iPort);
   1.106 +	if(iWriter)
   1.107 +		iConsole->Printf(_L("Have created writer\r\n"));
   1.108 +	else
   1.109 +		iConsole->Printf(_L("Failed to create writer\r\n"));
   1.110 +
   1.111 +	iReader=CActiveReader::NewL(iConsole,&iPort);
   1.112 +	if(iReader)
   1.113 +		iConsole->Printf(_L("Have created reader\r\n"));
   1.114 +	else
   1.115 +		iConsole->Printf(_L("Failed to create reader\r\n"));
   1.116 +	}
   1.117 +
   1.118 +CActiveConsole::~CActiveConsole()
   1.119 +	{
   1.120 +	// Make sure we're cancelled
   1.121 +	Cancel();
   1.122 +
   1.123 +	if(iWriter)
   1.124 +		delete iWriter;
   1.125 +	if(iReader)
   1.126 +		delete iReader;
   1.127 +
   1.128 +	iPort.Close();
   1.129 +	}
   1.130 +
   1.131 +void  CActiveConsole::DoCancel()
   1.132 +	{
   1.133 +	iConsole->ReadCancel();
   1.134 +	}
   1.135 +
   1.136 +void  CActiveConsole::RunL()
   1.137 +	{
   1.138 +	ProcessKeyPressL(TChar(iConsole->KeyCode()));
   1.139 +//	iConsole->Printf(_L("CActiveConsole - Completed with code %d\r\n\r\n"), iStatus.Int ());
   1.140 +	}
   1.141 +
   1.142 +void CActiveConsole::RequestCharacter()
   1.143 +	{
   1.144 +	if(!iInit1)
   1.145 +		{
   1.146 +		Options1();
   1.147 +		return;
   1.148 +		}
   1.149 +	if(!iInit2)
   1.150 +		{
   1.151 +		Options2();
   1.152 +		return;
   1.153 +		}
   1.154 +	if(!iInit3)
   1.155 +		{
   1.156 +		Options3();
   1.157 +		return;
   1.158 +		}
   1.159 +	  // A request is issued to the CConsoleBase to accept a
   1.160 +	  // character from the keyboard.
   1.161 +	iConsole->Printf(_L("*********************************\r\n"));
   1.162 +	iConsole->Printf(_L("press Escape to quit\r\n"));
   1.163 +	iConsole->Printf(_L("press '1'/'2' to start/stop reader\r\n"));
   1.164 +	iConsole->Printf(_L("press '3'/'4' to start/stop writer\r\n"));
   1.165 +	iConsole->Printf(_L("press '8' to show FIR regs\r\n"));
   1.166 +	iConsole->Printf(_L("press '9' to show Dma reader regs\r\n"));
   1.167 +	iConsole->Printf(_L("press '0' to show Dma writer regs\r\n"));
   1.168 +	iConsole->Printf(_L("press 'a' to show TxBuf info\r\n"));
   1.169 +	iConsole->Printf(_L("press 'b' to show RxBuf info\r\n"));
   1.170 +	iConsole->Printf(_L("press 'c' to show Chunk info\r\n"));
   1.171 +	iConsole->Printf(_L("press 'd' to show misc info\r\n"));
   1.172 +	iConsole->Read(iStatus); 
   1.173 +	SetActive();
   1.174 +	}
   1.175 +
   1.176 +void CActiveConsole::Options1()
   1.177 +	{
   1.178 +	iConsole->Printf(_L("*****Choose Delay*****\r\n"));
   1.179 +	iConsole->Printf(_L("press '1'  576000 baud\r\n"));
   1.180 +	iConsole->Printf(_L("press '2' 1152000 baud\r\n"));
   1.181 +	iConsole->Printf(_L("press '3' 4000000 baud\r\n"));
   1.182 +	iConsole->Read(iStatus); 
   1.183 +	SetActive();	
   1.184 +	}
   1.185 +
   1.186 +void CActiveConsole::Options2()
   1.187 +	{
   1.188 +	iConsole->Printf(_L("*****Choose Delay*****\r\n"));
   1.189 +	iConsole->Printf(_L("press '1' 1.00 sec delay\r\n"));
   1.190 +	iConsole->Printf(_L("press '2' 0.10 sec delay\r\n"));
   1.191 +	iConsole->Printf(_L("press '3' 0.01 sec delay\r\n"));
   1.192 +	iConsole->Printf(_L("press '4' 0.00 sec delay\r\n"));
   1.193 +	iConsole->Read(iStatus); 
   1.194 +	SetActive();	
   1.195 +	}
   1.196 +
   1.197 +void CActiveConsole::Options3()
   1.198 +	{
   1.199 +	iConsole->Printf(_L("****Choose Buf Sz*****\r\n"));
   1.200 +	iConsole->Printf(_L("press '1' 1    byte \r\n"));
   1.201 +	iConsole->Printf(_L("press '2' 4    bytes\r\n"));
   1.202 +	iConsole->Printf(_L("press '3' 16   bytes\r\n"));
   1.203 +	iConsole->Printf(_L("press '4' 64   bytes\r\n"));
   1.204 +	iConsole->Printf(_L("press '5' 128  bytes\r\n"));
   1.205 +	iConsole->Printf(_L("press '6' 2000 bytes\r\n"));
   1.206 +	iConsole->Printf(_L("press '7' 2051 bytes\r\n"));
   1.207 +	iConsole->Read(iStatus); 
   1.208 +	SetActive();	
   1.209 +	}
   1.210 +
   1.211 +void CActiveConsole::ProcessKeyPressL(TChar aChar)
   1.212 +	{
   1.213 +	if (aChar == EKeyEscape)
   1.214 +		{
   1.215 +		CActiveScheduler::Stop();
   1.216 +		return;
   1.217 +		}
   1.218 +
   1.219 +	if(!iInit1)
   1.220 +		{
   1.221 +		switch(aChar)
   1.222 +			{
   1.223 +		case '1':
   1.224 +			iBaudRate=EBps576000;
   1.225 +			break;
   1.226 +		case '2':
   1.227 +			iBaudRate=EBps1152000;
   1.228 +			break;
   1.229 +		case '3':
   1.230 +			iBaudRate=EBps4000000;
   1.231 +			break;
   1.232 +		default:
   1.233 +			iBaudRate=EBps4000000;
   1.234 +			break;
   1.235 +			}
   1.236 +		iConsole->Printf(_L("Baud rate: %d\r\n"),iBaudRate);
   1.237 +		iInit1=ETrue;
   1.238 +		TFirConfig aConfigBuf;
   1.239 +		TFirConfigV01& aConfig=aConfigBuf();
   1.240 +		aConfig.iRate=iBaudRate;
   1.241 +		TInt ret=iPort.SetConfig(aConfigBuf);
   1.242 +		iConsole->Printf(_L("Error %d on SetConfig\r\n"),ret);
   1.243 +		RequestCharacter();
   1.244 +		return;
   1.245 +		}
   1.246 +
   1.247 +	if(!iInit2)
   1.248 +		{
   1.249 +		switch(aChar)
   1.250 +			{
   1.251 +		case '1'://1 sec
   1.252 +			iTimeDelay=1000000;
   1.253 +			break;
   1.254 +		case '2'://0.1 sec
   1.255 +			iTimeDelay=100000;
   1.256 +			break;
   1.257 +		case '3'://0.01 sec
   1.258 +			iTimeDelay=10000;
   1.259 +			break;
   1.260 +		case '4'://0 sec
   1.261 +			iTimeDelay=0;
   1.262 +			break;
   1.263 +		default:
   1.264 +			iTimeDelay=1000000;
   1.265 +			break;
   1.266 +			}
   1.267 +		iConsole->Printf(_L("Time Delay: %d\r\n"),iTimeDelay);
   1.268 +		iInit2=ETrue;
   1.269 +		RequestCharacter();
   1.270 +		return;
   1.271 +		}
   1.272 +	if(!iInit3)
   1.273 +		{
   1.274 +		switch(aChar)
   1.275 +			{
   1.276 +		case '1':
   1.277 +			iBufSz=1;
   1.278 +			break;
   1.279 +		case '2':
   1.280 +			iBufSz=4;
   1.281 +			break;
   1.282 +		case '3':
   1.283 +			iBufSz=16;
   1.284 +			break;
   1.285 +		case '4':
   1.286 +			iBufSz=64;
   1.287 +			break;
   1.288 +		case '5':
   1.289 +			iBufSz=128;
   1.290 +			break;
   1.291 +		case '6':
   1.292 +			iBufSz=2000;
   1.293 +			break;
   1.294 +		case '7':
   1.295 +			iBufSz=2052;
   1.296 +			break;
   1.297 +		default:
   1.298 +			iBufSz=2000;
   1.299 +			break;
   1.300 +			}
   1.301 +		iConsole->Printf(_L("Buffer size: %d\r\n"),iBufSz);
   1.302 +		iInit3=ETrue;
   1.303 +		RequestCharacter();
   1.304 +		return;
   1.305 +		}
   1.306 +
   1.307 +	switch (aChar)
   1.308 +		{
   1.309 +	case '1'://start reader
   1.310 +		iReader->Start();
   1.311 +		break;
   1.312 +	case '2'://stop reader
   1.313 +		iReader->Stop();
   1.314 +		break;
   1.315 +	case '3'://start writer
   1.316 +		iWriter->Start();
   1.317 +		break;
   1.318 +	case '4'://stop writer
   1.319 +		iWriter->Stop();
   1.320 +		break;
   1.321 +	case '8'://get fir regs
   1.322 +		GetFirRegs();
   1.323 +		break;
   1.324 +	case '9'://get dma reader regs
   1.325 +		GetDmaReaderRegs();
   1.326 +		break;
   1.327 +	case '0'://get dma writer regs
   1.328 +		GetDmaWriterRegs();
   1.329 +		break;
   1.330 +	case 'a'://get TxBuf info
   1.331 +		GetWriteBufInfo();
   1.332 +		break;
   1.333 +	case 'b'://get RxBuf info
   1.334 +		GetReadBufInfo();
   1.335 +		break;
   1.336 +	case 'c'://get RxBuf info
   1.337 +		GetChunkInfo();
   1.338 +		break;
   1.339 +	case 'd':
   1.340 +		GetMiscInfo();
   1.341 +		break;
   1.342 +	default:
   1.343 +		iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
   1.344 +		break;
   1.345 +		}
   1.346 +	RequestCharacter ();
   1.347 +	return;
   1.348 +	}
   1.349 +
   1.350 +void CActiveConsole::GetFirRegs()
   1.351 +	{
   1.352 +/*	TInt r=0;
   1.353 +	TDebugFirRegs FirRegs;
   1.354 +	r=iPort.GetFirRegs(FirRegs);
   1.355 +	iConsole->Printf(_L("RxFrameStatus  : 0x%x\r\n"),FirRegs.RxFrameStatus);
   1.356 +	iConsole->Printf(_L("RxBufferEmpty  : 0x%x\r\n"),FirRegs.RxBufferEmpty);
   1.357 +	iConsole->Printf(_L("RxError        : 0x%x\r\n"),FirRegs.RxError);
   1.358 +	iConsole->Printf(_L("RxOverrun      : 0x%x\r\n"),FirRegs.RxOverrun);
   1.359 +	iConsole->Printf(_L("CrcError       : 0x%x\r\n"),FirRegs.CrcError);
   1.360 +	iConsole->Printf(_L("TxFrameStatus  : 0x%x\r\n"),FirRegs.TxFrameStatus);
   1.361 +	iConsole->Printf(_L("TxBufferEmpty  : 0x%x\r\n"),FirRegs.TxBufferEmpty);
   1.362 +	iConsole->Printf(_L("TxBufferSz     : 0x%x\r\n"),FirRegs.TxBufferSz);
   1.363 +	iConsole->Printf(_L("TxOverrun      : 0x%x\r\n"),FirRegs.TxOverrun);*/
   1.364 +	}
   1.365 +
   1.366 +void CActiveConsole::GetDmaReaderRegs()
   1.367 +	{
   1.368 +/*	TInt r=0;
   1.369 +	TDebugDmaChannelRegs DmaRxRegs;
   1.370 +	r=iPort.GetDmaRxRegs(DmaRxRegs);
   1.371 +	iConsole->Printf(_L("Rx Chan       : %d\n"),DmaRxRegs.DmaRxChannel);
   1.372 +	iConsole->Printf(_L("Rx DmaMode    : %d  "),DmaRxRegs.DmaMode);
   1.373 +	iConsole->Printf(_L("Rx DmaState   : %d  "),DmaRxRegs.DmaState);
   1.374 +	iConsole->Printf(_L("Rx DmaBuffer  : %x\n"),DmaRxRegs.DmaBuffer);
   1.375 +	iConsole->Printf(_L("Rx DmGauge    : %d\n"),DmaRxRegs.DmaGauge);
   1.376 +	iConsole->Printf(_L("Rx DmaSrcAddr : %x  "),DmaRxRegs.DmaSrcAddr);
   1.377 +	iConsole->Printf(_L("Rx DmaSrcInc  : %d\n"),DmaRxRegs.DmaSrcInc);
   1.378 +	iConsole->Printf(_L("Rx DmaDestAddr: %x  "),DmaRxRegs.DmaDestAddr);
   1.379 +	iConsole->Printf(_L("Rx DmaDestInc : %d\n"),DmaRxRegs.DmaDestInc);
   1.380 +	iConsole->Printf(_L("Rx DmaCount   : %d\n"),DmaRxRegs.DmaCount);
   1.381 +	//iConsole->Printf(_L("Rx MatchClear : %x\n"),DmaRxRegs.MatchClear);
   1.382 +	//iConsole->Printf(_L("Rx MatchSet   : %x\n"),DmaRxRegs.MatchSet);*/
   1.383 +	}
   1.384 +
   1.385 +void CActiveConsole::GetDmaWriterRegs()
   1.386 +	{
   1.387 +/*	TInt r=0;
   1.388 +	TDebugDmaChannelRegs DmaTxRegs;
   1.389 +	r=iPort.GetDmaTxRegs(DmaTxRegs);
   1.390 +	iConsole->Printf(_L("Tx Chan       : %d\n"),DmaTxRegs.DmaTxChannel);
   1.391 +	iConsole->Printf(_L("Tx DmaMode    : %d"),DmaTxRegs.DmaMode);
   1.392 +	iConsole->Printf(_L("Tx DmaState   : %d"),DmaTxRegs.DmaState);
   1.393 +	iConsole->Printf(_L("Tx DmaBuffer  : %x\n"),DmaTxRegs.DmaBuffer);
   1.394 +	iConsole->Printf(_L("Tx DmGauge    : %d\n"),DmaTxRegs.DmaGauge);
   1.395 +	iConsole->Printf(_L("Tx DmaSrcAddr : %x"),DmaTxRegs.DmaSrcAddr);
   1.396 +	iConsole->Printf(_L("Tx DmaSrcInc  : %d\n"),DmaTxRegs.DmaSrcInc);
   1.397 +	iConsole->Printf(_L("Tx DmaDestAddr: %x"),DmaTxRegs.DmaDestAddr);
   1.398 +	iConsole->Printf(_L("Tx DmaDestInc : %d\n"),DmaTxRegs.DmaDestInc);
   1.399 +	iConsole->Printf(_L("Tx DmaCount   : %d\n"),DmaTxRegs.DmaCount);
   1.400 +	//iConsole->Printf(_L("Tx MatchClear : %x\n"),DmaTxRegs.MatchClear);
   1.401 +	//iConsole->Printf(_L("Tx MatchSet   : %x\n"),DmaTxRegs.MatchSet);*/
   1.402 +	}
   1.403 +
   1.404 +void CActiveConsole::GetReadBufInfo()
   1.405 +	{
   1.406 +/*	TInt r=0;
   1.407 +	TDebugBufInfo RxBufInfo;
   1.408 +	r=iPort.GetRxBufInfo(RxBufInfo);
   1.409 +	iConsole->Printf(_L("Rx no frames: %d\r\n"),RxBufInfo.iNoFrames);
   1.410 +	iConsole->Printf(_L("Rx insert pt: %d "),RxBufInfo.iInsertPt);
   1.411 +	iConsole->Printf(_L("Rx remove pt: %d\r\n"),RxBufInfo.iRemovePt);
   1.412 +	iConsole->Printf(_L("Rx head     : %d "),RxBufInfo.iHead);
   1.413 +	iConsole->Printf(_L("Rx tail     : %d\r\n"),RxBufInfo.iTail);
   1.414 +	iConsole->Printf(_L("Rx active   : %x "),RxBufInfo.iActive);
   1.415 +	iConsole->Printf(_L("Rx cancelled: %x\r\n"),RxBufInfo.iCancelled);
   1.416 +	iConsole->Printf(_L("Client read pending: %d\r\n"),RxBufInfo.iClientPending);*/
   1.417 +	}
   1.418 +
   1.419 +void CActiveConsole::GetWriteBufInfo()
   1.420 +	{
   1.421 +/*	TInt r=0;
   1.422 +	TDebugBufInfo TxBufInfo;
   1.423 +	r=iPort.GetTxBufInfo(TxBufInfo);
   1.424 +	iConsole->Printf(_L("Tx no frames: %d\r\n"),TxBufInfo.iNoFrames);
   1.425 +	iConsole->Printf(_L("Tx insert pt: %d "),TxBufInfo.iInsertPt);
   1.426 +	iConsole->Printf(_L("Tx remove pt: %d\r\n"),TxBufInfo.iRemovePt);
   1.427 +	iConsole->Printf(_L("Tx head     : %d "),TxBufInfo.iHead);
   1.428 +	iConsole->Printf(_L("Tx tail     : %d\r\n"),TxBufInfo.iTail);
   1.429 +	iConsole->Printf(_L("Tx active   : %x "),TxBufInfo.iActive);
   1.430 +	iConsole->Printf(_L("Tx cancelled: %x\r\n"),TxBufInfo.iCancelled);
   1.431 +	iConsole->Printf(_L("Client write pending: %d\r\n"),TxBufInfo.iClientPending);*/
   1.432 +	}
   1.433 +
   1.434 +void CActiveConsole::GetChunkInfo()
   1.435 +	{
   1.436 +/*	TInt r=0;
   1.437 +	TDebugDmaChunkInfo DmaChunkInfo;
   1.438 +	r=iPort.GetDmaChunkInfo(DmaChunkInfo);
   1.439 +	iConsole->Printf(_L("Write Chunk Phys Addr: 0x%x\r\n"),DmaChunkInfo.iWriteChunkPhysAddr);
   1.440 +	iConsole->Printf(_L("Write Chunk Lin  Addr: 0x%x\r\n"),DmaChunkInfo.iWriteChunkLinAddr);
   1.441 +	iConsole->Printf(_L("Read  Chunk Phys Addr: 0x%x\r\n"),DmaChunkInfo.iReadChunkPhysAddr);
   1.442 +	iConsole->Printf(_L("Read  Chunk Lin  Addr: 0x%x\r\n"),DmaChunkInfo.iReadChunkLinAddr);
   1.443 +	//iConsole->Printf(_L("No pages in read chunk  : %d\r\n"),DmaChunkInfo.iReaderNoPages);
   1.444 +	//iConsole->Printf(_L("no pages in write chunk : %d\r\n"),DmaChunkInfo.iWriterNoPages);*/
   1.445 +	}
   1.446 +
   1.447 +void CActiveConsole::GetMiscInfo()
   1.448 +	{
   1.449 +/*	TInt r=0;
   1.450 +	TDebugInterruptInfo IntInfo;
   1.451 +	r=iPort.GetInterruptsInfo(IntInfo);
   1.452 +	iConsole->Printf(_L("NoRxDmaInts  : %d\r\n"),IntInfo.NoRxDmaInts);	
   1.453 +	iConsole->Printf(_L("NoTxDmaInts  : %d\r\n"),IntInfo.NoTxDmaInts);	
   1.454 +	iConsole->Printf(_L("NoRxBusyInts : %d\r\n"),IntInfo.NoRxBusyInts);	
   1.455 +	iConsole->Printf(_L("NoRxIdleInts : %d\r\n"),IntInfo.NoRxIdleInts);
   1.456 +	iConsole->Printf(_L("NoRxInts     : %d\r\n"),IntInfo.NoRxInts);
   1.457 +	iConsole->Printf(_L("NoTxIdleInts : %d\r\n"),IntInfo.NoTxIdleInts);
   1.458 +	iConsole->Printf(_L("NoTxInts     : %d\r\n"),IntInfo.NoTxInts);*/
   1.459 +	}
   1.460 +
   1.461 +void CActiveConsole::SetUpBuffers()
   1.462 +	{
   1.463 +	TInt i=0;
   1.464 +	WriteBuf.SetLength(2060);
   1.465 +	ReadBuf.SetLength(2060);
   1.466 +	for(i=0;i<2050;i++)
   1.467 +		{
   1.468 +		//WriteBuf[i]='W';
   1.469 +		ReadBuf[i] ='R';
   1.470 +		}
   1.471 +
   1.472 +	TInt j=0;
   1.473 +	while(j<2050-16)
   1.474 +		{
   1.475 +		WriteBuf[j  ]='0';
   1.476 +		WriteBuf[j+1]='1';
   1.477 +		WriteBuf[j+2]='2';
   1.478 +		WriteBuf[j+3]='3';
   1.479 +
   1.480 +		WriteBuf[j+4]='4';
   1.481 +		WriteBuf[j+5]='5';
   1.482 +		WriteBuf[j+6]='6';
   1.483 +		WriteBuf[j+7]='7';
   1.484 +
   1.485 +		WriteBuf[j+8 ]='8';
   1.486 +		WriteBuf[j+9 ]='9';
   1.487 +		WriteBuf[j+10]='A';
   1.488 +		WriteBuf[j+11]='B';
   1.489 +
   1.490 +		WriteBuf[j+12]='C';
   1.491 +		WriteBuf[j+13]='D';
   1.492 +		WriteBuf[j+14]='E';
   1.493 +		WriteBuf[j+15]='F';
   1.494 +
   1.495 +		j=j+16;
   1.496 +		}
   1.497 +
   1.498 +	WriteBuf.SetLength(2000);
   1.499 +	}
   1.500 +
   1.501 +//
   1.502 +// class CActiveWriter
   1.503 +//
   1.504 +
   1.505 +CActiveWriter::CActiveWriter(CConsoleBase* aConsole,RDevFir* aPort)
   1.506 +	: CActive (EPriorityNormal)
   1.507 +	{
   1.508 +	iConsole   = aConsole;
   1.509 +	iPort=aPort;
   1.510 +	iLength=0;
   1.511 +	}
   1.512 +
   1.513 +CActiveWriter* CActiveWriter::NewL(CConsoleBase* aConsole,RDevFir* aPort)
   1.514 +	{
   1.515 +	CActiveWriter* self = new (ELeave) CActiveWriter(aConsole,aPort);
   1.516 +
   1.517 +	CleanupStack::PushL (self);
   1.518 +	self->ConstructL();
   1.519 +	CActiveScheduler::Add (self);
   1.520 +	CleanupStack::Pop ();
   1.521 +	return (self);
   1.522 +	}
   1.523 +
   1.524 +void CActiveWriter::ConstructL()
   1.525 +	{
   1.526 +	}
   1.527 +
   1.528 +CActiveWriter::~CActiveWriter()
   1.529 +	{
   1.530 +	Cancel();
   1.531 +	}
   1.532 +
   1.533 +void CActiveWriter::RunL ()
   1.534 +	{
   1.535 +	if (iStatus != KErrNone)
   1.536 +		{
   1.537 +		iConsole->Printf(_L("Error %d on write completion\r\n"),iStatus.Int());
   1.538 +		return;
   1.539 +		}
   1.540 +	else
   1.541 +		iConsole->Printf(_L("W :%d "),WriteBuf.Length());
   1.542 +
   1.543 +	if(iTimeDelay)
   1.544 +		User::After(iTimeDelay);
   1.545 +	iLength=(iLength+1)%10;
   1.546 +	WriteBuf.SetLength(iBufSz+iLength);
   1.547 +	iPort->Write(iStatus, WriteBuf, WriteBuf.Length());
   1.548 +	SetActive();
   1.549 +	}
   1.550 +
   1.551 +void CActiveWriter::Start()
   1.552 +	{
   1.553 +	if(IsActive())
   1.554 +		return;
   1.555 +	iConsole->Printf(_L("Starting writer.....\r\n"));
   1.556 +	iPort->Write(iStatus, WriteBuf, WriteBuf.Length());
   1.557 +	SetActive();
   1.558 +	}
   1.559 +
   1.560 +void CActiveWriter::Stop()
   1.561 +	{
   1.562 +	iConsole->Printf(_L("Stopping writer.....\r\n"));
   1.563 +	Cancel();
   1.564 +	}
   1.565 +
   1.566 +void CActiveWriter::DoCancel()
   1.567 +	{
   1.568 +	iPort->WriteCancel();
   1.569 +	}
   1.570 +
   1.571 +//
   1.572 +// class CActiveReader
   1.573 +//
   1.574 +
   1.575 +CActiveReader::CActiveReader(CConsoleBase* aConsole,RDevFir* aPort)
   1.576 +	: CActive (EPriorityNormal)//EPriorityMore)
   1.577 +	{
   1.578 +	iConsole=aConsole;
   1.579 +	iPort   =aPort;
   1.580 +	}
   1.581 +
   1.582 +CActiveReader* CActiveReader::NewL(CConsoleBase* aConsole,RDevFir* aPort)
   1.583 +	{
   1.584 +	CActiveReader* self = new (ELeave) CActiveReader(aConsole,aPort);
   1.585 +
   1.586 +	CleanupStack::PushL(self);
   1.587 +	self->ConstructL();
   1.588 +	CActiveScheduler::Add (self);
   1.589 +	CleanupStack::Pop();
   1.590 +	return (self);
   1.591 +	}
   1.592 +
   1.593 +void CActiveReader::ConstructL()
   1.594 +	{
   1.595 +	}
   1.596 +
   1.597 +CActiveReader::~CActiveReader ()
   1.598 +	{
   1.599 +	Cancel();
   1.600 +	}
   1.601 +
   1.602 +void CActiveReader::Start()
   1.603 +	{
   1.604 +	if(IsActive())
   1.605 +		return;
   1.606 +	iConsole->Printf(_L("Starting reader.....\r\n"));
   1.607 +	ReadBuf.SetLength(2052);
   1.608 +	iPort->Read(iStatus, ReadBuf, ReadBuf.Length());
   1.609 +	SetActive();
   1.610 +	}
   1.611 +
   1.612 +void CActiveReader::Stop()
   1.613 +	{
   1.614 +	iConsole->Printf(_L("Stopping reader.....\r\n"));
   1.615 +	Cancel();
   1.616 +	}
   1.617 +
   1.618 +void CActiveReader::RunL ()
   1.619 +	{
   1.620 +	if (iStatus != KErrNone)
   1.621 +		iConsole->Printf(_L("Error %d\r\n"),iStatus.Int());
   1.622 +	else
   1.623 +		{
   1.624 +		if(!CompareBuffers(ReadBuf.Length()))
   1.625 +			iConsole->Printf(_L("Buffers dont compare!\r\n"));
   1.626 +		iConsole->Printf(_L("R:%d\r\n"),ReadBuf.Length());
   1.627 +/*		TInt len=ReadBuf.Length();
   1.628 +		for(TInt i=0;i<10;i++)
   1.629 +			{
   1.630 +			for (TInt j=0;j<16;j++)//print 16 bytes
   1.631 +				{
   1.632 +				if ((i*16)+j<len)
   1.633 +					{
   1.634 +					TInt v=ReadBuf[(i*16)+j];
   1.635 +					iConsole->Printf(_L("%02x "),v);
   1.636 +					}
   1.637 +				else
   1.638 +					iConsole->Printf(_L("   "));
   1.639 +				}
   1.640 +			iConsole->Printf(_L("\r\n"));
   1.641 +			}*/
   1.642 +		}
   1.643 +
   1.644 +	ResetReadBuffer();
   1.645 +	if(iTimeDelay)
   1.646 +		User::After(iTimeDelay);
   1.647 +	iPort->Read(iStatus, ReadBuf, ReadBuf.Length());
   1.648 +	SetActive();
   1.649 +	}
   1.650 +
   1.651 +void CActiveReader::DoCancel()
   1.652 +	{
   1.653 +	iPort->ReadCancel();
   1.654 +	}
   1.655 +
   1.656 +void CActiveReader::ResetReadBuffer()
   1.657 +	{
   1.658 +	TInt i=0;
   1.659 +	ReadBuf.SetLength(2060);
   1.660 +	for(i=0;i<2052;i++)
   1.661 +		ReadBuf[i] ='R';
   1.662 +	}
   1.663 +
   1.664 +TBool CActiveReader::CompareBuffers(TInt aLen)
   1.665 +	{
   1.666 +	TInt i=0;
   1.667 +	while(i<aLen)
   1.668 +		{
   1.669 +		if(ReadBuf[i]!=WriteBuf[i])
   1.670 +			return EFalse;
   1.671 +		i++;
   1.672 +		}
   1.673 +	return ETrue;
   1.674 +	}
   1.675 +#pragma warning (default:4710)
   1.676 +