|
1 /* |
|
2 * Copyright (c) 2002-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 * This program executes all the tests in the ACM CSY Test Specification v 0.1 |
|
16 * and is to be used in conjunction with the host-side application. (t_acm_wins) |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <e32cons.h> |
|
22 #include <e32math.h> |
|
23 #include <c32comm.h> |
|
24 #include <usbman.h> |
|
25 #include <e32debug.h> |
|
26 |
|
27 LOCAL_D CConsoleBase* console; |
|
28 |
|
29 RCommServ TheCommServ; |
|
30 RUsb TheUsb; |
|
31 |
|
32 TCommConfig TheConfigBuf; |
|
33 TCommConfigV01& TheConfig = TheConfigBuf(); |
|
34 |
|
35 const TInt KReceiveBufferLength = 4096; |
|
36 const TInt KMaxAcmPortNameLength = 8; |
|
37 //_LIT(KUsbCsyName, "ECACM"); |
|
38 _LIT(KUsbPortName, "ACM::0"); |
|
39 _LIT(KUsbPortNameAcm1, "ACM::1"); |
|
40 |
|
41 _LIT(KUsbLddName, "EUSBC"); |
|
42 |
|
43 #define _printf console->Printf |
|
44 #define _getch console->Getch |
|
45 #define LEAVE(_x) VerboseLeaveL(_x, __LINE__, TPtrC8((const TUint8*)__FILE__), _L8(#_x)) |
|
46 #define LEAVEIFERROR(_x) VerboseLeaveIfErrorL(_x, __LINE__, TPtrC8((const TUint8*)__FILE__), _L8(#_x)) |
|
47 #define CHECK(_x) if (! (_x)) VerboseLeaveL(KErrGeneral, __LINE__, TPtrC8((const TUint8*)__FILE__), _L8(#_x)) |
|
48 |
|
49 // A define for stack-based buffers |
|
50 #define MAX_BUFFER_SIZE 1024 |
|
51 |
|
52 // A bigger buffer on the heap |
|
53 #define MAX_HEAP_BUFFER_SIZE (1024*8) |
|
54 TBuf8<MAX_HEAP_BUFFER_SIZE> readBigBuf; |
|
55 |
|
56 // A timer for use by several of the tests |
|
57 RTimer timer; |
|
58 |
|
59 //The random seed |
|
60 TInt64 seed = 100; |
|
61 |
|
62 void VerboseLeaveL(TInt aError, TInt aLineNum, const TDesC8& aFileName, const TDesC8& aCode) |
|
63 /** |
|
64 * For bombing out usefully. |
|
65 */ |
|
66 { |
|
67 TInt filenameOffset = aFileName.LocateReverse('\\') + 1; |
|
68 if (filenameOffset < 0) filenameOffset = 1; |
|
69 TPtrC8 shortFileName = aFileName.Mid(filenameOffset); |
|
70 TBuf<64> fName, code; |
|
71 fName.Copy(shortFileName.Left(64)); |
|
72 code.Copy(aCode.Left(64)); |
|
73 _printf(_L("\nERROR (%d) on line %d of file %S\n"), aError, aLineNum, &fName); |
|
74 _printf(_L("Code: %S\n\n"), &code); |
|
75 _printf(_L("[ press any key ]")); |
|
76 _getch(); |
|
77 User::Leave(aError); |
|
78 } |
|
79 |
|
80 void VerboseLeaveIfErrorL(TInt aError, TInt aLineNum, const TDesC8& aFileName, const TDesC8& aCode) |
|
81 /** |
|
82 * For bombing out usefully if there's an error. |
|
83 */ |
|
84 { |
|
85 if (aError) |
|
86 VerboseLeaveL(aError, aLineNum, aFileName, aCode); |
|
87 } |
|
88 |
|
89 void ReadString(TDes& aDes) |
|
90 /** |
|
91 * Reads user input into the start of the descriptor aDes. |
|
92 */ |
|
93 { |
|
94 TChar inputKey; |
|
95 TInt count = 0; |
|
96 |
|
97 aDes.Zero(); |
|
98 for (;;) |
|
99 { |
|
100 inputKey = (TInt) _getch(); |
|
101 |
|
102 if ((TInt)inputKey == EKeyEnter) |
|
103 break; |
|
104 |
|
105 if(inputKey == EKeyBackspace) |
|
106 { |
|
107 if (count > 0) |
|
108 { |
|
109 _printf(_L("%C"), (TUint) inputKey); |
|
110 aDes.Delete(--count,1); |
|
111 } |
|
112 } |
|
113 else if(inputKey.IsPrint()) |
|
114 { |
|
115 _printf(_L("%C"), (TUint) inputKey); |
|
116 aDes.Append(inputKey); |
|
117 count++; |
|
118 } |
|
119 } |
|
120 } |
|
121 |
|
122 void FillBuffer(TDes8 &aDes) |
|
123 /** |
|
124 * Fills a given buffer with incrementing numbers. |
|
125 */ |
|
126 { |
|
127 aDes.Zero(); |
|
128 for (TInt i=0; i<aDes.MaxSize(); i++) |
|
129 { |
|
130 aDes.Append(i); |
|
131 } |
|
132 } |
|
133 |
|
134 bool CheckBuffer(TDes8 &aDes, TInt size) |
|
135 /** |
|
136 * Checks that a given buffer contains incrementing numbers. |
|
137 */ |
|
138 { |
|
139 for (TInt i=0; i<size; i++) |
|
140 { |
|
141 if (aDes[i] != i) |
|
142 return FALSE; |
|
143 } |
|
144 |
|
145 return TRUE; |
|
146 } |
|
147 |
|
148 ////////////////////////////////////////////////////////////////////////////////////////////// |
|
149 /** |
|
150 * loopback From a Port input by the user to abother port- |
|
151 * ACM::1 KUsbPortNameAcm1 to ACM::0 KUsbPortName by default |
|
152 */ |
|
153 |
|
154 void ReadLoopbackFromPortAToPortBTestL() |
|
155 { |
|
156 |
|
157 TRequestStatus consoleStatus; |
|
158 TRequestStatus status; |
|
159 RComm portIN; |
|
160 RComm portOut; |
|
161 |
|
162 _printf(_L("Enter the packet size:")); |
|
163 TBufC<8> buf; |
|
164 TPtr ptr (buf.Des()); |
|
165 ReadString(ptr); |
|
166 |
|
167 TLex input(buf); |
|
168 |
|
169 TInt pktlen = 0; |
|
170 while ((input.Peek()).IsDigit()) { |
|
171 pktlen = 10*pktlen + (input.Get()) - '0'; |
|
172 } |
|
173 |
|
174 // Get port names |
|
175 _printf(_L("\nEnter acm port name as loopback INPUT: (ex ACM::1):")); |
|
176 TBufC<KMaxAcmPortNameLength> portINName; |
|
177 TPtr portINNamePtr (portINName.Des()); |
|
178 ReadString(portINNamePtr); |
|
179 if ( portINNamePtr.Length() == 0 ) |
|
180 { |
|
181 portINName= KUsbPortNameAcm1; |
|
182 } |
|
183 |
|
184 _printf(_L("\nEnter acm port name as loopback OUTPUT: (ex ACM::0):")); |
|
185 TBufC<KMaxAcmPortNameLength> portOutName; |
|
186 TPtr portOutNamePtr (portOutName.Des()); |
|
187 ReadString(portOutNamePtr); |
|
188 if ( portOutNamePtr.Length() == 0 ) |
|
189 { |
|
190 portOutName = KUsbPortName; |
|
191 } |
|
192 |
|
193 |
|
194 _printf(_L("\n----------------------------------------\n")); |
|
195 _printf(_L("This test listens for data on the ACM port: ")); |
|
196 _printf(portINName); |
|
197 _printf(_L("\nwrites anything it receives on the ACM port: ")); |
|
198 _printf(portOutName); |
|
199 _printf(_L("\nPress any key to quit.\n")); |
|
200 _printf(_L("----------------------------------------\n\n")); |
|
201 |
|
202 LEAVEIFERROR(portIN.Open(TheCommServ, portINName, ECommExclusive, ECommRoleDCE)); |
|
203 CleanupClosePushL(portIN); |
|
204 |
|
205 LEAVEIFERROR(portOut.Open(TheCommServ, portOutName, ECommExclusive, ECommRoleDCE)); |
|
206 CleanupClosePushL(portOut); |
|
207 |
|
208 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
209 |
|
210 portIN.SetConfig(TheConfigBuf); |
|
211 portIN.SetReceiveBufferLength(KReceiveBufferLength); |
|
212 portOut.SetConfig(TheConfigBuf); |
|
213 portOut.SetReceiveBufferLength(KReceiveBufferLength); |
|
214 |
|
215 _printf(_L("loopback received data\n")); |
|
216 |
|
217 console->Read(consoleStatus); |
|
218 |
|
219 FOREVER |
|
220 { |
|
221 portIN.Read(status, readBigBuf, pktlen); |
|
222 |
|
223 User::WaitForRequest(status, consoleStatus); |
|
224 |
|
225 if (consoleStatus == KRequestPending) |
|
226 { |
|
227 if (status != KErrNone) |
|
228 { |
|
229 |
|
230 console->ReadCancel(); |
|
231 LEAVE(status.Int()); |
|
232 } |
|
233 } |
|
234 else |
|
235 { |
|
236 portIN.ReadCancel(); |
|
237 break; |
|
238 } |
|
239 |
|
240 portOut.Write(status, readBigBuf); |
|
241 User::WaitForRequest(status, consoleStatus); |
|
242 |
|
243 if (consoleStatus == KRequestPending) |
|
244 { |
|
245 if (status != KErrNone) |
|
246 { |
|
247 // need to cancel the read to avoid a CBase-77 panic! |
|
248 console->ReadCancel(); |
|
249 LEAVE(status.Int()); |
|
250 } |
|
251 } |
|
252 else |
|
253 { |
|
254 portOut.WriteCancel(); |
|
255 break; |
|
256 } |
|
257 } |
|
258 |
|
259 portOut.WriteCancel(); |
|
260 |
|
261 _printf(_L("\nTest complete\n")); |
|
262 |
|
263 CleanupStack::PopAndDestroy(2); // portA , portOut |
|
264 |
|
265 } |
|
266 |
|
267 ////////////////////////////////////////////////////////////////////////////////////////////// |
|
268 /** |
|
269 * Original loopback test - uses Read(). |
|
270 */ |
|
271 |
|
272 void ReadLoopbackTestL() |
|
273 { |
|
274 |
|
275 TRequestStatus consoleStatus; |
|
276 TRequestStatus status; |
|
277 RComm port; |
|
278 |
|
279 _printf(_L("Enter the packet size:")); |
|
280 TBufC<8> buf; |
|
281 TPtr ptr (buf.Des()); |
|
282 ReadString(ptr); |
|
283 |
|
284 TLex input(buf); |
|
285 |
|
286 TInt pktlen = 0; |
|
287 while ((input.Peek()).IsDigit()) { |
|
288 pktlen = 10*pktlen + (input.Get()) - '0'; |
|
289 } |
|
290 |
|
291 _printf(_L("\n----------------------------------------\n")); |
|
292 _printf(_L("This test listens for data on the ACM\n")); |
|
293 _printf(_L("port and echoes anything it receives\n")); |
|
294 _printf(_L("back to the PC. Press any key to quit.\n")); |
|
295 _printf(_L("----------------------------------------\n\n")); |
|
296 |
|
297 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
298 CleanupClosePushL(port); |
|
299 |
|
300 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
301 |
|
302 port.SetConfig(TheConfigBuf); |
|
303 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
304 |
|
305 _printf(_L("Echoing received data\n")); |
|
306 |
|
307 console->Read(consoleStatus); |
|
308 |
|
309 FOREVER |
|
310 { |
|
311 port.Read(status, readBigBuf, pktlen); |
|
312 |
|
313 User::WaitForRequest(status, consoleStatus); |
|
314 |
|
315 if (consoleStatus == KRequestPending) |
|
316 { |
|
317 if (status != KErrNone) |
|
318 { |
|
319 |
|
320 console->ReadCancel(); |
|
321 LEAVE(status.Int()); |
|
322 } |
|
323 } |
|
324 else |
|
325 { |
|
326 port.ReadCancel(); |
|
327 break; |
|
328 } |
|
329 port.Write(status, readBigBuf); |
|
330 User::WaitForRequest(status, consoleStatus); |
|
331 |
|
332 if (consoleStatus == KRequestPending) |
|
333 { |
|
334 if (status != KErrNone) |
|
335 { |
|
336 // need to cancel the read to avoid a CBase-77 panic! |
|
337 console->ReadCancel(); |
|
338 LEAVE(status.Int()); |
|
339 } |
|
340 } |
|
341 else |
|
342 { |
|
343 port.WriteCancel(); |
|
344 break; |
|
345 } |
|
346 } |
|
347 |
|
348 _printf(_L("\nTest complete\n")); |
|
349 |
|
350 CleanupStack::PopAndDestroy(); // port |
|
351 |
|
352 } |
|
353 |
|
354 /** |
|
355 * Original loopback test - uses ReadOneOrMore(). |
|
356 */ |
|
357 |
|
358 void LoopbackTestL() |
|
359 { |
|
360 TRequestStatus consoleStatus; |
|
361 TRequestStatus status; |
|
362 RComm port; |
|
363 |
|
364 _printf(_L("\n----------------------------------------\n")); |
|
365 _printf(_L("This test listens for data on the ACM\n")); |
|
366 _printf(_L("port and echoes anything it receives\n")); |
|
367 _printf(_L("back to the PC. Press any key to quit.\n")); |
|
368 _printf(_L("----------------------------------------\n\n")); |
|
369 |
|
370 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
371 CleanupClosePushL(port); |
|
372 |
|
373 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
374 |
|
375 port.SetConfig(TheConfigBuf); |
|
376 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
377 |
|
378 _printf(_L("Echoing received data\n")); |
|
379 |
|
380 TBuf8<256> readBuf; |
|
381 |
|
382 console->Read(consoleStatus); |
|
383 |
|
384 FOREVER |
|
385 { |
|
386 port.ReadOneOrMore(status, readBuf); |
|
387 |
|
388 User::WaitForRequest(status, consoleStatus); |
|
389 |
|
390 if (consoleStatus == KRequestPending) |
|
391 { |
|
392 if (status != KErrNone) |
|
393 { |
|
394 // need to cancel the read to avoid a CBase-77 panic! |
|
395 console->ReadCancel(); |
|
396 LEAVE(status.Int()); |
|
397 } |
|
398 } |
|
399 else |
|
400 { |
|
401 port.ReadCancel(); |
|
402 break; |
|
403 } |
|
404 port.Write(status, readBuf); |
|
405 User::WaitForRequest(status, consoleStatus); |
|
406 |
|
407 if (consoleStatus == KRequestPending) |
|
408 { |
|
409 if (status != KErrNone) |
|
410 { |
|
411 // need to cancel the read to avoid a CBase-77 panic! |
|
412 console->ReadCancel(); |
|
413 LEAVE(status.Int()); |
|
414 } |
|
415 } |
|
416 else |
|
417 { |
|
418 port.WriteCancel(); |
|
419 break; |
|
420 } |
|
421 } |
|
422 |
|
423 _printf(_L("\nTest complete\n")); |
|
424 |
|
425 CleanupStack::PopAndDestroy(); // port |
|
426 } |
|
427 |
|
428 /** |
|
429 * NotifydataAvailable test. |
|
430 */ |
|
431 |
|
432 void NotifyDataAvailableTestL() |
|
433 { |
|
434 TRequestStatus status; |
|
435 TRequestStatus stat2; |
|
436 RComm port; |
|
437 |
|
438 _printf(_L("\n----------------------------------------\n")); |
|
439 _printf(_L("This test listens for data on the ACM\n")); |
|
440 _printf(_L("port and echoes anything it receives\n")); |
|
441 _printf(_L("back to the PC. Press any key to quit.\n")); |
|
442 _printf(_L("----------------------------------------\n\n")); |
|
443 |
|
444 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
445 CleanupClosePushL(port); |
|
446 |
|
447 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
448 |
|
449 port.SetConfig(TheConfigBuf); |
|
450 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
451 |
|
452 _printf(_L("Echoing received data\n")); |
|
453 |
|
454 TBuf8<256> readBuf; |
|
455 |
|
456 _printf(_L("*********************************\n")); |
|
457 _printf(_L("test NotifyDataAvailable\n")); |
|
458 TRequestStatus stat; |
|
459 TRequestStatus status2; |
|
460 |
|
461 _printf(_L("test NotifyDataAvailable, nominal test\n")); |
|
462 |
|
463 port.NotifyDataAvailable(status); |
|
464 |
|
465 User::WaitForRequest(status); // wait until the data is available |
|
466 |
|
467 LEAVEIFERROR(status.Int()); |
|
468 |
|
469 TBuf8<30> receive; |
|
470 port.ReadOneOrMore(status,receive); |
|
471 User::WaitForRequest(status); |
|
472 |
|
473 LEAVEIFERROR(status.Int()); |
|
474 |
|
475 _printf(_L("test NotifyDataAvailable, nominal test succeeded\n")); |
|
476 |
|
477 |
|
478 //=========== Test the KErrInUse that should be returned when a notification of data available is posted at the same |
|
479 // time as a Read - or visa versa ============== // |
|
480 _printf(_L("test NotifyDataAvailable, KErrInUse mode\n")); |
|
481 |
|
482 TBuf8<10> buf; |
|
483 port.ReadOneOrMore(status,buf); |
|
484 port.NotifyDataAvailable(status2); |
|
485 User::WaitForRequest(status2); |
|
486 if (status2.Int() != KErrInUse) |
|
487 { |
|
488 LEAVE(status2.Int()); |
|
489 } |
|
490 LEAVEIFERROR(port.ReadCancel()); |
|
491 |
|
492 User::WaitForRequest(status); |
|
493 if (status.Int() != KErrCancel) |
|
494 { |
|
495 LEAVE(status.Int()); |
|
496 } |
|
497 // 2nd case |
|
498 port.NotifyDataAvailable(status); |
|
499 port.ReadOneOrMore(status2,buf); |
|
500 User::WaitForRequest(status2); |
|
501 if (status2.Int() != KErrInUse) |
|
502 { |
|
503 LEAVE(status2.Int()); |
|
504 } |
|
505 |
|
506 // cancel |
|
507 LEAVEIFERROR(port.NotifyDataAvailableCancel()); |
|
508 |
|
509 User::WaitForRequest(status); |
|
510 |
|
511 if (status.Int() != KErrCancel) |
|
512 { |
|
513 LEAVE(status.Int()); |
|
514 } |
|
515 _printf(_L("test NotifyDataAvailable, KErrInUse test succeeded\n")); |
|
516 |
|
517 |
|
518 // ====== test NotifyDataAvailable, testing canceling |
|
519 |
|
520 _printf(_L("test NotifyDataAvailable, testing canceling\n")); |
|
521 port.NotifyDataAvailable(stat); |
|
522 User::WaitForRequest(stat); |
|
523 |
|
524 LEAVEIFERROR(stat.Int()); |
|
525 |
|
526 port.ResetBuffers(); |
|
527 // testing canceling |
|
528 stat2=KErrNone; |
|
529 port.NotifyDataAvailable(stat2); |
|
530 LEAVEIFERROR(port.NotifyDataAvailableCancel()); |
|
531 User::WaitForRequest(stat2); // |
|
532 if (stat2.Int() != KErrCancel) |
|
533 { |
|
534 LEAVE(stat2.Int()); |
|
535 } |
|
536 stat2=KErrNone; |
|
537 port.NotifyDataAvailable(stat2); |
|
538 LEAVEIFERROR(port.NotifyDataAvailableCancel()); |
|
539 |
|
540 User::WaitForRequest(stat2); // |
|
541 if (stat2.Int() != KErrCancel) |
|
542 { |
|
543 LEAVE(stat2.Int()); |
|
544 } |
|
545 |
|
546 _printf(_L("test NotifyDataAvailable, testing canceling succeeded\n")); |
|
547 |
|
548 User::After(20000000); |
|
549 |
|
550 _printf(_L("\nTest complete\n")); |
|
551 |
|
552 CleanupStack::PopAndDestroy(); // port |
|
553 } |
|
554 |
|
555 void ReadWithTerminatorsLoopbackTestL() |
|
556 { |
|
557 TRequestStatus consoleStatus; |
|
558 TRequestStatus status; |
|
559 RComm port; |
|
560 |
|
561 // Get terminator characters |
|
562 _printf(_L("Enter the terminator characters (up to %d):"), KConfigMaxTerminators); |
|
563 TBufC<KConfigMaxTerminators> termbuf; |
|
564 TPtr termptr (termbuf.Des()); |
|
565 ReadString(termptr); |
|
566 TText8 terminators[KConfigMaxTerminators]; |
|
567 if ( termptr.Length() == 0 ) |
|
568 { |
|
569 _printf(_L("\nno terminators given- not running test")); |
|
570 return; |
|
571 } |
|
572 TUint termCount = 0; |
|
573 TUint ii; |
|
574 for ( ii = 0 ; ii < (TUint)termptr.Length() ; ii++ ) |
|
575 { |
|
576 termCount++; |
|
577 terminators[ii] = (TText8)termptr[ii]; |
|
578 } |
|
579 |
|
580 _printf(_L("\nEnter the packet size:")); |
|
581 TBufC<8> buf; |
|
582 TPtr ptr (buf.Des()); |
|
583 ReadString(ptr); |
|
584 |
|
585 TLex input(buf); |
|
586 |
|
587 TInt pktlen = 0; |
|
588 while ((input.Peek()).IsDigit()) { |
|
589 pktlen = 10*pktlen + (input.Get()) - '0'; |
|
590 } |
|
591 |
|
592 _printf(_L("\n----------------------------------------\n")); |
|
593 _printf(_L("This test listens for data on the ACM\n")); |
|
594 _printf(_L("port and echoes anything it receives\n")); |
|
595 _printf(_L("back to the PC. Press any key to quit.\n")); |
|
596 _printf(_L("----------------------------------------\n\n")); |
|
597 |
|
598 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
599 CleanupClosePushL(port); |
|
600 |
|
601 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
602 |
|
603 // Set the config, including terminator characters. |
|
604 TCommConfig configBuf; |
|
605 TCommConfigV01& config = configBuf(); |
|
606 port.Config(configBuf); |
|
607 config.iTerminatorCount = termCount; |
|
608 for ( ii = 0 ; ii < termCount ; ii++ ) |
|
609 { |
|
610 config.iTerminator[ii] = terminators[ii]; |
|
611 } |
|
612 LEAVEIFERROR(port.SetConfig(configBuf)); |
|
613 |
|
614 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
615 |
|
616 _printf(_L("Echoing received data\n")); |
|
617 |
|
618 console->Read(consoleStatus); |
|
619 |
|
620 TBuf8<256> readBuf; |
|
621 |
|
622 FOREVER |
|
623 { |
|
624 port.Read(status, readBuf, pktlen); |
|
625 |
|
626 User::WaitForRequest(status, consoleStatus); |
|
627 |
|
628 if (consoleStatus == KRequestPending) |
|
629 { |
|
630 if (status != KErrNone) |
|
631 { |
|
632 console->ReadCancel(); |
|
633 LEAVE(status.Int()); |
|
634 } |
|
635 } |
|
636 else |
|
637 { |
|
638 port.ReadCancel(); |
|
639 break; |
|
640 } |
|
641 |
|
642 port.Write(status, readBuf); |
|
643 User::WaitForRequest(status, consoleStatus); |
|
644 |
|
645 if (consoleStatus == KRequestPending) |
|
646 { |
|
647 if (status != KErrNone) |
|
648 { |
|
649 // need to cancel the read to avoid a CBase-77 panic! |
|
650 console->ReadCancel(); |
|
651 LEAVE(status.Int()); |
|
652 } |
|
653 } |
|
654 else |
|
655 { |
|
656 port.WriteCancel(); |
|
657 break; |
|
658 } |
|
659 } |
|
660 |
|
661 _printf(_L("\nTest complete\n")); |
|
662 |
|
663 CleanupStack::PopAndDestroy(); // port |
|
664 } |
|
665 |
|
666 ///////////////////////////////////////////////////////////////////////////////// |
|
667 |
|
668 void DataStress_SizeVary_TestL() |
|
669 /** |
|
670 * Runs the test as specified in the ACM unit test specification. |
|
671 */ |
|
672 { |
|
673 TRequestStatus status; |
|
674 RComm port; |
|
675 TInt i; |
|
676 |
|
677 _printf(_L("\n----------------------------------\n")); |
|
678 _printf(_L("This test performs varying size read\n")); |
|
679 _printf(_L("and writes to and from the host.\n")); |
|
680 _printf(_L("------------------------------------\n\n")); |
|
681 |
|
682 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
683 CleanupClosePushL(port); |
|
684 |
|
685 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
686 |
|
687 port.SetConfig(TheConfigBuf); |
|
688 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
689 |
|
690 TBuf8<MAX_BUFFER_SIZE> readBuf; |
|
691 |
|
692 _printf(_L("Reading data.\nLengths:")); |
|
693 for (i = 1; i<MAX_BUFFER_SIZE; i*=2) |
|
694 { |
|
695 _printf(_L(" %d"), i); |
|
696 |
|
697 port.Read(status, readBuf, i); |
|
698 User::WaitForRequest(status); |
|
699 |
|
700 if (status != KErrNone) |
|
701 { |
|
702 LEAVE(status.Int()); |
|
703 } |
|
704 |
|
705 CheckBuffer(readBuf, i); |
|
706 } |
|
707 |
|
708 _printf(_L(" done.\nReadOneOrMore()-ing data.\n")); |
|
709 TUint totalExpectedTransfer = 0; |
|
710 for (i = 1; i<MAX_BUFFER_SIZE; i*=2) |
|
711 { |
|
712 totalExpectedTransfer += i; |
|
713 } |
|
714 TUint totalTransfer = 0; |
|
715 while ( totalTransfer < totalExpectedTransfer ) |
|
716 { |
|
717 port.ReadOneOrMore(status, readBuf); |
|
718 User::WaitForRequest(status); |
|
719 |
|
720 if (status != KErrNone) |
|
721 { |
|
722 _printf(_L("Read error")); |
|
723 LEAVE(status.Int()); |
|
724 } |
|
725 else |
|
726 { |
|
727 totalTransfer += readBuf.Length(); |
|
728 } |
|
729 } |
|
730 |
|
731 _printf(_L("\n Writing\n")); |
|
732 |
|
733 for (i = 1; i<MAX_BUFFER_SIZE; i*=2) |
|
734 { |
|
735 |
|
736 FillBuffer(readBuf); |
|
737 |
|
738 port.Write(status, readBuf, i); |
|
739 |
|
740 User::WaitForRequest(status); |
|
741 |
|
742 if (status != KErrNone) |
|
743 { |
|
744 _printf(_L("write error\n")); |
|
745 LEAVE(status.Int()); |
|
746 } |
|
747 |
|
748 _printf(_L(" %d"), i); |
|
749 } |
|
750 |
|
751 _printf(_L(" done.\nTest complete\n")); |
|
752 CleanupStack::PopAndDestroy(); //port |
|
753 } |
|
754 |
|
755 |
|
756 void DataStress_RateVary_TestL() |
|
757 /** |
|
758 * Runs the test as specified in the ACM unit test specification. |
|
759 */ |
|
760 { |
|
761 TRequestStatus status; |
|
762 RComm port; |
|
763 TInt i; |
|
764 |
|
765 _printf(_L("\n----------------------------------\n")); |
|
766 _printf(_L("This test performs varying speed read\n")); |
|
767 _printf(_L("and writes to and from the host.\n")); |
|
768 _printf(_L("------------------------------------\n\n")); |
|
769 |
|
770 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
771 CleanupClosePushL(port); |
|
772 |
|
773 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
774 |
|
775 port.SetConfig(TheConfigBuf); |
|
776 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
777 |
|
778 TBuf8<MAX_BUFFER_SIZE> readBuf; |
|
779 |
|
780 _printf(_L("Reading data.\nLengths:")); |
|
781 for (i = 1; i<100; i++) |
|
782 { |
|
783 _printf(_L(" %d"), i); |
|
784 port.Read(status, readBuf); |
|
785 User::WaitForRequest(status); |
|
786 |
|
787 if (status != KErrNone) |
|
788 { |
|
789 _printf(_L("Error reading")); |
|
790 LEAVE(status.Int()); |
|
791 } |
|
792 |
|
793 CheckBuffer(readBuf, readBuf.MaxSize()); |
|
794 } |
|
795 |
|
796 |
|
797 _printf(_L("done.\nReadOneOrMore()-ing data.\n ")); |
|
798 int totalTransferSize = 19*MAX_BUFFER_SIZE; |
|
799 int totalTransfer = 0; |
|
800 while (totalTransfer < totalTransferSize) { |
|
801 port.ReadOneOrMore(status, readBuf); |
|
802 User::WaitForRequest(status); |
|
803 |
|
804 if (status != KErrNone) |
|
805 { |
|
806 LEAVE(status.Int()); |
|
807 } |
|
808 else |
|
809 { |
|
810 totalTransfer += readBuf.Length(); |
|
811 } |
|
812 } |
|
813 |
|
814 _printf(_L(" Writing data\n")); |
|
815 |
|
816 FillBuffer(readBuf); |
|
817 |
|
818 for (i = 1; i< 100; i++) |
|
819 { |
|
820 _printf(_L(" %d "), i); |
|
821 port.Write(status, readBuf, MAX_BUFFER_SIZE); |
|
822 User::WaitForRequest(status); |
|
823 |
|
824 if (status != KErrNone) |
|
825 { |
|
826 _printf(_L("Write failed\n")); |
|
827 LEAVE(status.Int()); |
|
828 } |
|
829 |
|
830 // Wait for random time |
|
831 timer.After(status, (Math::Rand(seed) % 1001));//1001 to get a value within [0-1000] |
|
832 User::WaitForRequest(status); |
|
833 } |
|
834 |
|
835 _printf(_L(" done.\nTest complete\n")); |
|
836 CleanupStack::PopAndDestroy(); // port |
|
837 } |
|
838 |
|
839 |
|
840 void TimeOut_TestL() |
|
841 /** |
|
842 * Runs the test as specified in the ACM unit test specification. |
|
843 */ |
|
844 { |
|
845 TRequestStatus status; |
|
846 RComm port; |
|
847 TInt timeout; |
|
848 |
|
849 TBuf8<MAX_BUFFER_SIZE> readBuf; |
|
850 |
|
851 _printf(_L("\n---------------------------\n")); |
|
852 _printf(_L("This test exercises the read\n")); |
|
853 _printf(_L("and write timeouts.\n")); |
|
854 _printf(_L("-----------------------------\n\n")); |
|
855 |
|
856 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
857 CleanupClosePushL(port); |
|
858 |
|
859 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
860 |
|
861 port.SetConfig(TheConfigBuf); |
|
862 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
863 |
|
864 _printf(_L("Reading data\nTimeouts (ms):")); |
|
865 for (timeout = 10; timeout<100; timeout+=10) |
|
866 { |
|
867 // Clean buffers |
|
868 port.ResetBuffers(); |
|
869 |
|
870 _printf(_L(" %d"), timeout); |
|
871 port.Read(status, timeout, readBuf, MAX_BUFFER_SIZE); |
|
872 User::WaitForRequest(status); |
|
873 |
|
874 if (status != KErrTimedOut) |
|
875 { |
|
876 LEAVE(status.Int()); |
|
877 } |
|
878 } |
|
879 |
|
880 TBuf8<MAX_BUFFER_SIZE> writeBuf; |
|
881 writeBuf = _L8("some data"); |
|
882 _printf(_L(" done.\nWriting data\nTimeouts (ms):")); |
|
883 for (timeout = 10; timeout<100; timeout+=10) |
|
884 { |
|
885 // Clean buffers |
|
886 port.ResetBuffers(); |
|
887 |
|
888 _printf(_L(" %d"), timeout); |
|
889 port.Write(status, timeout, writeBuf); |
|
890 User::WaitForRequest(status); |
|
891 |
|
892 if (status != KErrTimedOut && status != KErrNone ) // NB Writes complete very quickly. |
|
893 { |
|
894 LEAVE(status.Int()); |
|
895 } |
|
896 } |
|
897 |
|
898 _printf(_L(" done.\nTest complete\n")); |
|
899 CleanupStack::PopAndDestroy(); // port |
|
900 } |
|
901 |
|
902 void CancelTx_TestL() |
|
903 /** |
|
904 * Runs the test as specified in the ACM unit test specification. |
|
905 */ |
|
906 { |
|
907 TRequestStatus status; |
|
908 RComm port; |
|
909 TInt timeout; |
|
910 |
|
911 TBuf8<MAX_BUFFER_SIZE> readBuf; |
|
912 |
|
913 _printf(_L("\n----------------------------------------\n")); |
|
914 _printf(_L("This tests the read/write cancel feature\n")); |
|
915 _printf(_L("------------------------------------------\n\n")); |
|
916 |
|
917 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
918 CleanupClosePushL(port); |
|
919 |
|
920 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
921 |
|
922 port.SetConfig(TheConfigBuf); |
|
923 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
924 |
|
925 _printf(_L("Reading data\n")); |
|
926 for (timeout = 10; timeout<100; timeout++) |
|
927 { |
|
928 port.Read(status, readBuf); |
|
929 |
|
930 // Wait before cancelling |
|
931 timer.After(status, timeout); |
|
932 User::WaitForRequest(status); |
|
933 |
|
934 port.ReadCancel(); |
|
935 User::WaitForRequest(status); |
|
936 |
|
937 if ( (status != KErrNone) && (status !=KErrCancel) ) |
|
938 { |
|
939 LEAVE(status.Int()); |
|
940 } |
|
941 } |
|
942 |
|
943 _printf(_L("Writing data\n")); |
|
944 for (timeout = 10; timeout<100; timeout++) |
|
945 { |
|
946 // FillBuffer(readBuf); |
|
947 |
|
948 port.Write(status, readBuf); |
|
949 |
|
950 // Wait before cancelling |
|
951 timer.After(status, timeout); |
|
952 User::WaitForRequest(status); |
|
953 |
|
954 port.WriteCancel(); |
|
955 User::WaitForRequest(status); |
|
956 |
|
957 if ( (status != KErrNone) && (status !=KErrCancel) ) |
|
958 { |
|
959 LEAVE(status.Int()); |
|
960 } |
|
961 } |
|
962 |
|
963 _printf(_L("\nTest complete\n")); |
|
964 CleanupStack::PopAndDestroy(); // port |
|
965 } |
|
966 |
|
967 void InterruptTx_TestL() |
|
968 /** |
|
969 * Runs the test as specified in the ACM unit test specification. |
|
970 */ |
|
971 { |
|
972 TRequestStatus status; |
|
973 RComm port; |
|
974 |
|
975 TBuf8<MAX_BUFFER_SIZE> readBuf; |
|
976 |
|
977 _printf(_L("\n--------------------------------\n")); |
|
978 _printf(_L("This tests the read/write cancel\n")); |
|
979 _printf(_L("when the USB cable is pulled\n")); |
|
980 _printf(_L("----------------------------------\n\n")); |
|
981 |
|
982 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
983 CleanupClosePushL(port); |
|
984 |
|
985 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
986 |
|
987 port.SetConfig(TheConfigBuf); |
|
988 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
989 |
|
990 _printf(_L("Reading data\n")); |
|
991 port.Read(status, readBuf); |
|
992 |
|
993 _printf(_L("Pull cable now\n")); |
|
994 User::WaitForRequest(status); |
|
995 _printf(_L("Received error code: %d\n"),status.Int()); |
|
996 _printf(_L("Expect -29(KErrCommsLineFail) or range -6702 to -6712 (USB driver errors)\n\n")); |
|
997 |
|
998 _printf(_L("Plug in cable and press any key\n")); |
|
999 _getch(); |
|
1000 User::After(1000000); |
|
1001 |
|
1002 _printf(_L("Pull cable now\n")); |
|
1003 _printf(_L("Writing data...\n")); |
|
1004 do |
|
1005 { |
|
1006 port.Write(status, readBuf); |
|
1007 User::WaitForRequest(status); |
|
1008 |
|
1009 } while (status == KErrNone); |
|
1010 |
|
1011 _printf(_L("Received error code: %d\n"),status.Int()); |
|
1012 _printf(_L("Expect -29(KErrCommsLineFail) or range -6702 to -6712 (USB driver errors)\n\n")); |
|
1013 |
|
1014 _printf(_L("Plug in cable and press any key- test is now finished\n")); |
|
1015 _getch(); |
|
1016 |
|
1017 _printf(_L("\nTest complete\n")); |
|
1018 CleanupStack::PopAndDestroy(); // port |
|
1019 } |
|
1020 |
|
1021 void Shutdown_TestL() |
|
1022 /** |
|
1023 * Runs the test as specified in the ACM unit test specification. |
|
1024 */ |
|
1025 { |
|
1026 TRequestStatus status; |
|
1027 RComm port; |
|
1028 |
|
1029 TBuf8<MAX_BUFFER_SIZE> readBuf; |
|
1030 |
|
1031 _printf(_L("\n-----------------------------------\n")); |
|
1032 _printf(_L("This tests the USB Manager shutdown\n")); |
|
1033 _printf(_L("during reads and writes.\n")); |
|
1034 _printf(_L("-------------------------------------\n\n")); |
|
1035 |
|
1036 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1037 CleanupClosePushL(port); |
|
1038 |
|
1039 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
1040 |
|
1041 port.SetConfig(TheConfigBuf); |
|
1042 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
1043 |
|
1044 _printf(_L("Reading data\n")); |
|
1045 port.Read(status, readBuf); |
|
1046 |
|
1047 _printf(_L("Shutting down USB Manager.\n")); |
|
1048 TheUsb.Stop(); |
|
1049 |
|
1050 _printf(_L("shutdown complete.\nWaiting for read to terminate.")); |
|
1051 User::WaitForRequest(status); |
|
1052 |
|
1053 if (status != KErrAccessDenied) |
|
1054 { |
|
1055 LEAVE(status.Int()); |
|
1056 } |
|
1057 |
|
1058 _printf(_L("Read complete.\nRestarting USB Manager\n")); |
|
1059 TheUsb.Start(status); |
|
1060 User::WaitForRequest(status); |
|
1061 LEAVEIFERROR(status.Int()); |
|
1062 |
|
1063 // Hacky pause to wait for device to enumerate. |
|
1064 User::After(1000000); |
|
1065 _printf(_L("Writing data\n")); |
|
1066 |
|
1067 port.Write(status, readBuf); |
|
1068 |
|
1069 _printf(_L("Shutting down USB Manager\n")); |
|
1070 TheUsb.Stop(); |
|
1071 |
|
1072 _printf(_L("shutdown complete.\nWaiting for write to terminate.")); |
|
1073 if ( status == KErrNone ) |
|
1074 { |
|
1075 // The Write already completed. This part of the test didn't work |
|
1076 // (i.e. it didn't actually test 'shutting down the USB Manager |
|
1077 // causes Write completion'), but there's not much we can do about it. |
|
1078 } |
|
1079 else |
|
1080 { |
|
1081 // If the Write is still outstanding at this point, it should |
|
1082 // eventually complete with access denied. |
|
1083 User::WaitForRequest(status); |
|
1084 if (status != KErrAccessDenied) |
|
1085 { |
|
1086 LEAVE(status.Int()); |
|
1087 } |
|
1088 } |
|
1089 |
|
1090 _printf(_L("Write complete.\nRestarting USB Manager\n")); |
|
1091 TheUsb.Start(status); |
|
1092 User::WaitForRequest(status); |
|
1093 LEAVEIFERROR(status.Int()); |
|
1094 |
|
1095 _printf(_L("\nTest complete\n")); |
|
1096 CleanupStack::PopAndDestroy(); // port |
|
1097 } |
|
1098 |
|
1099 void BufferOverrun_TestL() |
|
1100 /** |
|
1101 * Test updated from that in the ACM unit test specification to |
|
1102 * read/write messages bigger than the receive and transmit buffers. |
|
1103 * Changed as previous test was no longer valid. |
|
1104 */ |
|
1105 { |
|
1106 TRequestStatus status; |
|
1107 RComm port; |
|
1108 |
|
1109 _printf(_L("\n--------------------------------\n")); |
|
1110 _printf(_L("This tests read/writes which are\n")); |
|
1111 _printf(_L("bigger than the buffer length.\n")); |
|
1112 _printf(_L("----------------------------------\n\n")); |
|
1113 |
|
1114 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1115 CleanupClosePushL(port); |
|
1116 |
|
1117 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
1118 |
|
1119 port.SetConfig(TheConfigBuf); |
|
1120 |
|
1121 _printf(_L("Reading data.\nBuffer length: %d"), MAX_HEAP_BUFFER_SIZE); |
|
1122 |
|
1123 port.SetReceiveBufferLength(128); |
|
1124 |
|
1125 port.Read(status, readBigBuf); |
|
1126 |
|
1127 User::WaitForRequest(status); |
|
1128 |
|
1129 if (status != KErrNone) |
|
1130 { |
|
1131 LEAVE(status.Int()); |
|
1132 } |
|
1133 |
|
1134 _printf(_L("done.\nWriting data\nBuffer length: %d"), MAX_HEAP_BUFFER_SIZE); |
|
1135 FillBuffer(readBigBuf); |
|
1136 |
|
1137 port.SetReceiveBufferLength(128); |
|
1138 |
|
1139 port.Write(status, readBigBuf); |
|
1140 User::WaitForRequest(status); |
|
1141 |
|
1142 if (status != KErrNone) |
|
1143 { |
|
1144 LEAVE(status.Int()); |
|
1145 } |
|
1146 |
|
1147 _printf(_L(" done.\nTest complete\n")); |
|
1148 _printf(_L("[ press any key ]")); |
|
1149 _getch(); |
|
1150 |
|
1151 CleanupStack::PopAndDestroy(); // port |
|
1152 } |
|
1153 |
|
1154 void Break_TestL() |
|
1155 /** |
|
1156 * Runs the test as specified in the ACM unit test specification. |
|
1157 */ |
|
1158 { |
|
1159 TRequestStatus status; |
|
1160 RComm port; |
|
1161 |
|
1162 _printf(_L("\n--------------------------------\n")); |
|
1163 _printf(_L("This tests break and break cancel.\n")); |
|
1164 _printf(_L("----------------------------------\n\n")); |
|
1165 |
|
1166 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1167 CleanupClosePushL(port); |
|
1168 |
|
1169 port.SetConfig(TheConfigBuf); |
|
1170 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
1171 |
|
1172 // Check that NotifyBreak is not completed at any point (should only be |
|
1173 // completed by host-driven breaks). |
|
1174 TRequestStatus notifyBreakStat; |
|
1175 port.NotifyBreak(notifyBreakStat); |
|
1176 |
|
1177 _printf(_L("Breaking\n")); |
|
1178 port.Break(status, 10); |
|
1179 |
|
1180 User::WaitForRequest(status); |
|
1181 |
|
1182 if (status != KErrNone) |
|
1183 { |
|
1184 LEAVE(status.Int()); |
|
1185 } |
|
1186 |
|
1187 _printf(_L("Press any key to cancel a break.\n")); |
|
1188 _getch(); |
|
1189 |
|
1190 _printf(_L("Cancelling the break.\n")); |
|
1191 port.Break(status, 1000000); |
|
1192 port.BreakCancel(); |
|
1193 User::WaitForRequest(status); |
|
1194 if (status != KErrCancel) |
|
1195 { |
|
1196 LEAVE(status.Int()); |
|
1197 } |
|
1198 |
|
1199 User::After(1000000); |
|
1200 if ( notifyBreakStat != KRequestPending ) |
|
1201 { |
|
1202 LEAVE(notifyBreakStat.Int()); |
|
1203 } |
|
1204 port.NotifyBreakCancel(); |
|
1205 User::WaitForRequest(notifyBreakStat); |
|
1206 if ( notifyBreakStat != KErrCancel ) |
|
1207 { |
|
1208 LEAVE(notifyBreakStat.Int()); |
|
1209 } |
|
1210 |
|
1211 _printf(_L("\nTest complete\n")); |
|
1212 CleanupStack::PopAndDestroy(); // port |
|
1213 } |
|
1214 |
|
1215 |
|
1216 void SignalChange_TestL() |
|
1217 /** |
|
1218 * Runs the test as specified in the ACM unit test specification. |
|
1219 */ |
|
1220 { |
|
1221 TRequestStatus status, statusTimer; |
|
1222 RComm port; |
|
1223 |
|
1224 _printf(_L("\n---------------------------------------\n")); |
|
1225 _printf(_L("This tests signal change notifications.\n")); |
|
1226 _printf(_L("---------------------------------------\n\n")); |
|
1227 |
|
1228 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1229 CleanupClosePushL(port); |
|
1230 |
|
1231 port.SetConfig(TheConfigBuf); |
|
1232 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
1233 |
|
1234 TUint signals = 0; |
|
1235 signals |= KSignalDTR; |
|
1236 |
|
1237 port.NotifySignalChange(status, signals); |
|
1238 User::WaitForRequest(status); |
|
1239 |
|
1240 if (status != KErrNone) |
|
1241 { |
|
1242 LEAVE(status.Int()); |
|
1243 } |
|
1244 |
|
1245 _printf(_L("Notified\n")); |
|
1246 |
|
1247 port.NotifySignalChange(status, signals); |
|
1248 |
|
1249 // Wait |
|
1250 timer.After(statusTimer, 10); |
|
1251 User::WaitForRequest(statusTimer); |
|
1252 |
|
1253 _printf(_L("Cancelling request for signal notifications\n")); |
|
1254 |
|
1255 port.NotifySignalChangeCancel(); |
|
1256 User::WaitForRequest(status); |
|
1257 |
|
1258 if (status != KErrCancel) |
|
1259 { |
|
1260 LEAVE(status.Int()); |
|
1261 } |
|
1262 |
|
1263 _printf(_L("\nRequest cancelled.\n Test complete\n")); |
|
1264 CleanupStack::PopAndDestroy(); // port |
|
1265 } |
|
1266 |
|
1267 void FlowControl_TestL() |
|
1268 /** |
|
1269 * Runs the test as specified in the ACM unit test specification. |
|
1270 */ |
|
1271 { |
|
1272 TRequestStatus status, statusTimer; |
|
1273 RComm port; |
|
1274 |
|
1275 _printf(_L("\n-------------------------------------------\n")); |
|
1276 _printf(_L("This tests flow control change notifications.\n")); |
|
1277 _printf(_L("---------------------------------------------\n\n")); |
|
1278 |
|
1279 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1280 CleanupClosePushL(port); |
|
1281 |
|
1282 port.SetConfig(TheConfigBuf); |
|
1283 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
1284 |
|
1285 TFlowControl signals; |
|
1286 port.NotifyFlowControlChange(status, signals); |
|
1287 User::WaitForRequest(status); |
|
1288 |
|
1289 if (status != KErrNotSupported) |
|
1290 { |
|
1291 LEAVE(status.Int()); |
|
1292 } |
|
1293 |
|
1294 port.NotifyFlowControlChange(status, signals); |
|
1295 |
|
1296 // Wait |
|
1297 timer.After(statusTimer, 10); |
|
1298 User::WaitForRequest(statusTimer); |
|
1299 |
|
1300 port.NotifyFlowControlChangeCancel(); |
|
1301 User::WaitForRequest(status); |
|
1302 if (status != KErrNotSupported) |
|
1303 { |
|
1304 LEAVE(status.Int()); |
|
1305 } |
|
1306 |
|
1307 _printf(_L("\nTest complete\n")); |
|
1308 CleanupStack::PopAndDestroy(); // port |
|
1309 } |
|
1310 |
|
1311 void ConfigChange_TestL() |
|
1312 /** |
|
1313 * Runs the test as specified in the ACM unit test specification. |
|
1314 */ |
|
1315 { |
|
1316 TRequestStatus status, statusTimer; |
|
1317 RComm port; |
|
1318 |
|
1319 _printf(_L("\n-------------------------------------\n")); |
|
1320 _printf(_L("This tests config change notifications.\n")); |
|
1321 _printf(_L("---------------------------------------\n\n")); |
|
1322 |
|
1323 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1324 CleanupClosePushL(port); |
|
1325 |
|
1326 port.SetConfig(TheConfigBuf); |
|
1327 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
1328 |
|
1329 TBuf8<64> signals; |
|
1330 port.NotifyConfigChange(status, signals); |
|
1331 User::WaitForRequest(status); |
|
1332 |
|
1333 if (status != KErrNone) |
|
1334 { |
|
1335 LEAVE(status.Int()); |
|
1336 } |
|
1337 |
|
1338 _printf(_L("Notified, waiting for a while before the next test\n")); |
|
1339 |
|
1340 // Wait |
|
1341 timer.After(statusTimer, 10); |
|
1342 User::WaitForRequest(statusTimer); |
|
1343 |
|
1344 _printf(_L("Cancelling request for config change notifications\n")); |
|
1345 |
|
1346 port.NotifyConfigChange(status, signals); |
|
1347 _printf(_L("Cancelling request for config change notifications\n")); |
|
1348 port.NotifyConfigChangeCancel(); |
|
1349 User::WaitForRequest(status); |
|
1350 |
|
1351 if (status != KErrCancel) |
|
1352 { |
|
1353 LEAVE(status.Int()); |
|
1354 } |
|
1355 |
|
1356 _printf(_L("\nRequest cancelled.\n Test complete\n")); |
|
1357 CleanupStack::PopAndDestroy(); // port |
|
1358 } |
|
1359 |
|
1360 |
|
1361 |
|
1362 void SecondClient_TestL() |
|
1363 /** |
|
1364 * Runs the test as specified in the ACM unit test specification. |
|
1365 * Updated to use a second RCommServ and to read/read in series. |
|
1366 * Tests that two clients can read/write on a single serial comms server. |
|
1367 * Note that it is invalid to have 2 reads/writes outstanding on a |
|
1368 * serial comms server. It would return a KErrInUse. |
|
1369 */ |
|
1370 { |
|
1371 RCommServ TheCommServ2; |
|
1372 RComm port1, port2; |
|
1373 TRequestStatus status1, status2; |
|
1374 |
|
1375 TBuf8<MAX_BUFFER_SIZE> readBuf1; |
|
1376 TBuf8<MAX_BUFFER_SIZE> readBuf2; |
|
1377 |
|
1378 _printf(_L("\n---------------------------------------\n")); |
|
1379 _printf(_L("This tests that we can have a second\n")); |
|
1380 _printf(_L("client with non-exclusive access.\n")); |
|
1381 _printf(_L("---------------------------------------\n\n")); |
|
1382 |
|
1383 // TheCommServ is already connected in mainL |
|
1384 _printf(_L("Connected to C32\n")); |
|
1385 LEAVEIFERROR(TheCommServ2.Connect()); |
|
1386 CleanupClosePushL(TheCommServ2); |
|
1387 _printf(_L("Connected to second C32\n")); |
|
1388 |
|
1389 LEAVEIFERROR(port1.Open(TheCommServ, KUsbPortName, ECommShared, ECommRoleDCE)); |
|
1390 CleanupClosePushL(port1); |
|
1391 LEAVEIFERROR(port2.Open(TheCommServ2, KUsbPortName, ECommShared, ECommRoleDCE)); |
|
1392 CleanupClosePushL(port2); |
|
1393 |
|
1394 port1.SetConfig(TheConfigBuf); |
|
1395 port1.SetReceiveBufferLength(256); |
|
1396 port2.SetConfig(TheConfigBuf); |
|
1397 port2.SetReceiveBufferLength(256); |
|
1398 |
|
1399 _printf(_L("Read()-ing data\n")); |
|
1400 port1.Read(status1, readBuf1); |
|
1401 _printf(_L("First data read\n")); |
|
1402 |
|
1403 User::WaitForAnyRequest(); |
|
1404 if ( status1 != KErrNone ) |
|
1405 { |
|
1406 LEAVE(status1.Int()); |
|
1407 } |
|
1408 _printf(_L("status of first read: %d\n"), status1.Int()); |
|
1409 |
|
1410 port2.Read(status2, readBuf2); |
|
1411 _printf(_L("Second data read\n")); |
|
1412 |
|
1413 User::WaitForAnyRequest(); |
|
1414 if ( status2 != KErrNone ) |
|
1415 { |
|
1416 LEAVE(status2.Int()); |
|
1417 } |
|
1418 _printf(_L("status of second read: %d\n"), status2.Int()); |
|
1419 |
|
1420 _printf(_L("Reading complete\n"), status1.Int()); |
|
1421 |
|
1422 TBuf8<256> readBuf; |
|
1423 |
|
1424 _printf(_L("Write()-ing data\n")); |
|
1425 FillBuffer(readBuf); |
|
1426 |
|
1427 // Test Writes |
|
1428 port1.Write(status1, readBuf, 256); |
|
1429 User::WaitForAnyRequest(); |
|
1430 if ( status1 != KErrNone ) |
|
1431 { |
|
1432 LEAVE(status1.Int()); |
|
1433 } |
|
1434 _printf(_L("status of first write : %d\n"), status1.Int()); |
|
1435 |
|
1436 port2.Write(status2, readBuf, 256); |
|
1437 User::WaitForAnyRequest(); |
|
1438 if ( status2 != KErrNone ) |
|
1439 { |
|
1440 LEAVE(status2.Int()); |
|
1441 } |
|
1442 _printf(_L("status of second write : %d\n"), status1.Int(), status2.Int()); |
|
1443 |
|
1444 _printf(_L("\nTest complete\n")); |
|
1445 _printf(_L("[ press any key ]")); |
|
1446 _getch(); |
|
1447 |
|
1448 CleanupStack::PopAndDestroy(); // port |
|
1449 CleanupStack::PopAndDestroy(); // the other port |
|
1450 CleanupStack::PopAndDestroy(); // TheCommServ2 |
|
1451 } |
|
1452 |
|
1453 |
|
1454 // ****************************************************************** |
|
1455 // The following are placholders for the ACMRq tests. |
|
1456 // These tests need no support on the platform end, as yet. |
|
1457 // The functions are left here incase someday support is needed. |
|
1458 // ****************************************************************** |
|
1459 |
|
1460 void ACMRq_EncapCommand_TestL() |
|
1461 { |
|
1462 // Not needed to support this here |
|
1463 } |
|
1464 |
|
1465 void ACMRq_Break_TestL() |
|
1466 { |
|
1467 // TODO: can we check for break status here ? |
|
1468 } |
|
1469 |
|
1470 void ACMRq_SetFeature_TestL() |
|
1471 { |
|
1472 // TODO: Test doesn't make sense. |
|
1473 } |
|
1474 |
|
1475 void ACMRq_ClearFeature_TestL() |
|
1476 { |
|
1477 // TODO: Test doesn't make sense. |
|
1478 } |
|
1479 |
|
1480 void ACMRq_SetCoding_TestL() |
|
1481 { |
|
1482 // TODO: Can we check the line codeing here ? |
|
1483 } |
|
1484 |
|
1485 void ACMRq_CtrlState_TestL() |
|
1486 { |
|
1487 // TODO: Test doesn't make sense. |
|
1488 } |
|
1489 |
|
1490 void ACMRq_EncapResp_TestL() |
|
1491 { |
|
1492 // Not needed to support this here. |
|
1493 } |
|
1494 |
|
1495 void ACMRq_CommsFeature_TestL() |
|
1496 { |
|
1497 // Not needed to support this here. |
|
1498 } |
|
1499 |
|
1500 void ACMRq_GetCoding_TestL() |
|
1501 { |
|
1502 // Not needed to support this here. |
|
1503 } |
|
1504 |
|
1505 |
|
1506 void ACMNtf_SendState_TestL() |
|
1507 { |
|
1508 // TODO: SendSerialState() ??? |
|
1509 } |
|
1510 |
|
1511 void ACMNtf_Status_TestL() |
|
1512 { |
|
1513 // TODO: SendNetworkConnection() ??? |
|
1514 } |
|
1515 |
|
1516 void ACMNtf_RespAvail_TestL() |
|
1517 { |
|
1518 // Test not supported. |
|
1519 } |
|
1520 |
|
1521 void AcmLoopback_TestL() |
|
1522 /** |
|
1523 * Runs the test as specified in the ACM unit test specification. |
|
1524 */ |
|
1525 { |
|
1526 TRequestStatus consoleStatus; |
|
1527 TRequestStatus status; |
|
1528 RComm port; |
|
1529 |
|
1530 _printf(_L("\n----------------------------------------\n")); |
|
1531 _printf(_L("This test listens for data on the ACM\n")); |
|
1532 _printf(_L("port and echoes anything it receives\n")); |
|
1533 _printf(_L("back to the PC. Press any key to quit.\n")); |
|
1534 _printf(_L("----------------------------------------\n\n")); |
|
1535 |
|
1536 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1537 CleanupClosePushL(port); |
|
1538 |
|
1539 _printf(_L("Setting handshaking & receive buffer length\n")); |
|
1540 |
|
1541 port.SetConfig(TheConfigBuf); |
|
1542 port.SetReceiveBufferLength(KReceiveBufferLength); |
|
1543 |
|
1544 _printf(_L("Echoing received data\n")); |
|
1545 |
|
1546 TBuf8<1024> readBuf; |
|
1547 |
|
1548 console->Read(consoleStatus); |
|
1549 |
|
1550 FOREVER |
|
1551 { |
|
1552 port.ReadOneOrMore(status, readBuf); |
|
1553 User::WaitForRequest(status, consoleStatus); |
|
1554 |
|
1555 if (consoleStatus == KRequestPending) |
|
1556 { |
|
1557 if (status != KErrNone) |
|
1558 { |
|
1559 // need to cancel the read to avoid a CBase-77 panic! |
|
1560 console->ReadCancel(); |
|
1561 LEAVE(status.Int()); |
|
1562 } |
|
1563 } |
|
1564 else |
|
1565 { |
|
1566 port.ReadCancel(); |
|
1567 break; |
|
1568 } |
|
1569 |
|
1570 port.Write(status, readBuf); |
|
1571 User::WaitForRequest(status, consoleStatus); |
|
1572 |
|
1573 if (consoleStatus == KRequestPending) |
|
1574 { |
|
1575 if (status != KErrNone) |
|
1576 { |
|
1577 // need to cancel the read to avoid a CBase-77 panic! |
|
1578 console->ReadCancel(); |
|
1579 LEAVE(status.Int()); |
|
1580 } |
|
1581 } |
|
1582 else |
|
1583 { |
|
1584 port.WriteCancel(); |
|
1585 break; |
|
1586 } |
|
1587 |
|
1588 _printf(_L(".")); |
|
1589 } |
|
1590 |
|
1591 _printf(_L("\nTest complete\n")); |
|
1592 |
|
1593 CleanupStack::PopAndDestroy(); // port |
|
1594 } |
|
1595 |
|
1596 void SetHandshakingL() |
|
1597 /** |
|
1598 * This function allows the user to select a new handshaking mode. |
|
1599 */ |
|
1600 { |
|
1601 RComm port; |
|
1602 |
|
1603 TCommCaps capsBuf; |
|
1604 TCommCapsV01& caps = capsBuf(); |
|
1605 |
|
1606 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1607 CleanupClosePushL(port); |
|
1608 |
|
1609 port.Caps(capsBuf); |
|
1610 _printf(_L("\nPort handshaking capabilities: 0x%X\n"), caps.iHandshake); |
|
1611 _printf(_L("Current handshaking options: 0x%X\n"), TheConfig.iHandshake); |
|
1612 |
|
1613 _printf(_L("\nHandshaking options:\n")); |
|
1614 _printf(_L("1. No handshaking\n")); |
|
1615 _printf(_L("2. Toggle Xon/Xoff\n")); |
|
1616 _printf(_L("3. Toggle obey CTS\n")); |
|
1617 _printf(_L("4. Toggle obey DSR / free RTS\n")); |
|
1618 _printf(_L("5. Toggle write buffered complete\n")); |
|
1619 |
|
1620 TInt key = (TInt) _getch(); |
|
1621 |
|
1622 switch (key) |
|
1623 { |
|
1624 case '1': |
|
1625 TheConfig.iHandshake = 0; |
|
1626 break; |
|
1627 case '2': |
|
1628 TheConfig.iHandshake ^= KConfigObeyXoff; |
|
1629 TheConfig.iHandshake ^= KConfigSendXoff; |
|
1630 break; |
|
1631 case '3': |
|
1632 TheConfig.iHandshake ^= KConfigObeyCTS; |
|
1633 break; |
|
1634 case '4': |
|
1635 TheConfig.iHandshake ^= KConfigObeyDSR; |
|
1636 TheConfig.iHandshake ^= KConfigFreeRTS; |
|
1637 break; |
|
1638 case '5': |
|
1639 TheConfig.iHandshake ^= KConfigWriteBufferedComplete; |
|
1640 break; |
|
1641 default: |
|
1642 break; |
|
1643 } |
|
1644 |
|
1645 LEAVEIFERROR(port.SetConfig(TheConfigBuf)); |
|
1646 |
|
1647 _printf(_L("Handshaking options now: 0x%X\n"), TheConfig.iHandshake); |
|
1648 |
|
1649 CleanupStack::PopAndDestroy(); |
|
1650 } |
|
1651 |
|
1652 void RestartUsbL() |
|
1653 /** |
|
1654 * This function stops and restarts usb manager. |
|
1655 */ |
|
1656 { |
|
1657 TheUsb.Stop(); |
|
1658 |
|
1659 TRequestStatus status; |
|
1660 TheUsb.Start(status); |
|
1661 User::WaitForRequest(status); |
|
1662 LEAVEIFERROR(status.Int()); |
|
1663 |
|
1664 _printf(_L("Restarted USB.\n")); |
|
1665 } |
|
1666 |
|
1667 void mainL() |
|
1668 /** |
|
1669 * This function controls test execution as directed by the user. |
|
1670 */ |
|
1671 { |
|
1672 char ch; |
|
1673 TInt menu = 1; |
|
1674 |
|
1675 TInt ret = User::LoadLogicalDevice(KUsbLddName); |
|
1676 if ((ret != KErrNone) && (ret != KErrAlreadyExists)) |
|
1677 LEAVE(ret); |
|
1678 |
|
1679 _printf(_L("Loaded USB LDD\n")); |
|
1680 |
|
1681 ret = StartC32(); |
|
1682 if ((ret != KErrNone) && (ret != KErrAlreadyExists)) |
|
1683 LEAVE(ret); |
|
1684 |
|
1685 _printf(_L("Started C32\n")); |
|
1686 |
|
1687 LEAVEIFERROR(TheUsb.Connect()); |
|
1688 |
|
1689 _printf(_L("Connected to USB Manager\n")); |
|
1690 |
|
1691 TRequestStatus status; |
|
1692 TheUsb.Start(status); |
|
1693 User::WaitForRequest(status); |
|
1694 LEAVEIFERROR(status.Int()); |
|
1695 |
|
1696 _printf(_L("Started USB\n")); |
|
1697 |
|
1698 |
|
1699 |
|
1700 LEAVEIFERROR(TheCommServ.Connect()); |
|
1701 |
|
1702 _printf(_L("Connected to C32\n")); |
|
1703 |
|
1704 RComm port; |
|
1705 |
|
1706 // The port's configuration seems to be junk at the beginning, so we set it to known values. |
|
1707 |
|
1708 TheConfig.iRate = EBps115200; |
|
1709 TheConfig.iDataBits = EData8; |
|
1710 TheConfig.iStopBits = EStop1; |
|
1711 TheConfig.iParity = EParityNone; |
|
1712 TheConfig.iHandshake = 0; |
|
1713 TheConfig.iTerminatorCount = 0; |
|
1714 |
|
1715 LEAVEIFERROR(port.Open(TheCommServ, KUsbPortName, ECommExclusive, ECommRoleDCE)); |
|
1716 CleanupClosePushL(port); |
|
1717 |
|
1718 port.SetConfig(TheConfigBuf); |
|
1719 _printf(_L("----------------------------------------\n")); |
|
1720 _printf(_L("Initial port config:\n")); |
|
1721 _printf(_L(" Rate: %d bps\n"), TheConfig.iRate); |
|
1722 _printf(_L(" Data bits: %d. Parity type: %d. Stop bits: %d\n"), |
|
1723 TheConfig.iStopBits, TheConfig.iParity, TheConfig.iStopBits); |
|
1724 _printf(_L(" Handshaking options: 0x%X\n"), TheConfig.iHandshake); |
|
1725 _printf(_L("----------------------------------------\n\n")); |
|
1726 |
|
1727 CleanupStack::PopAndDestroy(); // port |
|
1728 |
|
1729 TBool noExit = ETrue; |
|
1730 while (noExit) |
|
1731 { |
|
1732 switch(menu) |
|
1733 { |
|
1734 case 1: |
|
1735 _printf(_L("\nAvailable tests:\n\n")); |
|
1736 _printf(_L("1. ReadOneOrMore loopback test\n")); |
|
1737 _printf(_L("2. Read loopback test\n")); |
|
1738 _printf(_L("3. Set handshaking\n")); |
|
1739 _printf(_L("4. Restart USB\n")); |
|
1740 _printf(_L("5. Test specification menu\n")); |
|
1741 _printf(_L("6. Read with terminators loopback test\n")); |
|
1742 _printf(_L("7. Read loopback from ACM0->ACM1 test\n")); |
|
1743 _printf(_L("8. NotifyDataAvailable test\n")); |
|
1744 _printf(_L("\nSelection (x to exit): ")); |
|
1745 |
|
1746 ch = (char) _getch(); |
|
1747 _printf(_L("\n")); |
|
1748 switch (ch) |
|
1749 { |
|
1750 case '1': LoopbackTestL(); break; |
|
1751 case '2': ReadLoopbackTestL(); break; |
|
1752 case '3': SetHandshakingL(); break; |
|
1753 case '4': RestartUsbL(); break; |
|
1754 case '5': menu = 2; break; |
|
1755 case '6': ReadWithTerminatorsLoopbackTestL(); break; |
|
1756 case '7': ReadLoopbackFromPortAToPortBTestL(); break; |
|
1757 case '8': NotifyDataAvailableTestL(); break; |
|
1758 case 'x': |
|
1759 case 'X': noExit = EFalse; break; |
|
1760 default: _printf(_L("\nInvalid key\n")); break; |
|
1761 } |
|
1762 break; |
|
1763 case 2: |
|
1764 _printf(_L("\nAvailable tests:\n\n")); |
|
1765 _printf(_L("1. Data stress, size varies (test 2.1.1)\n")); |
|
1766 _printf(_L("2. Data stress, rate varies (test 2.1.2)\n")); |
|
1767 _printf(_L("3. Timeout (test 2.2)\n")); |
|
1768 _printf(_L("4. Cancel Transfer (test 2.3)\n")); |
|
1769 _printf(_L("5. Interrupt Transfer (test 2.4)\n")); |
|
1770 _printf(_L("6. Shutdown (test 2.5)\n")); |
|
1771 _printf(_L("7. Buffer overrun (test 2.6)\n")); |
|
1772 _printf(_L("8. Break (test 2.7)\n")); |
|
1773 _printf(_L("9. Event notification, signal change (test 2.8.1)\n")); |
|
1774 _printf(_L("a. Event notification, flow control (test 2.8.2)\n")); |
|
1775 _printf(_L("b. Event notification, config change (test 2.8.3)\n")); |
|
1776 _printf(_L("c. Second client (test 2.9)\n")); |
|
1777 /* _printf(_L("d. ACM request, encapsulated command (test 2.10.1)\n")); |
|
1778 _printf(_L("e. ACM request, break (test 2.10.2)\n")); |
|
1779 _printf(_L("f. ACM request, setting feature (test 2.10.3)\n")); |
|
1780 _printf(_L("g. ACM request, clearing feature (test 2.10.4)\n")); |
|
1781 _printf(_L("h. ACM request, setting line coding (test 2.10.5)\n")); |
|
1782 _printf(_L("i. ACM request, control line state (test 2.10.6)\n")); |
|
1783 _printf(_L("j. ACM request, encapsualted response (test 2.10.7)\n")); |
|
1784 _printf(_L("k. ACM request, comms feature (test 2.10.8)\n")); |
|
1785 _printf(_L("l. ACM request, getting line coding (test 2.10.9)\n")); |
|
1786 _printf(_L("m. ACM Notifications, send serial state (test 2.11.1)\n")); |
|
1787 _printf(_L("n. ACM Notifications, network status (test 2.11.2)\n")); |
|
1788 _printf(_L("o. ACM Notifications, response available (test 2.11.3)\n")); |
|
1789 */ _printf(_L("p. Loopback test (test 2.12)\n")); |
|
1790 _printf(_L("q. Main menu\n")); |
|
1791 |
|
1792 ch = (char) _getch(); |
|
1793 _printf(_L("\n")); |
|
1794 switch (ch) |
|
1795 { |
|
1796 case '1': DataStress_SizeVary_TestL(); break; |
|
1797 case '2': DataStress_RateVary_TestL(); break; |
|
1798 case '3': TimeOut_TestL(); break; |
|
1799 case '4': CancelTx_TestL(); break; |
|
1800 case '5': InterruptTx_TestL(); break; |
|
1801 case '6': Shutdown_TestL(); break; |
|
1802 case '7': BufferOverrun_TestL(); break; |
|
1803 case '8': Break_TestL(); break; |
|
1804 case '9': SignalChange_TestL(); break; |
|
1805 case 'A': |
|
1806 case 'a': FlowControl_TestL(); break; |
|
1807 case 'B': |
|
1808 case 'b': ConfigChange_TestL(); break; |
|
1809 case 'C': |
|
1810 case 'c': SecondClient_TestL(); break; |
|
1811 case 'D': |
|
1812 case 'd': ACMRq_EncapCommand_TestL(); break; |
|
1813 case 'E': |
|
1814 case 'e': ACMRq_Break_TestL(); break; |
|
1815 case 'F': |
|
1816 case 'f': ACMRq_SetFeature_TestL(); break; |
|
1817 case 'G': |
|
1818 case 'g': ACMRq_ClearFeature_TestL(); break; |
|
1819 case 'H': |
|
1820 case 'h': ACMRq_SetCoding_TestL(); break; |
|
1821 case 'I': |
|
1822 case 'i': ACMRq_CtrlState_TestL(); break; |
|
1823 case 'J': |
|
1824 case 'j': ACMRq_EncapResp_TestL(); break; |
|
1825 case 'K': |
|
1826 case 'k': ACMRq_CommsFeature_TestL(); break; |
|
1827 case 'L': |
|
1828 case 'l': ACMRq_GetCoding_TestL(); break; |
|
1829 case 'M': |
|
1830 case 'm': ACMNtf_SendState_TestL(); break; |
|
1831 case 'N': |
|
1832 case 'n': ACMNtf_Status_TestL(); break; |
|
1833 case 'O': |
|
1834 case 'o': ACMNtf_RespAvail_TestL(); break; |
|
1835 case 'P': |
|
1836 case 'p': AcmLoopback_TestL(); break; |
|
1837 case 'q': |
|
1838 case 'Q': menu = 1; break; |
|
1839 default: |
|
1840 _printf(_L("\nInvalid key\n")); |
|
1841 break; |
|
1842 } |
|
1843 break; |
|
1844 default: |
|
1845 LEAVE(-1); |
|
1846 } |
|
1847 } |
|
1848 TheCommServ.Close(); |
|
1849 TheUsb.Close(); |
|
1850 } |
|
1851 |
|
1852 void consoleMainL() |
|
1853 /** |
|
1854 * Create a console and run mainL(). |
|
1855 */ |
|
1856 { |
|
1857 console=Console::NewL(_L("T_ACM"),TSize(KConsFullScreen,KConsFullScreen)); |
|
1858 CleanupStack::PushL(console); |
|
1859 mainL(); |
|
1860 _printf(_L("[ press any key ]")); |
|
1861 _getch(); |
|
1862 CleanupStack::PopAndDestroy(); |
|
1863 } |
|
1864 |
|
1865 GLDEF_C TInt E32Main() |
|
1866 /** |
|
1867 * Runs the test as specified in the ACM unit test specification. |
|
1868 */ |
|
1869 { |
|
1870 __UHEAP_MARK; |
|
1871 CTrapCleanup* cleanupStack=CTrapCleanup::New(); |
|
1872 |
|
1873 // create the timer for use during some of the tests |
|
1874 timer.CreateLocal(); |
|
1875 |
|
1876 TRAP_IGNORE(consoleMainL()); |
|
1877 delete cleanupStack; |
|
1878 __UHEAP_MARKEND; |
|
1879 return 0; |
|
1880 } |