Mercurial > ecos
annotate packages/io/serial/current/tests/serial3.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 // serial3.c | |
| 4 // | |
| 5 // Test data half-duplex receive and send. | |
| 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 half-duplex receive and send capabilities of | |
| 37 // the serial driver. | |
| 38 // Requirements: This test requires the ser_filter on the host side. | |
| 39 // | |
| 40 //####DESCRIPTIONEND#### | |
| 41 | |
| 42 #include <pkgconf/system.h> | |
| 43 | |
| 44 #include <cyg/infra/testcase.h> // test macros | |
| 45 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 46 | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
47 // Package requirements |
| 2 | 48 #if defined(CYGPKG_IO_SERIAL) && defined(CYGPKG_KERNEL) |
| 49 | |
| 50 #include <pkgconf/kernel.h> | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
51 |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
52 // Package option requirements |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
53 #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
|
54 |
| 2 | 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 | |
| 61 #include "ser_test_protocol.inl" | |
| 62 | |
| 63 //--------------------------------------------------------------------------- | |
| 64 // Serial test main function. | |
| 65 void | |
| 66 serial_test( void ) | |
| 67 { | |
| 68 cyg_io_handle_t ser_handle; | |
| 69 | |
| 70 test_open_ser(&ser_handle); | |
| 71 | |
| 72 // We need the filter for this test. | |
| 73 test_ping(ser_handle); | |
| 74 | |
| 75 #if defined(CYGPKG_HAL_ARM_AEB) | |
| 76 { | |
| 77 // The AEB board is too slow to run the driver in interrupt mode | |
| 78 // at the default 38400 baud when doing this test. | |
| 79 cyg_ser_cfg_t arm_aeb_cfg = { | |
| 80 CYGNUM_SERIAL_BAUD_14400, CYGNUM_SERIAL_WORD_LENGTH_8, | |
| 81 CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }; | |
| 82 | |
| 83 change_config(ser_handle, &arm_aeb_cfg); | |
| 84 } | |
| 85 #endif | |
| 86 | |
| 87 // Start slowly, the go for max size. | |
| 88 { | |
| 89 test_binary(ser_handle, 16, MODE_EOP_ECHO); | |
| 90 test_binary(ser_handle, 128, MODE_EOP_ECHO); | |
| 91 test_binary(ser_handle, 256, MODE_EOP_ECHO); | |
| 92 test_binary(ser_handle, IN_BUFFER_SIZE, MODE_EOP_ECHO); | |
| 93 } | |
| 94 | |
| 95 // Write some varying length packets. | |
| 96 { | |
| 97 int i; | |
| 98 for(i = 0; i < 8; i++) { | |
| 99 // No echo. | |
| 100 test_binary(ser_handle, 256 + 42*i, MODE_NO_ECHO); | |
| 101 test_binary(ser_handle, 64 + 7*i, MODE_NO_ECHO); | |
| 102 // Echo. | |
| 103 test_binary(ser_handle, 256 + 42*i, MODE_EOP_ECHO); | |
| 104 test_binary(ser_handle, 64 + 7*i, MODE_EOP_ECHO); | |
| 105 } | |
| 106 } | |
| 107 | |
| 108 #if 0 // Disable this for now. | |
| 109 // End with some long packets. | |
| 110 { | |
| 111 test_binary(ser_handle, 2048, MODE_NO_ECHO); | |
| 112 test_binary(ser_handle, 16384, MODE_NO_ECHO); | |
| 113 test_binary(ser_handle, 65536, MODE_NO_ECHO); | |
| 114 } | |
| 115 #endif | |
| 116 | |
| 117 CYG_TEST_PASS_FINISH("serial3 test OK"); | |
| 118 } | |
| 119 | |
| 120 void | |
| 121 cyg_start(void) | |
| 122 { | |
| 123 CYG_TEST_INIT(); | |
| 124 cyg_thread_create(10, // Priority - just a number | |
| 125 (cyg_thread_entry_t*)serial_test, // entry | |
| 126 0, // | |
| 127 "serial_thread", // Name | |
| 128 &stack[0], // Stack | |
| 129 CYGNUM_HAL_STACK_SIZE_TYPICAL, // Size | |
| 130 &thread_handle, // Handle | |
| 131 &thread_data // Thread data structure | |
| 132 ); | |
| 133 cyg_thread_resume(thread_handle); | |
| 134 cyg_scheduler_start(); | |
| 135 } | |
| 136 | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
137 #else // CYGFUN_KERNEL_API_C |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
138 #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
|
139 #endif |
| 2 | 140 |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
141 #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
|
142 #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
|
143 #endif |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
144 |
|
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
145 #ifdef N_A_MSG |
| 2 | 146 void |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
147 cyg_start( void ) |
| 2 | 148 { |
| 149 CYG_TEST_INIT(); | |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
150 CYG_TEST_NA( N_A_MSG); |
| 2 | 151 } |
|
32
5af43b635655
Merge from eCos master repository on 1999-08-18-15:20:01-BST
jlarmour
parents:
2
diff
changeset
|
152 #endif // N_A_MSG |
| 2 | 153 // EOF serial3.c |
