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_sirco2.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "t_slowir.h"
|
|
19 |
#include <e32svr.h>
|
|
20 |
#include <e32std.h>
|
|
21 |
#include <e32std_private.h>
|
|
22 |
#include <e32hal.h>
|
|
23 |
#include <hal.h>
|
|
24 |
|
|
25 |
#if defined(__VC32__) && _MSC_VER==1100
|
|
26 |
// Disable MSVC++ 5.0 aggressive warnings about non-expansion of inline functions.
|
|
27 |
#pragma warning(disable : 4710) // function '...' not expanded
|
|
28 |
#endif
|
|
29 |
|
|
30 |
#if defined (__WINS__)
|
|
31 |
#define PDD_NAME _L("ECDRV.PDD")
|
|
32 |
#define LDD_NAME _L("ECOMM.LDD")
|
|
33 |
#else
|
|
34 |
#define PDD_NAME _L("EUART")
|
|
35 |
#define LDD_NAME _L("ECOMM")
|
|
36 |
#endif
|
|
37 |
|
|
38 |
#define PDD2_NAME _L("EUART")
|
|
39 |
|
|
40 |
#ifdef __WINS__
|
|
41 |
#include <es_sock.h>
|
|
42 |
RSocketServ ss;
|
|
43 |
#endif
|
|
44 |
|
|
45 |
#define FIND_NAME _L("Comm.*")
|
|
46 |
|
|
47 |
const TInt KUnit1=1;
|
|
48 |
const TInt KUnit2=2;
|
|
49 |
|
|
50 |
//LOCAL_D RTest test(_L("T_SlowIR"));
|
|
51 |
|
|
52 |
TBuf8<2060> WriteBuf;
|
|
53 |
TBuf8<2060> ReadBuf;
|
|
54 |
TInt iTimeDelay=1000000;
|
|
55 |
TInt iBufSz=2000;
|
|
56 |
TBool iRWToWrite=EFalse;
|
|
57 |
|
|
58 |
void ResetReadBuffer()
|
|
59 |
{
|
|
60 |
TInt i=0;
|
|
61 |
ReadBuf.SetLength(2060);
|
|
62 |
for(i=0;i<2050;i++)
|
|
63 |
ReadBuf[i] ='R';
|
|
64 |
}
|
|
65 |
|
|
66 |
void ResetWriteBuffer()
|
|
67 |
//
|
|
68 |
// Mark a buffer with repeating byte pattern
|
|
69 |
//
|
|
70 |
{
|
|
71 |
TUint startChar='A';
|
|
72 |
TUint endChar='z';
|
|
73 |
WriteBuf.SetLength(2060);
|
|
74 |
|
|
75 |
TUint character=startChar;
|
|
76 |
for (TInt i=0;i<WriteBuf.Length();i++)
|
|
77 |
{
|
|
78 |
WriteBuf[i]=(TText8)character;
|
|
79 |
if(++character>endChar)
|
|
80 |
character=startChar;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
TInt CActiveRW::ErrorStats()
|
|
85 |
{ // Computes error %ge
|
|
86 |
if(iRxCount != 0)
|
|
87 |
return (iRxErrCount*200+iRxCount)/(2*iRxCount);
|
|
88 |
else
|
|
89 |
return 0;
|
|
90 |
}
|
|
91 |
|
|
92 |
TBool CActiveRW::CompareBuffers(TInt aLen)
|
|
93 |
{
|
|
94 |
TInt i=0;
|
|
95 |
if(aLen !=ReadBuf.Length() || aLen !=WriteBuf.Length())
|
|
96 |
return EFalse;
|
|
97 |
|
|
98 |
while(i<aLen)
|
|
99 |
{
|
|
100 |
if(ReadBuf[i]!=WriteBuf[i]){
|
|
101 |
return EFalse;}
|
|
102 |
i++;
|
|
103 |
}
|
|
104 |
return ETrue;
|
|
105 |
}
|
|
106 |
|
|
107 |
void SetUpBuffers()
|
|
108 |
{
|
|
109 |
ResetReadBuffer();
|
|
110 |
ResetWriteBuffer();
|
|
111 |
}
|
|
112 |
|
|
113 |
CActiveConsole::CActiveConsole(CConsoleBase* aConsole)
|
|
114 |
: CActive(EPriorityNormal)
|
|
115 |
{
|
|
116 |
iConsole=aConsole;
|
|
117 |
iInit1 =EFalse;
|
|
118 |
iInit2 =EFalse;
|
|
119 |
}
|
|
120 |
|
|
121 |
CActiveConsole* CActiveConsole::NewLC(CConsoleBase* aConsole)
|
|
122 |
{
|
|
123 |
CActiveConsole* self = new (ELeave) CActiveConsole(aConsole);
|
|
124 |
self->ConstructL();
|
|
125 |
return self;
|
|
126 |
}
|
|
127 |
|
|
128 |
void CActiveConsole::ConstructL ()
|
|
129 |
{
|
|
130 |
TCommCaps aCapsBuf;
|
|
131 |
TCommCapsV01& aCaps=aCapsBuf();
|
|
132 |
TCommConfig aConfigBuf;
|
|
133 |
TCommConfigV01& aConfig=aConfigBuf();
|
|
134 |
iConsole->Printf(_L("\r\n"));
|
|
135 |
CActiveScheduler::Add(this); // Add to active scheduler
|
|
136 |
|
|
137 |
TBuf<10> pddName=PDD_NAME;
|
|
138 |
#if defined (__MARM__)
|
|
139 |
const TInt KMaxPdds=10;
|
|
140 |
iConsole->Printf(_L("Load MARM PDDs\n\r"));
|
|
141 |
RDebug::Print(_L("Load MARM PDDs\n\r"));
|
|
142 |
#else
|
|
143 |
const TInt KMaxPdds=0;
|
|
144 |
iConsole->Printf(_L("Load WINS PDD\n\r"));
|
|
145 |
iConsole->Printf(PDD_NAME);
|
|
146 |
#endif
|
|
147 |
// iConsole->Read(iStatus);
|
|
148 |
|
|
149 |
TInt i;
|
|
150 |
TInt r;
|
|
151 |
for (i=-1; i<KMaxPdds; ++i)
|
|
152 |
{
|
|
153 |
if (i==0)
|
|
154 |
pddName.Append(TChar('0'));
|
|
155 |
else if (i>0)
|
|
156 |
pddName[pddName.Length()-1] = (TText)('0'+i);
|
|
157 |
r=User::LoadPhysicalDevice(pddName);
|
|
158 |
if (r==KErrNone || r==KErrAlreadyExists)
|
|
159 |
{
|
|
160 |
iConsole->Printf(_L("PDD %S loaded\n"),&pddName);
|
|
161 |
RDebug::Print(_L("PDD %S loaded\n"),&pddName);
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
RDebug::Print(_L("Load MARM LDD\n\r"));
|
|
166 |
RDebug::Print(LDD_NAME);
|
|
167 |
iConsole->Printf(_L("Load LDD\n\r"));
|
|
168 |
iConsole->Printf(LDD_NAME);
|
|
169 |
r=User::LoadLogicalDevice(LDD_NAME);
|
|
170 |
RDebug::Print(_L("\n\rReturn %d\n\r"),r);
|
|
171 |
iConsole->Printf(_L("\n\rReturn %d\n\r"),r);
|
|
172 |
// test(r==KErrNone || r==KErrAlreadyExists);
|
|
173 |
|
|
174 |
RDebug::Print(_L("\n\rFind PDDs\n\r"));
|
|
175 |
iConsole->Printf(_L("Find PDDs\n"));
|
|
176 |
TFindPhysicalDevice findPDD(FIND_NAME);
|
|
177 |
TFullName findResult;
|
|
178 |
TInt res=findPDD.Next(findResult);
|
|
179 |
while (res==KErrNone)
|
|
180 |
{
|
|
181 |
RDebug::Print(_L("Found Driver: %S\n\r"),&findResult);
|
|
182 |
iConsole->Printf(_L("Found Driver: %S\n\r"),&findResult);
|
|
183 |
res=findPDD.Next(findResult);
|
|
184 |
}
|
|
185 |
|
|
186 |
iConsole->Printf(_L("Found drivers\n\r"));
|
|
187 |
|
|
188 |
iPort=new RCommDev;
|
|
189 |
// test(iPort!=NULL);
|
|
190 |
|
|
191 |
SetUpBuffers();
|
|
192 |
|
|
193 |
TInt muid=0;
|
|
194 |
TInt ret=HAL::Get(HAL::EMachineUid, muid);
|
|
195 |
if (ret!=KErrNone)
|
|
196 |
iConsole->Printf(_L("Error %d reading MachineUid\r\n"),ret);
|
|
197 |
if(muid==HAL::EMachineUid_Integrator)
|
|
198 |
iConsole->Printf(_L("Platform is Integrator\r\n"));
|
|
199 |
|
|
200 |
if(muid==HAL::EMachineUid_Integrator) ret=iPort->Open(KUnit2); // unit =2 for Integrator
|
|
201 |
else ret=iPort->Open(KUnit1); // unit == 1 for brutus
|
|
202 |
if (ret!=KErrNone)
|
|
203 |
iConsole->Printf(_L("Error %d on opening Slow ir port\r\n"),ret);
|
|
204 |
else
|
|
205 |
iConsole->Printf(_L("Successfully opened Slow ir port\r\n"));
|
|
206 |
|
|
207 |
iPort->Caps(aCapsBuf);
|
|
208 |
|
|
209 |
if (ret!=KErrNone)
|
|
210 |
iConsole->Printf(_L("Error %d on getting caps\r\n"),ret);
|
|
211 |
else
|
|
212 |
iConsole->Printf(_L("Sir Caps: %d\r\n"),aCaps.iRate);
|
|
213 |
|
|
214 |
iPort->Config(aConfigBuf);
|
|
215 |
if (ret!=KErrNone)
|
|
216 |
iConsole->Printf(_L("Error %d getting config\r\n"),ret);
|
|
217 |
else
|
|
218 |
iConsole->Printf(_L("IR port config read\r\n"));
|
|
219 |
|
|
220 |
iConsole->Printf(_L("****Choose Rate*****\r\n"));
|
|
221 |
iConsole->Printf(_L("press '1' for 9600\r\n"));
|
|
222 |
iConsole->Printf(_L("press '2' for 19200\r\n"));
|
|
223 |
iConsole->Printf(_L("press '3' for 38400\r\n"));
|
|
224 |
iConsole->Printf(_L("press '4' for 57600\r\n"));
|
|
225 |
iConsole->Printf(_L("press '5' for 115200\r\n"));
|
|
226 |
|
|
227 |
TRequestStatus key;
|
|
228 |
iConsole->Read(key);
|
|
229 |
User::WaitForRequest(key);
|
|
230 |
TChar pressedkey = TChar(iConsole->KeyCode());
|
|
231 |
|
|
232 |
switch(pressedkey)
|
|
233 |
{
|
|
234 |
case '1':
|
|
235 |
aConfig.iRate=EBps9600;
|
|
236 |
break;
|
|
237 |
case '2':
|
|
238 |
aConfig.iRate=EBps19200;
|
|
239 |
break;
|
|
240 |
case '3':
|
|
241 |
aConfig.iRate=EBps38400;
|
|
242 |
break;
|
|
243 |
case '4':
|
|
244 |
aConfig.iRate=EBps57600;
|
|
245 |
break;
|
|
246 |
case '5':
|
|
247 |
aConfig.iRate=EBps115200;
|
|
248 |
break;
|
|
249 |
default:
|
|
250 |
aConfig.iRate=EBps115200;
|
|
251 |
break;
|
|
252 |
}
|
|
253 |
|
|
254 |
aConfig.iHandshake=0;
|
|
255 |
aConfig.iSIREnable=ESIREnable;
|
|
256 |
aConfig.iParity=EParityNone;
|
|
257 |
aConfig.iDataBits=EData8;
|
|
258 |
aConfig.iStopBits=EStop1;
|
|
259 |
|
|
260 |
ret=iPort->SetConfig(aConfigBuf);
|
|
261 |
|
|
262 |
if (ret!=KErrNone)
|
|
263 |
iConsole->Printf(_L("Error %d setting config\r\n"),ret);
|
|
264 |
else
|
|
265 |
iConsole->Printf(_L("Have configured port\n"));
|
|
266 |
|
|
267 |
|
|
268 |
iRW=CActiveRW::NewL(iConsole,iPort);
|
|
269 |
|
|
270 |
|
|
271 |
if(iRW)
|
|
272 |
iConsole->Printf(_L("Have created writer\r\n"));
|
|
273 |
else
|
|
274 |
iConsole->Printf(_L("Failed to create writer\r\n"));
|
|
275 |
}
|
|
276 |
|
|
277 |
CActiveConsole::~CActiveConsole()
|
|
278 |
{
|
|
279 |
// Make sure we're cancelled
|
|
280 |
Cancel();
|
|
281 |
|
|
282 |
if(iRW)
|
|
283 |
delete iRW;
|
|
284 |
|
|
285 |
iPort->Close();
|
|
286 |
}
|
|
287 |
|
|
288 |
void CActiveConsole::DoCancel()
|
|
289 |
{
|
|
290 |
iConsole->ReadCancel();
|
|
291 |
}
|
|
292 |
|
|
293 |
void CActiveConsole::RunL()
|
|
294 |
{
|
|
295 |
ProcessKeyPressL(TChar(iConsole->KeyCode()));
|
|
296 |
// iConsole->Printf(_L("CActiveConsole - Completed with code %d\r\n\r\n"), iStatus.Int ());
|
|
297 |
}
|
|
298 |
|
|
299 |
void CActiveConsole::RequestCharacter()
|
|
300 |
{
|
|
301 |
if(!iInit1)
|
|
302 |
{
|
|
303 |
Options1();
|
|
304 |
return;
|
|
305 |
}
|
|
306 |
if(!iInit2)
|
|
307 |
{
|
|
308 |
Options2();
|
|
309 |
return;
|
|
310 |
}
|
|
311 |
// A request is issued to the CConsoleBase to accept a
|
|
312 |
// character from the keyboard.
|
|
313 |
iConsole->Printf(_L("*********************************\r\n"));
|
|
314 |
iConsole->Printf(_L("press Escape to quit\r\n"));
|
|
315 |
iConsole->Printf(_L("press 'r' to start as reader\r\n"));
|
|
316 |
iConsole->Printf(_L("press 'w' to start as writer\r\n"));
|
|
317 |
iConsole->Printf(_L("press 's' stop \r\n"));
|
|
318 |
|
|
319 |
iConsole->Read(iStatus);
|
|
320 |
SetActive();
|
|
321 |
}
|
|
322 |
|
|
323 |
void CActiveConsole::Options1()
|
|
324 |
{
|
|
325 |
iConsole->Printf(_L("*****Choose Delay*****\r\n"));
|
|
326 |
iConsole->Printf(_L("press '1' 1.00 sec delay\r\n"));
|
|
327 |
iConsole->Printf(_L("press '2' 0.10 sec delay\r\n"));
|
|
328 |
iConsole->Printf(_L("press '3' 0.01 sec delay\r\n"));
|
|
329 |
iConsole->Printf(_L("press '4' 0.00 sec delay\r\n"));
|
|
330 |
iConsole->Read(iStatus);
|
|
331 |
SetActive();
|
|
332 |
}
|
|
333 |
|
|
334 |
void CActiveConsole::Options2()
|
|
335 |
{
|
|
336 |
iConsole->Printf(_L("****Choose Buf Sz*****\r\n"));
|
|
337 |
iConsole->Printf(_L("press '1' 1 byte \r\n"));
|
|
338 |
iConsole->Printf(_L("press '2' 4 bytes\r\n"));
|
|
339 |
iConsole->Printf(_L("press '3' 2000 bytes\r\n"));
|
|
340 |
iConsole->Printf(_L("press '4' 2051 bytes\r\n"));
|
|
341 |
iConsole->Read(iStatus);
|
|
342 |
SetActive();
|
|
343 |
}
|
|
344 |
|
|
345 |
void CActiveConsole::ProcessKeyPressL(TChar aChar)
|
|
346 |
{
|
|
347 |
if (aChar == EKeyEscape)
|
|
348 |
{
|
|
349 |
CActiveScheduler::Stop();
|
|
350 |
return;
|
|
351 |
}
|
|
352 |
|
|
353 |
if(!iInit1)
|
|
354 |
{
|
|
355 |
switch(aChar)
|
|
356 |
{
|
|
357 |
case '1'://1 sec
|
|
358 |
iTimeDelay=1000000;
|
|
359 |
break;
|
|
360 |
case '2'://0.1 sec
|
|
361 |
iTimeDelay=100000;
|
|
362 |
break;
|
|
363 |
case '3'://0.01 sec
|
|
364 |
iTimeDelay=10000;
|
|
365 |
break;
|
|
366 |
case '4'://0 sec
|
|
367 |
iTimeDelay=0;
|
|
368 |
break;
|
|
369 |
default:
|
|
370 |
iTimeDelay=1000000;
|
|
371 |
break;
|
|
372 |
}
|
|
373 |
iConsole->Printf(_L("Time Delay: %d\r\n"),iTimeDelay);
|
|
374 |
iInit1=ETrue;
|
|
375 |
RequestCharacter();
|
|
376 |
return;
|
|
377 |
}
|
|
378 |
if(!iInit2)
|
|
379 |
{
|
|
380 |
switch(aChar)
|
|
381 |
{
|
|
382 |
case '1':
|
|
383 |
iBufSz=1;
|
|
384 |
break;
|
|
385 |
case '2':
|
|
386 |
iBufSz=4;
|
|
387 |
break;
|
|
388 |
case '3':
|
|
389 |
iBufSz=2000;
|
|
390 |
break;
|
|
391 |
case '4':
|
|
392 |
iBufSz=2051;
|
|
393 |
break;
|
|
394 |
default:
|
|
395 |
iBufSz=2000;
|
|
396 |
break;
|
|
397 |
}
|
|
398 |
// check that we have enough space
|
|
399 |
if(iBufSz>iPort->ReceiveBufferLength())
|
|
400 |
iPort->SetReceiveBufferLength(iBufSz);
|
|
401 |
// if it won't do it, then settle for what it is by default
|
|
402 |
if(iBufSz>iPort->ReceiveBufferLength())
|
|
403 |
iBufSz=iPort->ReceiveBufferLength();
|
|
404 |
|
|
405 |
iConsole->Printf(_L("Buffer size: %d\r\n"),iBufSz);
|
|
406 |
iInit2=ETrue;
|
|
407 |
RequestCharacter();
|
|
408 |
return;
|
|
409 |
}
|
|
410 |
|
|
411 |
switch (aChar)
|
|
412 |
{
|
|
413 |
case 'r'://start reader
|
|
414 |
case 'R'://start reader
|
|
415 |
iRW->Start(EFalse);
|
|
416 |
break;
|
|
417 |
case 'w'://start writer
|
|
418 |
case 'W'://start writer
|
|
419 |
iRW->Start(ETrue);
|
|
420 |
break;
|
|
421 |
case 's'://stop reader
|
|
422 |
case 'S'://stop reader
|
|
423 |
iRW->Stop();
|
|
424 |
break;
|
|
425 |
default:
|
|
426 |
iConsole->Printf(_L("\r\nUnknown Command\r\n\r\n"));
|
|
427 |
break;
|
|
428 |
}
|
|
429 |
RequestCharacter ();
|
|
430 |
return;
|
|
431 |
}
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
//
|
|
436 |
// class CActiveRW
|
|
437 |
//
|
|
438 |
|
|
439 |
CActiveRW::CActiveRW(CConsoleBase* aConsole,RCommDev* aPort)
|
|
440 |
: CActive (EPriorityNormal)
|
|
441 |
{
|
|
442 |
iConsole=aConsole;
|
|
443 |
iPort=aPort;
|
|
444 |
iLength=0;
|
|
445 |
iUnrecovered=0;
|
|
446 |
iRxCount=0;
|
|
447 |
iRxErrCount=0;
|
|
448 |
}
|
|
449 |
|
|
450 |
CActiveRW* CActiveRW::NewL(CConsoleBase* aConsole,RCommDev* aPort)
|
|
451 |
{
|
|
452 |
CActiveRW* self = new (ELeave) CActiveRW(aConsole,aPort);
|
|
453 |
|
|
454 |
CleanupStack::PushL (self);
|
|
455 |
self->ConstructL();
|
|
456 |
CActiveScheduler::Add (self);
|
|
457 |
CleanupStack::Pop ();
|
|
458 |
return (self);
|
|
459 |
}
|
|
460 |
|
|
461 |
void CActiveRW::ConstructL()
|
|
462 |
{
|
|
463 |
}
|
|
464 |
|
|
465 |
CActiveRW::~CActiveRW()
|
|
466 |
{
|
|
467 |
Cancel();
|
|
468 |
}
|
|
469 |
|
|
470 |
void CActiveRW::RunL ()
|
|
471 |
{
|
|
472 |
|
|
473 |
TInt i=0;
|
|
474 |
if(iNextXfer==EWriteXfer)
|
|
475 |
iRxCount++;
|
|
476 |
|
|
477 |
if (iStatus != KErrNone)
|
|
478 |
{
|
|
479 |
if(iNextXfer==EWriteXfer)
|
|
480 |
{
|
|
481 |
iRxErrCount++;
|
|
482 |
iConsole->Printf(_L("Error %d on reading, error = %d%%\r\n"),iStatus.Int(),ErrorStats());
|
|
483 |
iPort->ResetBuffers();
|
|
484 |
iNextXfer=EDiscardXfer;
|
|
485 |
|
|
486 |
}
|
|
487 |
else
|
|
488 |
{
|
|
489 |
iConsole->Printf(_L("Error %d on writing\r\n"),iStatus.Int());
|
|
490 |
iConsole->Printf(_L("Received %d characters\r\n"),iPort->QueryReceiveBuffer());
|
|
491 |
}
|
|
492 |
}
|
|
493 |
//return;
|
|
494 |
|
|
495 |
if(iTimeDelay)
|
|
496 |
User::After(iTimeDelay);
|
|
497 |
|
|
498 |
if(iNextXfer==EReadXfer)
|
|
499 |
{
|
|
500 |
// iPort->ResetBuffers();
|
|
501 |
ResetReadBuffer();
|
|
502 |
ReadBuf.SetLength(iBufSz);
|
|
503 |
iConsole->Printf(_L("Reading(%d)"),ReadBuf.Length());
|
|
504 |
iPort->Read(iStatus, ReadBuf, ReadBuf.Length());
|
|
505 |
iNextXfer=EWriteXfer;
|
|
506 |
}
|
|
507 |
else // EWriteXfer || EDiagXfer || EDiscardXfer
|
|
508 |
{
|
|
509 |
if(iNextXfer==EWriteXfer)
|
|
510 |
{
|
|
511 |
if(!CompareBuffers(iBufSz))
|
|
512 |
{
|
|
513 |
iConsole->Printf(_L("\n***** Buffers don't match *****\n"));
|
|
514 |
for (i=0;i<ReadBuf.Length();i++)
|
|
515 |
{
|
|
516 |
iConsole->Printf(_L("WriteBuf[%d] = %02x, ReadBuf[%d] = %02x\n"),i,WriteBuf[i],i,ReadBuf[i]);
|
|
517 |
}
|
|
518 |
|
|
519 |
iUnrecovered=iPort->QueryReceiveBuffer();
|
|
520 |
iConsole->Printf(_L("Unrecovered %d characters\r\n"),iUnrecovered);
|
|
521 |
if(iUnrecovered)
|
|
522 |
{
|
|
523 |
ReadBuf.SetLength(Max(iBufSz,iUnrecovered));
|
|
524 |
iNextXfer=EDiagXfer;
|
|
525 |
iConsole->Printf(_L("\n***** Doing Diagnostic read *****\n"));
|
|
526 |
iPort->Read(iStatus, ReadBuf, iUnrecovered);
|
|
527 |
SetActive();
|
|
528 |
return;
|
|
529 |
}
|
|
530 |
}
|
|
531 |
else
|
|
532 |
{
|
|
533 |
iConsole->Printf(_L("ok\n"));
|
|
534 |
}
|
|
535 |
}
|
|
536 |
else if(iNextXfer==EDiagXfer)//EDiagXfer
|
|
537 |
{
|
|
538 |
iConsole->Printf(_L("\n***** Diagnostic dump %d *****\n"),iUnrecovered);
|
|
539 |
|
|
540 |
for (i=0;i<iUnrecovered;i++)
|
|
541 |
{
|
|
542 |
iConsole->Printf(_L("ReadBuf[%d] = %02x\n"),i,ReadBuf[i]);
|
|
543 |
}
|
|
544 |
}
|
|
545 |
WriteBuf.SetLength(iBufSz);
|
|
546 |
iConsole->Printf(_L("\nWriting(%d), "),WriteBuf.Length());
|
|
547 |
iPort->Write(iStatus, WriteBuf, WriteBuf.Length());
|
|
548 |
iNextXfer=EReadXfer;
|
|
549 |
|
|
550 |
}
|
|
551 |
iUnrecovered=0;
|
|
552 |
SetActive();
|
|
553 |
}
|
|
554 |
|
|
555 |
void CActiveRW::Start(TBool StartWriting)
|
|
556 |
{
|
|
557 |
iPort->ResetBuffers();
|
|
558 |
if(IsActive())
|
|
559 |
return;
|
|
560 |
if(StartWriting)
|
|
561 |
{
|
|
562 |
// iConsole->Printf(_L("Starting with write.%d....\r\n"),iBufSz);
|
|
563 |
WriteBuf.SetLength(iBufSz);
|
|
564 |
iPort->Write(iStatus, WriteBuf, WriteBuf.Length());
|
|
565 |
iNextXfer=EReadXfer;
|
|
566 |
}
|
|
567 |
else
|
|
568 |
{
|
|
569 |
ReadBuf.SetLength(iBufSz);
|
|
570 |
iPort->Read(iStatus, ReadBuf, ReadBuf.Length());
|
|
571 |
// iConsole->Printf(_L("Starting with read.%d....\r\n"),ReadBuf.Length());
|
|
572 |
iNextXfer=EWriteXfer;
|
|
573 |
}
|
|
574 |
SetActive();
|
|
575 |
}
|
|
576 |
|
|
577 |
void CActiveRW::Stop()
|
|
578 |
{
|
|
579 |
iConsole->Printf(_L("Stopping.....\r\n"));
|
|
580 |
iConsole->Printf(_L("Unrecovered %d characters\r\n"),iPort->QueryReceiveBuffer());
|
|
581 |
Cancel();
|
|
582 |
}
|
|
583 |
|
|
584 |
void CActiveRW::DoCancel()
|
|
585 |
{
|
|
586 |
iPort->WriteCancel();
|
|
587 |
iPort->ReadCancel();
|
|
588 |
}
|
|
589 |
|
|
590 |
#pragma warning (default:4710)
|