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