Mercurial > ecos
annotate packages/io/serial/current/tests/tty2.c @ 32:5af43b635655 ecos-sw-1999-08-18
Merge from eCos master repository on 1999-08-18-15:20:01-BST
| author | jlarmour |
|---|---|
| date | Wed, 18 Aug 1999 15:33:44 +0000 |
| parents | 443894e2e912 |
| children | c38311975d4f |
| rev | line source |
|---|---|
| 2 | 1 //========================================================================== |
| 2 // | |
| 3 // tty2.c | |
| 4 // | |
| 5 // Test simple string output. | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 25 // by Cygnus are Copyright (C) 1998, 1999 Cygnus Solutions. | |
| 26 // All Rights Reserved. | |
| 27 // ------------------------------------------- | |
| 28 // | |
| 29 //####COPYRIGHTEND#### | |
| 30 //========================================================================== | |
| 31 //#####DESCRIPTIONBEGIN#### | |
| 32 // | |
| 33 // Author(s): jskov | |
| 34 // Contributors: jskov | |
| 35 // Date: 1999-03-17 | |
| 36 // Description: Test simple string output. | |
| 37 // | |
| 38 //####DESCRIPTIONEND#### | |
| 39 | |
| 40 #include <pkgconf/system.h> | |
| 41 | |
| 42 #include <cyg/infra/testcase.h> // test macros | |
| 43 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 44 | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
45 // Package requirements |
| 2 | 46 #if defined(CYGPKG_IO_SERIAL) && defined(CYGPKG_KERNEL) |
| 47 | |
| 48 #include <pkgconf/kernel.h> | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
49 |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
50 // Package option requirements |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
51 #if defined(CYGFUN_KERNEL_API_C) |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
52 |
| 2 | 53 #include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL |
| 54 #include <cyg/kernel/kapi.h> | |
| 55 unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; | |
| 56 cyg_thread thread_data; | |
| 57 cyg_handle_t thread_handle; | |
| 58 | |
| 59 #include "ser_test_protocol.inl" | |
| 60 | |
| 61 //--------------------------------------------------------------------------- | |
| 62 // TTY test main function. | |
| 63 void | |
| 64 tty_test( void ) | |
| 65 { | |
| 66 char test_msg1[]="This is a test message!\n"; | |
| 67 char test_msg2[]="$O5468697320697320612074657374206d657373616765210d0a#12"; | |
| 68 int msglen; | |
| 69 cyg_io_handle_t tty_handle; | |
| 70 | |
| 71 test_open_tty(&tty_handle); | |
| 72 | |
| 73 CYG_TEST_INFO("Writing a raw string to the TTY device..."); | |
| 74 msglen = strlen(&test_msg1[0]); | |
| 75 Tcyg_io_write(tty_handle, &test_msg1[0], &msglen); | |
| 76 | |
| 77 CYG_TEST_INFO("Writing a GDB encoded string to the TTY device..."); | |
| 78 msglen = strlen(&test_msg2[0]); | |
| 79 Tcyg_io_write(tty_handle, &test_msg2[0], &msglen); | |
| 80 | |
| 81 CYG_TEST_PASS_FINISH("tty2 test OK"); | |
| 82 } | |
| 83 | |
| 84 void | |
| 85 cyg_start(void) | |
| 86 { | |
| 87 CYG_TEST_INIT(); | |
| 88 cyg_thread_create(10, // Priority - just a number | |
| 89 (cyg_thread_entry_t*)tty_test, // entry | |
| 90 0, // | |
| 91 "tty_thread", // Name | |
| 92 &stack[0], // Stack | |
| 93 CYGNUM_HAL_STACK_SIZE_TYPICAL, // Size | |
| 94 &thread_handle, // Handle | |
| 95 &thread_data // Thread data structure | |
| 96 ); | |
| 97 cyg_thread_resume(thread_handle); | |
| 98 cyg_scheduler_start(); | |
| 99 } | |
| 100 | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
101 |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
102 #else // CYGFUN_KERNEL_API_C |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
103 #define N_A_MSG "Needs kernel C API" |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
104 #endif |
| 2 | 105 |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
106 #else // CYGPKG_IO_SERIAL && CYGPKG_KERNEL |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
107 #define N_A_MSG "Needs IO/serial and Kernel" |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
108 #endif |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
109 |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
110 #ifdef N_A_MSG |
| 2 | 111 void |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
112 cyg_start( void ) |
| 2 | 113 { |
| 114 CYG_TEST_INIT(); | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
115 CYG_TEST_NA( N_A_MSG); |
| 2 | 116 } |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
117 #endif // N_A_MSG |
| 2 | 118 // EOF tty2.c |
