comparison packages/io/serial/current/tests/serial4.c @ 2:443894e2e912 ecos-v1_2_1-release

Block commit of eCos version 1.2.1
author jlarmour
date Tue, 11 May 1999 12:24:34 +0000
parents
children 1d7f19c9e4d1
comparison
equal deleted inserted replaced
1:72f549f0d891 2:443894e2e912
1 //==========================================================================
2 //
3 // serial4.c
4 //
5 // Test serial configuration changing
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 the configuration capabilities of the serial driver.
37 // Requirements: This test requires the ser_filter on the host side.
38 //
39 // To Do:
40 // This test should do a full test of the configuration combinations.
41 // This will get possible with proper test_change_config protocol
42 // implementation.
43 //####DESCRIPTIONEND####
44
45 #include <pkgconf/system.h>
46
47 #include <cyg/infra/testcase.h> // test macros
48 #include <cyg/infra/cyg_ass.h> // assertion macros
49
50 #if defined(CYGPKG_IO_SERIAL) && defined(CYGPKG_KERNEL)
51
52 #ifdef CYGPKG_KERNEL
53 #include <pkgconf/kernel.h>
54 #ifdef CYGFUN_KERNEL_API_C
55 #include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL
56 #include <cyg/kernel/kapi.h>
57 unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
58 cyg_thread thread_data;
59 cyg_handle_t thread_handle;
60 #endif
61 #endif
62
63 #include "ser_test_protocol.inl"
64
65 //---------------------------------------------------------------------------
66 // Serial test main function.
67 void
68 serial_test( void )
69 {
70 cyg_io_handle_t ser_handle;
71
72 test_open_ser(&ser_handle);
73
74 // We need the filter for this test.
75 test_ping(ser_handle);
76
77 // Test multiple configurations (defined in the protocol file).
78 // FIXME: This will get replaced with a test over the full configuration
79 // permutation space.
80 {
81 int i;
82 int count = sizeof(test_configs) / sizeof(cyg_ser_cfg_t);
83 char msg[] = "This is a test\n";
84 int msglen = strlen(msg);
85
86 for (i = 0; i < count; i++){
87 change_config(ser_handle, &test_configs[i]);
88 test_binary(ser_handle, 128, MODE_EOP_ECHO);
89 test_binary(ser_handle, 256, MODE_NO_ECHO);
90 Tcyg_io_write(ser_handle, msg, &msglen);
91 }
92 }
93
94 CYG_TEST_PASS_FINISH("serial4 test OK");
95 }
96
97 void
98 cyg_start(void)
99 {
100 CYG_TEST_INIT();
101 #ifdef CYGFUN_KERNEL_API_C
102 cyg_thread_create(10, // Priority - just a number
103 (cyg_thread_entry_t*)serial_test, // entry
104 0, //
105 "serial_thread", // Name
106 &stack[0], // Stack
107 CYGNUM_HAL_STACK_SIZE_TYPICAL, // Size
108 &thread_handle, // Handle
109 &thread_data // Thread data structure
110 );
111 cyg_thread_resume(thread_handle);
112 cyg_scheduler_start();
113 #else
114 serial_test();
115 #endif
116 }
117
118 #else // ifdef CYGPKG_IO_SERIAL
119
120 void
121 cyg_start(void)
122 {
123 CYG_TEST_INIT();
124 CYG_TEST_NA("Requires serial device driver and kernel");
125 }
126
127 #endif
128 // EOF serial4.c