|
1 /* |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * TODO: This is used for non-loopback (i.e. bulk IN and OUT) performance |
|
16 * testing. It has been modified (see TODO: speed enhancement! marks) from the |
|
17 * vanilla version in the team directory (Camfiler01\softeng\Departmental\Pan |
|
18 * \Team\USB\Useful Stuff\t_catc\t_catc.cpp) to make it faster |
|
19 * |
|
20 */ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32cons.h> |
|
24 #include <e32std.h> |
|
25 #include <badesca.h> |
|
26 #include <c32comm.h> |
|
27 #include <usbman.h> |
|
28 |
|
29 //////////////////////////////////////////////////////////////////////////////// |
|
30 |
|
31 LOCAL_D CConsoleBase* console; |
|
32 |
|
33 RCommServ TheCommServ; |
|
34 RUsb TheUsb; |
|
35 |
|
36 TCommConfig TheConfigBuf; |
|
37 TCommConfigV01& TheConfig = TheConfigBuf(); |
|
38 |
|
39 const TInt KReceiveBufferLength = 65536/*16384*/; // TODO: speed enhancement! |
|
40 //const TInt KMaxBufferSize = 8192; // TODO: speed enhancement! |
|
41 const TUint KChunkSize = 65536; |
|
42 |
|
43 //////////////////////////////////////////////////////////////////////////////// |
|
44 |
|
45 //_LIT(KUsbCsyName, "ECACM"); |
|
46 _LIT(KUsbPortName, "ACM::0"); |
|
47 _LIT(KUsbLddName, "EUSBC"); |
|
48 |
|
49 //////////////////////////////////////////////////////////////////////////////// |
|
50 |
|
51 #define _printf console->Printf |
|
52 #define _getch console->Getch |
|
53 |
|
54 //////////////////////////////////////////////////////////////////////////////// |
|
55 |
|
56 TInt bReadCall = ETrue ; |
|
57 TInt bUseZLP = EFalse ; |
|
58 TInt bUseTerm = EFalse ; |
|
59 |
|
60 //////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
62 #define PARM(_c,_x) _c, __LINE__, TPtrC8((const TUint8*)__FILE__), _L8(#_x) |
|
63 |
|
64 #define LEAVE(_x) VerboseLeaveL(PARM(_x,_x)) |
|
65 #define LEAVEIFERROR(_x) VerboseLeaveIfErrorL(PARM(_x,_x)) |
|
66 |
|
67 #define CHECK(_x) if(! (_x) ) \ |
|
68 { \ |
|
69 VerboseLeaveL(PARM(KErrGeneral,_x)); \ |
|
70 } |
|
71 |
|
72 void VerboseLeaveL(TInt aError, TInt aLineNum, const TDesC8& aFileName, const TDesC8& aCode) |
|
73 { |
|
74 TInt filenameOffset = aFileName.LocateReverse('\\') + 1; |
|
75 if (filenameOffset < 0) filenameOffset = 1; |
|
76 TPtrC8 shortFileName = aFileName.Mid(filenameOffset); |
|
77 TBuf<64> fName, code; |
|
78 fName.Copy(shortFileName.Left(64)); |
|
79 code.Copy(aCode.Left(64)); |
|
80 _printf(_L("ERROR (%d) on line %d of file %S\n"), aError, aLineNum, &fName); |
|
81 _printf(_L("Code: %S\n\n"), &code); |
|
82 _printf(_L("[ press any key ]")); |
|
83 _getch(); |
|
84 User::Leave(aError); |
|
85 } |
|
86 |
|
87 void VerboseLeaveIfErrorL(TInt aError, TInt aLineNum, const TDesC8& aFileName, const TDesC8& aCode) |
|
88 { |
|
89 if (aError) |
|
90 { |
|
91 VerboseLeaveL(aError, aLineNum, aFileName, aCode); |
|
92 } |
|
93 } |
|
94 |
|
95 //////////////////////////////////////////////////////////////////////////////// |
|
96 |
|
97 void ReadString(TDes& aDes) |
|
98 /** |
|
99 * Reads user input into the start of the descriptor aDes. |
|
100 */ |
|
101 { |
|
102 TChar inputKey; |
|
103 TInt count = 0; |
|
104 |
|
105 aDes.Zero(); |
|
106 for (;;) |
|
107 { |
|
108 inputKey = (TInt) _getch(); |
|
109 |
|
110 if ((TInt)inputKey == EKeyEnter) |
|
111 { |
|
112 break; |
|
113 } |
|
114 |
|
115 if(inputKey == EKeyBackspace) |
|
116 { |
|
117 if (count > 0) |
|
118 { |
|
119 _printf(_L("%C"), (TUint) inputKey); |
|
120 aDes.Delete(--count,1); |
|
121 } |
|
122 } |
|
123 else if(inputKey.IsPrint()) |
|
124 { |
|
125 _printf(_L("%C"), (TUint) inputKey); |
|
126 aDes.Append(inputKey); |
|
127 count++; |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 //////////////////////////////////////////////////////////////////////////////// |
|
133 |
|
134 void Bulk_OUT_TestL() |
|
135 { |
|
136 TRequestStatus consoleStatus; |
|
137 TRequestStatus status; |
|
138 RComm port; |
|
139 |
|
140 // static TBuf8<1024> OUT_Buf; // TODO: speed enhancement! |
|
141 static TBuf8<KChunkSize> OUT_Buf; |
|
142 |
|
143 _printf(_L("\n")); |
|
144 _printf(_L("+-----------------------------------------+\n")); |
|
145 _printf(_L("|+---------------------------------------+|\n")); |
|
146 _printf(_L("|| This test listens for data on the ACM ||\n")); |
|
147 _printf(_L("|| (Bulk OUT) data port . ||\n")); |
|
148 _printf(_L("|| ||\n")); |
|
149 _printf(_L("|| Once running, Press any key to quit. ||\n")); |
|
150 _printf(_L("|+---------------------------------------+|\n")); |
|
151 _printf(_L("+------------------------------------[rjf]+\n")); |
|
152 _printf(_L("\n")); |
|
153 |
|
154 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
155 CleanupClosePushL(port); |
|
156 |
|
157 port.SetConfig(TheConfigBuf); |
|
158 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
159 |
|
160 // prime the console for the abandon-ship |
|
161 |
|
162 console->Read(consoleStatus); |
|
163 |
|
164 TInt uReadCount = 0 ; |
|
165 //TInt uThermoBar = 0 ; // TODO: speed enhancement! (remove ThermoBar fnality) |
|
166 |
|
167 _printf(_L("\tWatch : ")); |
|
168 |
|
169 TInt uAvgCount = 0 ; |
|
170 TInt uNumReads = 0 ; |
|
171 TInt uNumRooms = 0 ; |
|
172 |
|
173 while (1) |
|
174 { |
|
175 // setup read to collect a single block by whatever method |
|
176 // has been selected. |
|
177 |
|
178 if( bReadCall ) |
|
179 { |
|
180 port.Read(status, OUT_Buf, KChunkSize); // TODO: speed enhancement! |
|
181 |
|
182 uNumReads++ ; |
|
183 } |
|
184 else |
|
185 { |
|
186 port.ReadOneOrMore(status, OUT_Buf); |
|
187 |
|
188 uNumRooms++ ; |
|
189 } |
|
190 |
|
191 // either the read is complete, or user request to stop the test |
|
192 |
|
193 User::WaitForRequest(status,consoleStatus); |
|
194 |
|
195 if (consoleStatus == KRequestPending) |
|
196 { |
|
197 // still waiting for keypress, so it must have been the read |
|
198 // that completed, check if it worked OK |
|
199 |
|
200 if (status != KErrNone) |
|
201 { |
|
202 console->ReadCancel(); |
|
203 |
|
204 LEAVE(status.Int()); |
|
205 } |
|
206 |
|
207 // reassure watcher that there is something happening... |
|
208 |
|
209 if( uAvgCount == 0 ) |
|
210 { |
|
211 uAvgCount = OUT_Buf.Length() ; |
|
212 } |
|
213 else |
|
214 { |
|
215 uAvgCount = ( ( 9 * uAvgCount ) + OUT_Buf.Length() ) / 10 ; |
|
216 } |
|
217 |
|
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 */ |
|
238 } |
|
239 else |
|
240 { |
|
241 // user must have wanted to stop, shut down the reader |
|
242 |
|
243 _printf(_L("\n")); |
|
244 _printf(_L("\n")); |
|
245 _printf(_L("\nReads=%d, Rooms=%d, Average Count=%d"),uNumReads,uNumRooms,uAvgCount); |
|
246 _printf(_L("\n")); |
|
247 |
|
248 _printf(_L("\n\n\tCancelling Read()")); |
|
249 |
|
250 port.ReadCancel(); |
|
251 |
|
252 _printf(_L("\n\n\tRead() Cancelled")); |
|
253 |
|
254 break; |
|
255 } |
|
256 } |
|
257 |
|
258 _printf(_L("\n")); |
|
259 _printf(_L("\tBulk OUT says bye...")); |
|
260 _printf(_L("\n")); |
|
261 |
|
262 CleanupStack::PopAndDestroy(); // port |
|
263 } |
|
264 |
|
265 ///////////////////////////////////////////////////////////////////////////////// |
|
266 |
|
267 void Bulk_IN_TestL() |
|
268 { |
|
269 TRequestStatus consoleStatus; |
|
270 TRequestStatus status; |
|
271 RComm port; |
|
272 |
|
273 //#define uInBufSize 4096 // TODO: speed enhancement! reduce number of IPC calls |
|
274 #define uInBufSize 65536 |
|
275 |
|
276 static TBuf8<uInBufSize> IN_Buf; |
|
277 static TBuf8<uInBufSize> ZLP_Buf; |
|
278 |
|
279 _printf(_L("\n")); |
|
280 _printf(_L("+-------------------------------------+\n")); |
|
281 _printf(_L("|+-----------------------------------+|\n")); |
|
282 _printf(_L("|| This test writes data on the ACM ||\n")); |
|
283 _printf(_L("|| (Bulk IN) data port ||\n")); |
|
284 _printf(_L("|| ||\n")); |
|
285 _printf(_L("|| On running, Press any key to quit ||\n")); |
|
286 _printf(_L("|+-----------------------------------+|\n")); |
|
287 _printf(_L("+--------------------------------[rjf]+\n")); |
|
288 _printf(_L("\n")); |
|
289 |
|
290 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
291 CleanupClosePushL(port); |
|
292 |
|
293 port.SetConfig(TheConfigBuf); |
|
294 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
295 |
|
296 // set up the ZLP and set a default pattern into the buffer |
|
297 |
|
298 ZLP_Buf.SetLength(0) ; |
|
299 |
|
300 IN_Buf.SetLength( uInBufSize ) ; |
|
301 |
|
302 int j = 0 ; |
|
303 |
|
304 for( int i = 0 ; i < uInBufSize ; i++ ) |
|
305 { |
|
306 if( ( i % 64 ) == 0 ) |
|
307 { |
|
308 j++; |
|
309 } |
|
310 |
|
311 switch( i % 64 ) |
|
312 { |
|
313 case 0 : |
|
314 IN_Buf[i] = 0xFF ; |
|
315 break ; |
|
316 case 1 : |
|
317 IN_Buf[i] = j / 256 ; |
|
318 break ; |
|
319 case 2 : |
|
320 IN_Buf[i] = j % 256 ; |
|
321 break ; |
|
322 case 3 : |
|
323 IN_Buf[i] = 0xFF ; |
|
324 break ; |
|
325 default: |
|
326 IN_Buf[i] = i ; |
|
327 break ; |
|
328 } |
|
329 } |
|
330 |
|
331 // prime the console for the abandon-ship |
|
332 |
|
333 console->Read(consoleStatus); |
|
334 |
|
335 TInt bDoneBlock = EFalse ; |
|
336 |
|
337 TInt bNeedZLP = bUseZLP && ((IN_Buf.Length()%64)==0); |
|
338 |
|
339 TInt uWriteCount = 0 ; |
|
340 // TInt uThermoBar = 0 ; // TODO: speed enhancement! |
|
341 |
|
342 _printf(_L("\tWatch : ")); |
|
343 |
|
344 while (1) |
|
345 { |
|
346 // setup write to send a single block, this is either the |
|
347 // block in the buffer, or else may be a ZLP which is sent |
|
348 // on every other pass, provided the size of the block is |
|
349 // exactly N*64 |
|
350 |
|
351 if( bDoneBlock && bNeedZLP ) |
|
352 { |
|
353 port.Write(status, ZLP_Buf); |
|
354 |
|
355 bDoneBlock = EFalse; |
|
356 } |
|
357 else |
|
358 { |
|
359 port.Write(status, IN_Buf); |
|
360 |
|
361 uWriteCount += IN_Buf.Length() ; |
|
362 |
|
363 bDoneBlock = ETrue; |
|
364 } |
|
365 |
|
366 // either the write is complete, or user request to stop the test |
|
367 |
|
368 User::WaitForRequest(status,consoleStatus); |
|
369 |
|
370 if (consoleStatus == KRequestPending) |
|
371 { |
|
372 if (status != KErrNone) |
|
373 { |
|
374 console->ReadCancel(); |
|
375 |
|
376 LEAVE(status.Int()); |
|
377 } |
|
378 |
|
379 // reassure watcher that there is something happening... |
|
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 */ |
|
399 } |
|
400 else |
|
401 { |
|
402 _printf(_L("\n\n\tCancelling Write()")); |
|
403 |
|
404 port.WriteCancel(); |
|
405 |
|
406 _printf(_L("\n\n\tWrite() Cancelled")); |
|
407 |
|
408 break; |
|
409 } |
|
410 } |
|
411 |
|
412 _printf(_L("\n")); |
|
413 _printf(_L("\tBulk IN says bye...")); |
|
414 _printf(_L("\n")); |
|
415 |
|
416 CleanupStack::PopAndDestroy(); // port |
|
417 } |
|
418 |
|
419 //////////////////////////////////////////////////////////////////////////////// |
|
420 |
|
421 void SetHandshakingL() |
|
422 { |
|
423 RComm port; |
|
424 |
|
425 TCommCaps capsBuf; |
|
426 TCommCapsV01& caps = capsBuf(); |
|
427 |
|
428 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
429 CleanupClosePushL(port); |
|
430 |
|
431 port.Caps(capsBuf); |
|
432 |
|
433 _printf(_L("\nPort handshaking capabilities: 0x%08X\n"), caps.iHandshake); |
|
434 _printf(_L("\nCurrent handshaking options: 0x%08X\n"), TheConfig.iHandshake); |
|
435 |
|
436 _printf(_L("\n")); |
|
437 |
|
438 #define HS(b) _printf(_L("\tTheConfig.%s = %s\n"), #b, ((TheConfig.iHandshake & b) == b) ? "Set" : "Clear" ) ; |
|
439 |
|
440 HS(KConfigObeyXoff); |
|
441 HS(KConfigSendXoff); |
|
442 HS(KConfigObeyCTS); |
|
443 HS(KConfigObeyDSR); |
|
444 HS(KConfigFreeRTS); |
|
445 HS(KConfigWriteBufferedComplete); |
|
446 |
|
447 _printf(_L("\n\n")); |
|
448 _printf(_L("Handshaking options:\n\n")); |
|
449 _printf(_L("1. No handshaking\n")); |
|
450 _printf(_L("2. Toggle Xon/Xoff\n")); |
|
451 _printf(_L("3. Toggle obey CTS\n")); |
|
452 _printf(_L("4. Toggle obey DSR / free RTS\n")); |
|
453 _printf(_L("5. Toggle write buffered complete\n")); |
|
454 |
|
455 TKeyCode key = console->Getch(); |
|
456 |
|
457 switch (key) |
|
458 { |
|
459 case '1': |
|
460 TheConfig.iHandshake = 0; |
|
461 break; |
|
462 case '2': |
|
463 TheConfig.iHandshake ^= KConfigObeyXoff; |
|
464 TheConfig.iHandshake ^= KConfigSendXoff; |
|
465 break; |
|
466 case '3': |
|
467 TheConfig.iHandshake ^= KConfigObeyCTS; |
|
468 break; |
|
469 case '4': |
|
470 TheConfig.iHandshake ^= KConfigObeyDSR; |
|
471 TheConfig.iHandshake ^= KConfigFreeRTS; |
|
472 break; |
|
473 case '5': |
|
474 TheConfig.iHandshake ^= KConfigWriteBufferedComplete; |
|
475 break; |
|
476 default: |
|
477 break; |
|
478 } |
|
479 |
|
480 LEAVEIFERROR(port.SetConfig(TheConfigBuf)); |
|
481 |
|
482 _printf(_L("Handshaking options now: 0x%X\n"), TheConfig.iHandshake); |
|
483 |
|
484 CleanupStack::PopAndDestroy(); |
|
485 } |
|
486 |
|
487 //////////////////////////////////////////////////////////////////////////////// |
|
488 |
|
489 void RestartUsbL() |
|
490 { |
|
491 TheUsb.Stop(); |
|
492 |
|
493 TRequestStatus status; |
|
494 TheUsb.Start(status); |
|
495 User::WaitForRequest(status); |
|
496 LEAVEIFERROR(status.Int()); |
|
497 |
|
498 _printf(_L("Restarted USB.\n")); |
|
499 } |
|
500 |
|
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 //////////////////////////////////////////////////////////////////////////////// |
|
544 |
|
545 void ToggleTermL() |
|
546 { |
|
547 bUseTerm = ( bUseTerm == EFalse ) ; |
|
548 |
|
549 if( bUseTerm ) |
|
550 { |
|
551 TheConfig.iTerminatorCount = 1 ; |
|
552 |
|
553 TheConfig.iTerminator[0] = 0x7E ; |
|
554 } |
|
555 else |
|
556 { |
|
557 TheConfig.iTerminatorCount = 0 ; |
|
558 } |
|
559 } |
|
560 |
|
561 //////////////////////////////////////////////////////////////////////////////// |
|
562 |
|
563 void mainL() |
|
564 { |
|
565 _printf(_L("\n")); |
|
566 _printf(_L("+--------------------------------+\n")); |
|
567 _printf(_L("|+------------------------------+|\n")); |
|
568 _printf(_L("|| T_CATC : V1.00 : 25-Feb-2003 ||\n")); |
|
569 _printf(_L("|+------------------------------+|\n")); |
|
570 _printf(_L("+---------------------------[rjf]+\n")); |
|
571 _printf(_L("\n")); |
|
572 |
|
573 TInt ret = User::LoadLogicalDevice(KUsbLddName); |
|
574 if ((ret != KErrNone) && (ret != KErrAlreadyExists)) |
|
575 LEAVE(ret); |
|
576 |
|
577 _printf(_L("Loaded USB LDD\n")); |
|
578 |
|
579 ret = StartC32(); |
|
580 if ((ret != KErrNone) && (ret != KErrAlreadyExists)) |
|
581 LEAVE(ret); |
|
582 |
|
583 _printf(_L("Started C32\n")); |
|
584 |
|
585 LEAVEIFERROR(TheUsb.Connect()); |
|
586 |
|
587 _printf(_L("Connected to USB Manager\n")); |
|
588 |
|
589 _printf(_L("\n")); |
|
590 _printf(_L("+-------------------------------------+\n")); |
|
591 _printf(_L("|+-----------------------------------+|\n")); |
|
592 _printf(_L("|| Please connect the USB cable now! ||\n")); |
|
593 _printf(_L("|+-----------------------------------+|\n")); |
|
594 _printf(_L("+--------------------------------[rjf]+\n")); |
|
595 _printf(_L("\n")); |
|
596 |
|
597 TRequestStatus status; |
|
598 |
|
599 TheUsb.Start(status); |
|
600 User::WaitForRequest(status); |
|
601 LEAVEIFERROR(status.Int()); |
|
602 |
|
603 _printf(_L("Started USB\n")); |
|
604 |
|
605 LEAVEIFERROR(TheCommServ.Connect()); |
|
606 |
|
607 _printf(_L("Connected to C32\n")); |
|
608 |
|
609 RComm port; |
|
610 |
|
611 // The port's configuration seems to be junk at the beginning, so we set it to known values. |
|
612 |
|
613 TheConfig.iRate = EBps115200; |
|
614 TheConfig.iDataBits = EData8; |
|
615 TheConfig.iStopBits = EStop1; |
|
616 TheConfig.iParity = EParityNone; |
|
617 TheConfig.iHandshake = 0; |
|
618 TheConfig.iTerminatorCount = 0; |
|
619 |
|
620 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
621 CleanupClosePushL(port); |
|
622 |
|
623 port.SetConfig(TheConfigBuf); |
|
624 |
|
625 CleanupStack::PopAndDestroy(); // port |
|
626 |
|
627 TBool exit = EFalse; |
|
628 |
|
629 #define SHOW(h,l,t,f) \ |
|
630 { \ |
|
631 _printf(_L("\n ")); \ |
|
632 _printf(_L(h)); \ |
|
633 _printf(_L("\t")); \ |
|
634 \ |
|
635 if( l ) \ |
|
636 { \ |
|
637 _printf(_L(t)); \ |
|
638 } \ |
|
639 else \ |
|
640 { \ |
|
641 _printf(_L(f)); \ |
|
642 } \ |
|
643 \ |
|
644 _printf(_L("\n")); \ |
|
645 } |
|
646 |
|
647 while (!exit) |
|
648 { |
|
649 _printf(_L("\n")); |
|
650 _printf(_L("Current Settings:\n")); |
|
651 _printf(_L("\n")); |
|
652 SHOW("OUT Method", bReadCall,"Read()","ReadOneOrMore()"); |
|
653 SHOW("ZLP Method", bUseZLP, "Active","Suppressed" ); |
|
654 SHOW("Term Method",bUseTerm, "Active","Suppressed" ); |
|
655 _printf(_L("\n")); |
|
656 _printf(_L("Available tests: \n")); |
|
657 _printf(_L("\n")); |
|
658 _printf(_L("1. Bulk OUT test \n")); |
|
659 _printf(_L("2. Bulk IN test \n")); |
|
660 _printf(_L("3. Set handshaking \n")); |
|
661 _printf(_L("4. Restart USB \n")); |
|
662 // _printf(_L("5. Run ThermoBar \n")); |
|
663 _printf(_L("6. Swap Read Method \n")); |
|
664 _printf(_L("7. Swap ZLP Method \n")); |
|
665 _printf(_L("8. Swap Term Method \n")); |
|
666 _printf(_L("\n")); |
|
667 _printf(_L("Select (q to quit): ")); |
|
668 |
|
669 char ch = (char) _getch(); |
|
670 _printf(_L("\n")); |
|
671 |
|
672 switch (ch) |
|
673 { |
|
674 case '1': Bulk_OUT_TestL(); break; |
|
675 case '2': Bulk_IN_TestL(); break; |
|
676 case '3': SetHandshakingL(); break; |
|
677 case '4': RestartUsbL(); break; |
|
678 // case '5': ThermoBar(); break; |
|
679 case '6': bReadCall = ( bReadCall == EFalse ) ; break; |
|
680 case '7': bUseZLP = ( bUseZLP == EFalse ) ; break; |
|
681 case '8': ToggleTermL() ; break; |
|
682 |
|
683 case 'q': |
|
684 case 'Q': |
|
685 exit = ETrue; |
|
686 break; |
|
687 |
|
688 default: |
|
689 _printf(_L("\nInvalid key\n")); |
|
690 break; |
|
691 } |
|
692 } |
|
693 |
|
694 TheCommServ.Close(); |
|
695 TheUsb.Close(); |
|
696 } |
|
697 |
|
698 //////////////////////////////////////////////////////////////////////////////// |
|
699 |
|
700 void consoleMainL() |
|
701 { |
|
702 console=Console::NewL(_L("T_ACM"),TSize(KConsFullScreen,KConsFullScreen)); |
|
703 CleanupStack::PushL(console); |
|
704 mainL(); |
|
705 _printf(_L("[ press any key ]")); |
|
706 _getch(); |
|
707 CleanupStack::PopAndDestroy(); |
|
708 } |
|
709 |
|
710 //////////////////////////////////////////////////////////////////////////////// |
|
711 |
|
712 GLDEF_C TInt E32Main() |
|
713 { |
|
714 __UHEAP_MARK; |
|
715 CTrapCleanup* cleanupStack=CTrapCleanup::New(); |
|
716 TRAP_IGNORE(consoleMainL()); |
|
717 delete cleanupStack; |
|
718 __UHEAP_MARKEND; |
|
719 return 0; |
|
720 } |
|
721 |
|
722 //////////////////////////////////////////////////////////////////////////////// |
|
723 |