|
2
|
1 //========================================================================== |
|
|
2 // |
|
|
3 // serial2.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 |
|
|
45 #if defined(CYGPKG_IO_SERIAL) && defined(CYGPKG_KERNEL) |
|
|
46 |
|
|
47 #ifdef CYGPKG_KERNEL |
|
|
48 #include <pkgconf/kernel.h> |
|
|
49 #ifdef CYGFUN_KERNEL_API_C |
|
|
50 #include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL |
|
|
51 #include <cyg/kernel/kapi.h> |
|
|
52 unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; |
|
|
53 cyg_thread thread_data; |
|
|
54 cyg_handle_t thread_handle; |
|
|
55 #endif |
|
|
56 #endif |
|
|
57 |
|
|
58 #include "ser_test_protocol.inl" |
|
|
59 |
|
|
60 //--------------------------------------------------------------------------- |
|
|
61 // Serial test main function. |
|
|
62 void |
|
|
63 serial_test( void ) |
|
|
64 { |
|
|
65 char test_msg1[]="This is a test message!\n"; |
|
|
66 char test_msg2[]="$O5468697320697320612074657374206d657373616765210d0a#12"; |
|
|
67 int msglen; |
|
|
68 cyg_io_handle_t ser_handle; |
|
|
69 |
|
|
70 test_open_ser(&ser_handle); |
|
|
71 |
|
|
72 CYG_TEST_INFO("Writing a raw string to the serial device..."); |
|
|
73 msglen = strlen(&test_msg1[0]); |
|
|
74 Tcyg_io_write(ser_handle, &test_msg1[0], &msglen); |
|
|
75 |
|
|
76 CYG_TEST_INFO("Writing a GDB encoded string to the serial device..."); |
|
|
77 msglen = strlen(&test_msg2[0]); |
|
|
78 Tcyg_io_write(ser_handle, &test_msg2[0], &msglen); |
|
|
79 |
|
|
80 CYG_TEST_PASS_FINISH("serial2 test OK"); |
|
|
81 } |
|
|
82 |
|
|
83 void |
|
|
84 cyg_start(void) |
|
|
85 { |
|
|
86 CYG_TEST_INIT(); |
|
|
87 #ifdef CYGFUN_KERNEL_API_C |
|
|
88 cyg_thread_create(10, // Priority - just a number |
|
|
89 (cyg_thread_entry_t*)serial_test, // entry |
|
|
90 0, // |
|
|
91 "serial_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 #else |
|
|
100 serial_test(); |
|
|
101 #endif |
|
|
102 } |
|
|
103 |
|
|
104 #else // ifdef CYGPKG_IO_SERIAL |
|
|
105 |
|
|
106 void |
|
|
107 cyg_start(void) |
|
|
108 { |
|
|
109 CYG_TEST_INIT(); |
|
|
110 CYG_TEST_NA("Requires serial device driver and kernel"); |
|
|
111 } |
|
|
112 |
|
|
113 #endif |
|
|
114 // EOF serial2.c |