os/kernelhwsrv/kerneltest/e32test/device/t_firco2.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\device\t_firco2.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "t_fir2.h"
sl@0
    19
sl@0
    20
#if defined(__VC32__) && _MSC_VER==1100
sl@0
    21
// Disable MSVC++ 5.0 aggressive warnings about non-expansion of inline functions. 
sl@0
    22
#pragma warning(disable : 4710)	// function '...' not expanded
sl@0
    23
#endif
sl@0
    24
sl@0
    25
#ifdef __WINS__
sl@0
    26
	#include <es_sock.h>
sl@0
    27
	RSocketServ ss;
sl@0
    28
#endif
sl@0
    29
sl@0
    30
TBuf8<2060> WriteBuf;
sl@0
    31
TBuf8<2060> ReadBuf;
sl@0
    32
TInt iTimeDelay=1000000;
sl@0
    33
TInt iBufSz=2000;
sl@0
    34
TBool iRWToWrite=EFalse;
sl@0
    35
TInt iDataStart=-1;
sl@0
    36
TInt iReadFramesCount=0;
sl@0
    37
TInt iFrameError=0;
sl@0
    38
void ResetReadBuffer()
sl@0
    39
	{
sl@0
    40
	TInt i=0;
sl@0
    41
	ReadBuf.SetLength(2060);
sl@0
    42
	for(i=0;i<2050;i++)
sl@0
    43
		ReadBuf[i] ='R';
sl@0
    44
	}
sl@0
    45
sl@0
    46
TBool CompareBuffers(TInt aLen)
sl@0
    47
	{
sl@0
    48
	TInt i=0;
sl@0
    49
	while(i<aLen)
sl@0
    50
		{
sl@0
    51
		if(ReadBuf[i]!=WriteBuf[i])
sl@0
    52
			return EFalse;
sl@0
    53
		i++;
sl@0
    54
		}
sl@0
    55
	return ETrue;
sl@0
    56
	}
sl@0
    57
sl@0
    58
void SetUpBuffers()
sl@0
    59
	{
sl@0
    60
	TInt i=0;
sl@0
    61
	WriteBuf.SetLength(2060);
sl@0
    62
	ReadBuf.SetLength(2060);
sl@0
    63
	for(i=0;i<2050;i++)
sl@0
    64
		{
sl@0
    65
		WriteBuf[i]=i+iDataStart;
sl@0
    66
		ReadBuf[i] ='R';
sl@0
    67
		}
sl@0
    68
	WriteBuf.SetLength(2000);
sl@0
    69
	}
sl@0
    70
sl@0
    71
CActiveConsole::CActiveConsole(CConsoleBase* aConsole) 
sl@0
    72
	: CActive(EPriorityNormal)
sl@0
    73
	{
sl@0
    74
	iConsole=aConsole;
sl@0
    75
	iInit1  =EFalse;
sl@0
    76
	iInit2  =EFalse;
sl@0
    77
	iInit3  =EFalse;
sl@0
    78
	}
sl@0
    79
sl@0
    80
CActiveConsole* CActiveConsole::NewLC(CConsoleBase* aConsole)
sl@0
    81
	{
sl@0
    82
	CActiveConsole* self = new (ELeave) CActiveConsole(aConsole);
sl@0
    83
	self->ConstructL();
sl@0
    84
	return self;
sl@0
    85
	}
sl@0
    86
sl@0
    87
void CActiveConsole::ConstructL ()
sl@0
    88
	{ 
sl@0
    89
	TFirCaps aCapsBuf;
sl@0
    90
	TFirCapsV01& aCaps=aCapsBuf();
sl@0
    91
	TFirConfig aConfigBuf;
sl@0
    92
	TFirConfigV01& aConfig=aConfigBuf();
sl@0
    93
sl@0
    94
	iConsole->Printf(_L("\r\n"));
sl@0
    95
	CActiveScheduler::Add(this);			// Add to active scheduler
sl@0
    96
sl@0
    97
	// Load Driver
sl@0
    98
	TInt ret=User::LoadPhysicalDevice(_L("Difir"));
sl@0
    99
	if (ret!=KErrNone)
sl@0
   100
		iConsole->Printf(_L("Error %d on loading Fir PDD\r\n"),ret);
sl@0
   101
	else
sl@0
   102
		iConsole->Printf(_L("Successfully loaded Fir PDD\r\n"));
sl@0
   103
sl@0
   104
	ret=User::LoadLogicalDevice(_L("Efir"));
sl@0
   105
	if (ret!=KErrNone)
sl@0
   106
		iConsole->Printf(_L("Error %d on loading Fir LDD\r\n"),ret);
sl@0
   107
	else
sl@0
   108
		iConsole->Printf(_L("Successfully loaded Fir LDD\r\n"));
sl@0
   109
sl@0
   110
	SetUpBuffers();
sl@0
   111
sl@0
   112
	ret=iPort.Open(0);
sl@0
   113
	if (ret!=KErrNone)
sl@0
   114
		iConsole->Printf(_L("Error %d on opening Fastir port\r\n"),ret);
sl@0
   115
	else
sl@0
   116
		iConsole->Printf(_L("Successfully opened Fastir port\r\n"));
sl@0
   117
sl@0
   118
sl@0
   119
	ret=iPort.Caps(aCapsBuf);
sl@0
   120
	if (ret!=KErrNone)
sl@0
   121
		iConsole->Printf(_L("Error %d on getting caps\r\n"),ret);
sl@0
   122
	else
sl@0
   123
		{
sl@0
   124
		if(aCaps.iRate & KCapsFirBps576000)
sl@0
   125
			iConsole->Printf(_L("576000 Bps supported\r\n"));
sl@0
   126
		if(aCaps.iRate & KCapsFirBps1152000)
sl@0
   127
			iConsole->Printf(_L("1152000 Bps supported\r\n"));
sl@0
   128
		if(aCaps.iRate & KCapsFirBps4000000)
sl@0
   129
			iConsole->Printf(_L("4000000 Bps supported\r\n"));
sl@0
   130
		}
sl@0
   131
sl@0
   132
	/*ret=iPort.Config(aConfigBuf);
sl@0
   133
	if (ret!=KErrNone)
sl@0
   134
		iConsole->Printf(_L("Error %d getting config\r\n"),ret);
sl@0
   135
	else
sl@0
   136
		{
sl@0
   137
		if(aConfig.iRate==EBps4000000)
sl@0
   138
			iConsole->Printf(_L("Fir config is 4Mbps\r\n"));
sl@0
   139
		}*/
sl@0
   140
sl@0
   141
	iRW=CActiveRW::NewL(iConsole,&iPort);
sl@0
   142
	if(iRW)
sl@0
   143
		iConsole->Printf(_L("Have created writer\r\n"));
sl@0
   144
	else
sl@0
   145
		iConsole->Printf(_L("Failed to create writer\r\n"));
sl@0
   146
	}
sl@0
   147
sl@0
   148
CActiveConsole::~CActiveConsole()
sl@0
   149
	{
sl@0
   150
	// Make sure we're cancelled
sl@0
   151
	Cancel();
sl@0
   152
sl@0
   153
	if(iRW)
sl@0
   154
		delete iRW;
sl@0
   155
sl@0
   156
	iPort.Close();
sl@0
   157
	}
sl@0
   158
sl@0
   159
void  CActiveConsole::DoCancel()
sl@0
   160
	{
sl@0
   161
	iConsole->ReadCancel();
sl@0
   162
	}
sl@0
   163
sl@0
   164
void  CActiveConsole::RunL()
sl@0
   165
	{
sl@0
   166
	ProcessKeyPressL(TChar(iConsole->KeyCode()));
sl@0
   167
//	iConsole->Printf(_L("CActiveConsole - Completed with code %d\r\n\r\n"), iStatus.Int ());
sl@0
   168
	}
sl@0
   169
sl@0
   170
void CActiveConsole::RequestCharacter()
sl@0
   171
	{
sl@0
   172
	if(!iInit1)
sl@0
   173
		{
sl@0
   174
		Options1();
sl@0
   175
		return;
sl@0
   176
		}
sl@0
   177
	if(!iInit2)
sl@0
   178
		{
sl@0
   179
		Options2();
sl@0
   180
		return;
sl@0
   181
		}
sl@0
   182
	if(!iInit3)
sl@0
   183
		{
sl@0
   184
		Options3();
sl@0
   185
		return;
sl@0
   186
		}
sl@0
   187
	  // A request is issued to the CConsoleBase to accept a
sl@0
   188
	  // character from the keyboard.
sl@0
   189
	iConsole->Printf(_L("*********************************\r\n"));
sl@0
   190
	iConsole->Printf(_L("press Escape to quit\r\n"));
sl@0
   191
	iConsole->Printf(_L("press '1'/'2' to start as reader/writer\r\n"));
sl@0
   192
	iConsole->Printf(_L("press '3' stop \r\n"));
sl@0
   193
	iConsole->Printf(_L("press '8' to show FIR regs\r\n"));
sl@0
   194
	iConsole->Printf(_L("press '9' to show Dma reader regs\r\n"));
sl@0
   195
	iConsole->Printf(_L("press '0' to show Dma writer regs\r\n"));
sl@0
   196
	iConsole->Printf(_L("press 'a' to show TxBuf info\r\n"));
sl@0
   197
	iConsole->Printf(_L("press 'b' to show RxBuf info\r\n"));
sl@0
   198
	iConsole->Printf(_L("press 'c' to show Chunk info\r\n"));
sl@0
   199
	iConsole->Printf(_L("press 'd' to show misc info\r\n"));
sl@0
   200
	iConsole->Read(iStatus); 
sl@0
   201
	SetActive();
sl@0
   202
	}
sl@0
   203
sl@0
   204
void CActiveConsole::Options1()
sl@0
   205
	{
sl@0
   206
	iConsole->Printf(_L("*****Choose Delay*****\r\n"));
sl@0
   207
	iConsole->Printf(_L("press '1'  576000 baud\r\n"));
sl@0
   208
	iConsole->Printf(_L("press '2' 1152000 baud\r\n"));
sl@0
   209
	iConsole->Printf(_L("press '3' 4000000 baud\r\n"));
sl@0
   210
	iConsole->Read(iStatus); 
sl@0
   211
	SetActive();	
sl@0
   212
	}
sl@0
   213
sl@0
   214
void CActiveConsole::Options2()
sl@0
   215
	{
sl@0
   216
	iConsole->Printf(_L("*****Choose Delay*****\r\n"));
sl@0
   217
	iConsole->Printf(_L("press '1' 1.00 sec delay\r\n"));
sl@0
   218
	iConsole->Printf(_L("press '2'  100  ms delay\r\n"));
sl@0
   219
	iConsole->Printf(_L("press '3'   10  ms delay\r\n"));
sl@0
   220
	iConsole->Printf(_L("press '4'    1  ms delay\r\n"));
sl@0
   221
	iConsole->Printf(_L("press '5' 0.00 sec delay\r\n"));
sl@0
   222
	iConsole->Read(iStatus); 
sl@0
   223
	SetActive();	
sl@0
   224
	}
sl@0
   225
sl@0
   226
void CActiveConsole::Options3()
sl@0
   227
	{
sl@0
   228
	iConsole->Printf(_L("****Choose Buf Sz*****\r\n"));
sl@0
   229
	iConsole->Printf(_L("press '1' 1    byte \r\n"));
sl@0
   230
	iConsole->Printf(_L("press '2' 4    bytes\r\n"));
sl@0
   231
	iConsole->Printf(_L("press '3' 2000 bytes\r\n"));
sl@0
   232
	iConsole->Printf(_L("press '4' 2042 bytes\r\n"));
sl@0
   233
	iConsole->Read(iStatus); 
sl@0
   234
	SetActive();	
sl@0
   235
	}
sl@0
   236
sl@0
   237
void CActiveConsole::ProcessKeyPressL(TChar aChar)
sl@0
   238
	{
sl@0
   239
	if (aChar == EKeyEscape)
sl@0
   240
		{
sl@0
   241
		CActiveScheduler::Stop();
sl@0
   242
		return;
sl@0
   243
		}
sl@0
   244
sl@0
   245
	if(!iInit1)
sl@0
   246
		{
sl@0
   247
		switch(aChar)
sl@0
   248
			{
sl@0
   249
		case '1':
sl@0
   250
			iBaudRate=EBps576000;
sl@0
   251
			break;
sl@0
   252
		case '2':
sl@0
   253
			iBaudRate=EBps1152000;
sl@0
   254
			break;
sl@0
   255
		case '3':
sl@0
   256
			iBaudRate=EBps4000000;
sl@0
   257
			break;
sl@0
   258
		default:
sl@0
   259
			iBaudRate=EBps4000000;
sl@0
   260
			break;
sl@0
   261
			}
sl@0
   262
		iConsole->Printf(_L("Baud rate: %d\r\n"),iBaudRate);
sl@0
   263
		iInit1=ETrue;
sl@0
   264
		TFirConfig aConfigBuf;
sl@0
   265
		TFirConfigV01& aConfig=aConfigBuf();
sl@0
   266
		aConfig.iRate=iBaudRate;
sl@0
   267
		TInt ret=iPort.SetConfig(aConfigBuf);
sl@0
   268
		iConsole->Printf(_L("Error %d on SetConfig\r\n"),ret);
sl@0
   269
		RequestCharacter();
sl@0
   270
		return;
sl@0
   271
		}
sl@0
   272
sl@0
   273
	if(!iInit2)
sl@0
   274
		{
sl@0
   275
		switch(aChar)
sl@0
   276
			{
sl@0
   277
		case '1'://1 sec
sl@0
   278
			iTimeDelay=1000000;
sl@0
   279
			break;
sl@0
   280
		case '2'://100ms
sl@0
   281
			iTimeDelay=100000;
sl@0
   282
			break;
sl@0
   283
		case '3'://10ms
sl@0
   284
			iTimeDelay=10000;
sl@0
   285
			break;
sl@0
   286
		case '4'://1ms
sl@0
   287
			iTimeDelay=1000;
sl@0
   288
			break;
sl@0
   289
		case '5'://0 sec
sl@0
   290
			iTimeDelay=0;
sl@0
   291
			break;
sl@0
   292
		default:
sl@0
   293
			iTimeDelay=1000000;
sl@0
   294
			break;
sl@0
   295
			}
sl@0
   296
		iConsole->Printf(_L("Time Delay: %d\r\n"),iTimeDelay);
sl@0
   297
		iInit2=ETrue;
sl@0
   298
		RequestCharacter();
sl@0
   299
		return;
sl@0
   300
		}
sl@0
   301
	if(!iInit3)
sl@0
   302
		{
sl@0
   303
		switch(aChar)
sl@0
   304
			{
sl@0
   305
		case '1':
sl@0
   306
			iBufSz=1;
sl@0
   307
			break;
sl@0
   308
		case '2':
sl@0
   309
			iBufSz=4;
sl@0
   310
			break;
sl@0
   311
		case '3':
sl@0
   312
			iBufSz=2000;
sl@0
   313
			break;
sl@0
   314
		case '4':
sl@0
   315
			iBufSz=2042;
sl@0
   316
			break;
sl@0
   317
		default:
sl@0
   318
			iBufSz=2000;
sl@0
   319
			break;
sl@0
   320
			}
sl@0
   321
		iConsole->Printf(_L("Buffer size: %d\r\n"),iBufSz);
sl@0
   322
		iInit3=ETrue;
sl@0
   323
		RequestCharacter();
sl@0
   324
		return;
sl@0
   325
		}
sl@0
   326
sl@0
   327
	switch (aChar)
sl@0
   328
		{
sl@0
   329
	case '1'://start reader
sl@0
   330
		iRW->Start(EFalse);
sl@0
   331
		break;
sl@0
   332
	case '2'://stop reader
sl@0
   333
		iRW->Start(ETrue);
sl@0
   334
		break;
sl@0
   335
	case '3'://start writer
sl@0
   336
		iRW->Stop();
sl@0
   337
		break;
sl@0
   338
	case '8'://get fir regs
sl@0
   339
		GetFirRegs();
sl@0
   340
		break;
sl@0
   341
	case '9'://get dma reader regs
sl@0
   342
		GetDmaReaderRegs();
sl@0
   343
		break;
sl@0
   344
	case '0'://get dma writer regs
sl@0
   345
		GetDmaWriterRegs();
sl@0
   346
		break;
sl@0
   347
	case 'a'://get TxBuf info
sl@0
   348
		GetWriteBufInfo();
sl@0
   349
		break;
sl@0
   350
	case 'b'://get RxBuf info
sl@0
   351
		GetReadBufInfo();
sl@0
   352
		break;
sl@0
   353
	case 'c'://get RxBuf info
sl@0
   354
		GetChunkInfo();
sl@0
   355
		break;
sl@0
   356
	case 'd':
sl@0
   357
		GetMiscInfo();
sl@0
   358
		break;
sl@0
   359
	default:
sl@0
   360
		iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
sl@0
   361
		break;
sl@0
   362
		}
sl@0
   363
	RequestCharacter ();
sl@0
   364
	return;
sl@0
   365
	}
sl@0
   366
sl@0
   367
void CActiveConsole::GetFirRegs()
sl@0
   368
	{
sl@0
   369
/*	TInt r=0;
sl@0
   370
	TDebugFirRegs FirRegs;
sl@0
   371
	r=iPort.GetFirRegs(FirRegs);
sl@0
   372
	iConsole->Printf(_L("RxFrameStatus  : 0x%x\r\n"),FirRegs.RxFrameStatus);
sl@0
   373
	iConsole->Printf(_L("RxBufferEmpty  : 0x%x\r\n"),FirRegs.RxBufferEmpty);
sl@0
   374
	iConsole->Printf(_L("RxError        : 0x%x\r\n"),FirRegs.RxError);
sl@0
   375
	iConsole->Printf(_L("RxOverrun      : 0x%x\r\n"),FirRegs.RxOverrun);
sl@0
   376
	iConsole->Printf(_L("CrcError       : 0x%x\r\n"),FirRegs.CrcError);
sl@0
   377
	iConsole->Printf(_L("TxFrameStatus  : 0x%x\r\n"),FirRegs.TxFrameStatus);
sl@0
   378
	iConsole->Printf(_L("TxBufferEmpty  : 0x%x\r\n"),FirRegs.TxBufferEmpty);
sl@0
   379
	iConsole->Printf(_L("TxBufferSz     : 0x%x\r\n"),FirRegs.TxBufferSz);
sl@0
   380
	iConsole->Printf(_L("TxOverrun      : 0x%x\r\n"),FirRegs.TxOverrun);*/
sl@0
   381
	}
sl@0
   382
sl@0
   383
void CActiveConsole::GetDmaReaderRegs()
sl@0
   384
	{
sl@0
   385
/*	TInt r=0;
sl@0
   386
	TDebugDmaChannelRegs DmaRxRegs;
sl@0
   387
	r=iPort.GetDmaRxRegs(DmaRxRegs);
sl@0
   388
	iConsole->Printf(_L("Rx Chan       : %d\n"),DmaRxRegs.DmaRxChannel);
sl@0
   389
	iConsole->Printf(_L("Tx Chan       : %d\n"),DmaRxRegs.DmaTxChannel);
sl@0
   390
	iConsole->Printf(_L("Rx DmaMode    : %d\n"),DmaRxRegs.DmaMode);
sl@0
   391
	iConsole->Printf(_L("Rx DmaState   : %d\n"),DmaRxRegs.DmaState);
sl@0
   392
	iConsole->Printf(_L("Rx DmaBuffer  : %x\n"),DmaRxRegs.DmaBuffer);
sl@0
   393
	User::After(1000000);
sl@0
   394
	iConsole->Printf(_L("Rx DmGauge    : %d\n"),DmaRxRegs.DmaGauge);
sl@0
   395
	iConsole->Printf(_L("Rx DmaSrcAddr : %x\n"),DmaRxRegs.DmaSrcAddr);
sl@0
   396
	iConsole->Printf(_L("Rx DmaSrcInc  : %d\n"),DmaRxRegs.DmaSrcInc);
sl@0
   397
	iConsole->Printf(_L("Rx DmaDestAddr: %x\n"),DmaRxRegs.DmaDestAddr);
sl@0
   398
	iConsole->Printf(_L("Rx DmaDestInc : %d\n"),DmaRxRegs.DmaDestInc);
sl@0
   399
	iConsole->Printf(_L("Rx DmaCount   : %d\n"),DmaRxRegs.DmaCount);
sl@0
   400
	iConsole->Printf(_L("Rx MatchClear : %x\n"),DmaRxRegs.MatchClear);
sl@0
   401
	iConsole->Printf(_L("Rx MatchSet   : %x\n"),DmaRxRegs.MatchSet);*/
sl@0
   402
	}
sl@0
   403
sl@0
   404
void CActiveConsole::GetDmaWriterRegs()
sl@0
   405
	{
sl@0
   406
/*	TInt r=0;
sl@0
   407
	TDebugDmaChannelRegs DmaTxRegs;
sl@0
   408
	r=iPort.GetDmaTxRegs(DmaTxRegs);
sl@0
   409
	iConsole->Printf(_L("Rx Chan       : %d\n"),DmaTxRegs.DmaRxChannel);
sl@0
   410
	iConsole->Printf(_L("Tx Chan       : %d\n"),DmaTxRegs.DmaTxChannel);
sl@0
   411
	iConsole->Printf(_L("Tx DmaMode    : %d\n"),DmaTxRegs.DmaMode);
sl@0
   412
	iConsole->Printf(_L("Tx DmaState   : %d\n"),DmaTxRegs.DmaState);
sl@0
   413
	iConsole->Printf(_L("Tx DmaBuffer  : %x\n"),DmaTxRegs.DmaBuffer);
sl@0
   414
	User::After(1000000);
sl@0
   415
	iConsole->Printf(_L("Tx DmGauge    : %d\n"),DmaTxRegs.DmaGauge);
sl@0
   416
	iConsole->Printf(_L("Tx DmaSrcAddr : %x\n"),DmaTxRegs.DmaSrcAddr);
sl@0
   417
	iConsole->Printf(_L("Tx DmaSrcInc  : %d\n"),DmaTxRegs.DmaSrcInc);
sl@0
   418
	iConsole->Printf(_L("Tx DmaDestAddr: %x\n"),DmaTxRegs.DmaDestAddr);
sl@0
   419
	iConsole->Printf(_L("Tx DmaDestInc : %d\n"),DmaTxRegs.DmaDestInc);
sl@0
   420
	iConsole->Printf(_L("Tx DmaCount   : %d\n"),DmaTxRegs.DmaCount);
sl@0
   421
	iConsole->Printf(_L("Tx MatchClear : %x\n"),DmaTxRegs.MatchClear);
sl@0
   422
	iConsole->Printf(_L("Tx MatchSet   : %x\n"),DmaTxRegs.MatchSet);*/
sl@0
   423
	}
sl@0
   424
sl@0
   425
void CActiveConsole::GetReadBufInfo()
sl@0
   426
	{
sl@0
   427
/*	TInt r=0;
sl@0
   428
	TDebugBufInfo RxBufInfo;
sl@0
   429
	r=iPort.GetRxBufInfo(RxBufInfo);
sl@0
   430
	iConsole->Printf(_L("Rx no frames: %d\r\n"),RxBufInfo.iNoFrames);
sl@0
   431
	iConsole->Printf(_L("Rx insert pt: %d\r\n"),RxBufInfo.iInsertPt);
sl@0
   432
	iConsole->Printf(_L("Rx remove pt: %d\r\n"),RxBufInfo.iRemovePt);
sl@0
   433
	iConsole->Printf(_L("Rx head     : %d\r\n"),RxBufInfo.iHead);
sl@0
   434
	iConsole->Printf(_L("Rx tail     : %d\r\n"),RxBufInfo.iTail);
sl@0
   435
	iConsole->Printf(_L("Rx active   : %x\r\n"),RxBufInfo.iActive);
sl@0
   436
	iConsole->Printf(_L("Rx cancelled: %x\r\n"),RxBufInfo.iCancelled);
sl@0
   437
	iConsole->Printf(_L("Client read pending: %d\r\n"),RxBufInfo.iClientPending);*/
sl@0
   438
	}
sl@0
   439
sl@0
   440
void CActiveConsole::GetWriteBufInfo()
sl@0
   441
	{
sl@0
   442
/*	TInt r=0;
sl@0
   443
	TDebugBufInfo TxBufInfo;
sl@0
   444
	r=iPort.GetTxBufInfo(TxBufInfo);
sl@0
   445
	iConsole->Printf(_L("Tx no frames: %d\r\n"),TxBufInfo.iNoFrames);
sl@0
   446
	iConsole->Printf(_L("Tx insert pt: %d\r\n"),TxBufInfo.iInsertPt);
sl@0
   447
	iConsole->Printf(_L("Tx remove pt: %d\r\n"),TxBufInfo.iRemovePt);
sl@0
   448
	iConsole->Printf(_L("Tx head     : %d\r\n"),TxBufInfo.iHead);
sl@0
   449
	iConsole->Printf(_L("Tx tail     : %d\r\n"),TxBufInfo.iTail);
sl@0
   450
	iConsole->Printf(_L("Tx active   : %x\r\n"),TxBufInfo.iActive);
sl@0
   451
	iConsole->Printf(_L("Tx cancelled: %x\r\n"),TxBufInfo.iCancelled);
sl@0
   452
	iConsole->Printf(_L("Client write pending: %d\r\n"),TxBufInfo.iClientPending);*/
sl@0
   453
	}
sl@0
   454
sl@0
   455
void CActiveConsole::GetChunkInfo()
sl@0
   456
	{
sl@0
   457
/*	TInt r=0;
sl@0
   458
	TDebugDmaChunkInfo DmaChunkInfo;
sl@0
   459
	r=iPort.GetDmaChunkInfo(DmaChunkInfo);
sl@0
   460
	iConsole->Printf(_L("Write Chunk Phys Addr: 0x%x\r\n"),DmaChunkInfo.iWriteChunkPhysAddr);
sl@0
   461
	iConsole->Printf(_L("Write Chunk Lin  Addr: 0x%x\r\n"),DmaChunkInfo.iWriteChunkLinAddr);
sl@0
   462
	iConsole->Printf(_L("Read  Chunk Phys Addr: 0x%x\r\n"),DmaChunkInfo.iReadChunkPhysAddr);
sl@0
   463
	iConsole->Printf(_L("Read  Chunk Lin  Addr: 0x%x\r\n"),DmaChunkInfo.iReadChunkLinAddr);
sl@0
   464
	//iConsole->Printf(_L("Write Chunk Phys Addr: 0x%x\r\n"),DmaChunkInfo.);*/
sl@0
   465
	}
sl@0
   466
sl@0
   467
void CActiveConsole::GetMiscInfo()
sl@0
   468
	{
sl@0
   469
/*	TInt r=0;
sl@0
   470
	TDebugInterruptInfo IntInfo;
sl@0
   471
	r=iPort.GetInterruptsInfo(IntInfo);
sl@0
   472
	iConsole->Printf(_L("No writer dma interrupts: %d\r\n"),IntInfo.iNoTxDmaInts);	
sl@0
   473
	iConsole->Printf(_L("No reader dma interrupts: %d\r\n"),IntInfo.iNoRxDmaInts);
sl@0
   474
	//iConsole->Printf(_L("Total Hspp interrupts: %d\r\n"),IntInfo.iNoHsspInts);
sl@0
   475
	iConsole->Printf(_L("Total Framing errors : %d\r\n"),IntInfo.iNoFREs);
sl@0
   476
	iConsole->Printf(_L("No xtra chars        : %d\r\n"),IntInfo.iNoXtraChars);
sl@0
   477
	iConsole->Printf(_L("No unwanted chars    : %d\r\n"),IntInfo.iNoUnwantedChars);
sl@0
   478
	iConsole->Printf(_L("No Rx dma leftovers  : %d\r\n"),IntInfo.iNoRxDmaInts);*/
sl@0
   479
	}
sl@0
   480
sl@0
   481
sl@0
   482
sl@0
   483
//
sl@0
   484
// class CActiveRW
sl@0
   485
//
sl@0
   486
sl@0
   487
CActiveRW::CActiveRW(CConsoleBase* aConsole,RDevFir* aPort)
sl@0
   488
	: CActive (EPriorityNormal)
sl@0
   489
	{
sl@0
   490
	iConsole=aConsole;
sl@0
   491
	iPort=aPort;
sl@0
   492
	iLength=0;
sl@0
   493
	}
sl@0
   494
sl@0
   495
CActiveRW* CActiveRW::NewL(CConsoleBase* aConsole,RDevFir* aPort)
sl@0
   496
	{
sl@0
   497
	CActiveRW* self = new (ELeave) CActiveRW(aConsole,aPort);
sl@0
   498
sl@0
   499
	CleanupStack::PushL (self);
sl@0
   500
	self->ConstructL();
sl@0
   501
	CActiveScheduler::Add (self);
sl@0
   502
	CleanupStack::Pop ();
sl@0
   503
	return (self);
sl@0
   504
	}
sl@0
   505
sl@0
   506
void CActiveRW::ConstructL()
sl@0
   507
	{
sl@0
   508
	}
sl@0
   509
sl@0
   510
CActiveRW::~CActiveRW()
sl@0
   511
	{
sl@0
   512
	Cancel();
sl@0
   513
	}
sl@0
   514
sl@0
   515
void CActiveRW::RunL ()
sl@0
   516
	{
sl@0
   517
	TInt i=0;
sl@0
   518
	TInt wlength=0;
sl@0
   519
	TInt rlength=0;
sl@0
   520
	TInt iErrorRate=0;
sl@0
   521
	if (iStatus != KErrNone)
sl@0
   522
		iConsole->Printf(_L("Error %d\r\n"),iStatus.Int());
sl@0
   523
sl@0
   524
	//return;
sl@0
   525
		if(iTimeDelay)
sl@0
   526
			User::After(iTimeDelay);
sl@0
   527
sl@0
   528
sl@0
   529
	if(iNextXfer==EWriteXfer)
sl@0
   530
		{
sl@0
   531
//			;
sl@0
   532
		iReadFramesCount++;
sl@0
   533
		rlength=ReadBuf[0]+(ReadBuf[1]<<8);
sl@0
   534
sl@0
   535
		if(rlength != ReadBuf.Length() || iStatus != KErrNone)
sl@0
   536
			{
sl@0
   537
			iFrameError++;
sl@0
   538
			RDebug::Print(_L("********* SHORT READ %d %d*********\n\r"),rlength, ReadBuf.Length());
sl@0
   539
			}
sl@0
   540
sl@0
   541
		if(iReadFramesCount>0)
sl@0
   542
			iErrorRate=(iFrameError*2000+iReadFramesCount)/(2*iReadFramesCount);
sl@0
   543
		else
sl@0
   544
			iErrorRate=0;
sl@0
   545
sl@0
   546
		iConsole->Printf(_L("R:%-4d FR %d EC %d Err %3d.%1d%%\r\n"),
sl@0
   547
			ReadBuf.Length(),iReadFramesCount,iFrameError, iErrorRate/10,iErrorRate%10);
sl@0
   548
sl@0
   549
		iLength=(iLength+1)%10;
sl@0
   550
		wlength=iBufSz+iLength;
sl@0
   551
		WriteBuf.SetLength(wlength);
sl@0
   552
		WriteBuf[0]=wlength;
sl@0
   553
		WriteBuf[1]=wlength>>8;
sl@0
   554
		iPort->Write(iStatus, WriteBuf, WriteBuf.Length());
sl@0
   555
		iNextXfer=EReadXfer;
sl@0
   556
sl@0
   557
		}
sl@0
   558
	else
sl@0
   559
		{ // EReadXfer
sl@0
   560
		iConsole->Printf(_L("W:%-4d "),WriteBuf.Length());
sl@0
   561
		ResetReadBuffer();
sl@0
   562
		iPort->Read(iStatus, ReadBuf, ReadBuf.Length());
sl@0
   563
		iNextXfer=EWriteXfer;
sl@0
   564
		}
sl@0
   565
	SetActive();
sl@0
   566
	}
sl@0
   567
sl@0
   568
void CActiveRW::Start(TBool StartWriting)
sl@0
   569
	{
sl@0
   570
	if(IsActive())
sl@0
   571
		return;
sl@0
   572
sl@0
   573
	if(StartWriting)
sl@0
   574
		{
sl@0
   575
		if(iDataStart==-1)
sl@0
   576
			{
sl@0
   577
			iDataStart=0x80;
sl@0
   578
			SetUpBuffers();
sl@0
   579
			}
sl@0
   580
		iConsole->Printf(_L("Starting with write.....\r\n"));
sl@0
   581
		WriteBuf.SetLength(iBufSz);
sl@0
   582
			WriteBuf[0]=iBufSz;
sl@0
   583
			WriteBuf[1]=iBufSz>>8;
sl@0
   584
		iPort->Write(iStatus, WriteBuf, WriteBuf.Length());
sl@0
   585
		iNextXfer=EReadXfer;
sl@0
   586
		}
sl@0
   587
	else
sl@0
   588
		{
sl@0
   589
		if(iDataStart==-1)
sl@0
   590
			{
sl@0
   591
			iDataStart=0x0;
sl@0
   592
			SetUpBuffers();
sl@0
   593
			}
sl@0
   594
		iConsole->Printf(_L("Starting with read.....\r\n"));
sl@0
   595
		iPort->Read(iStatus, ReadBuf, ReadBuf.Length());
sl@0
   596
		iNextXfer=EWriteXfer;
sl@0
   597
		}
sl@0
   598
	SetActive();
sl@0
   599
	}
sl@0
   600
sl@0
   601
void CActiveRW::Stop()
sl@0
   602
	{
sl@0
   603
	iConsole->Printf(_L("Stopping.....\r\n"));
sl@0
   604
	Cancel();
sl@0
   605
	}
sl@0
   606
sl@0
   607
void CActiveRW::DoCancel()
sl@0
   608
	{
sl@0
   609
	iPort->WriteCancel();
sl@0
   610
	iPort->ReadCancel();
sl@0
   611
	}
sl@0
   612
sl@0
   613
#pragma warning (default:4710)