comparison packages/devs/serial/rs232/tx39/current/tests/tx39_serial_test.cxx @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 //=================================================================
2 //
3 // tx39_serial_test.cxx
4 //
5 // Test that the device API for the tx39 device exists.
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 // October 31, 1998.
23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved.
26 // -------------------------------------------
27 //
28 //####COPYRIGHTEND####
29 //=================================================================
30 //#####DESCRIPTIONBEGIN####
31 //
32 // Author(s): proven
33 // Contributors: proven
34 // Date: 1998-10-08
35 // Description: Tests basic serial functionality.
36 //####DESCRIPTIONEND####
37
38 // #include <pkgconf/devs.h>
39 #include <pkgconf/devices.h> // For now include all the devices
40
41 #include <cyg/infra/testcase.h> // Generic test macros
42
43 #ifdef CYG_DEVICE_SERIAL_RS232_TX39_NAME
44 #define CYG_DEVICE_SERIAL_RS232_NAME CYG_DEVICE_SERIAL_RS232_TX39_NAME
45
46 #define NTHREADS 1
47 #include <cyg/kernel/kernel.hxx> // All the kernel specific stuff
48 #include <cyg/devs/common/testaux.hxx>
49
50 // #define CYG_DEVICE_INTERNAL
51 // #include <cyg/devs/serial/rs232/tx39/serial_tx39.hxx>
52 // #include <cyg/devs/serial/rs232/common/tests/serial_.ht>
53
54 char message1[] = "This is test message 1.\n";
55 char message2[] = "This is test message 2.\n";
56
57 /* Only call routines that do not require user input */
58 void entry0(CYG_ADDRWORD data)
59 {
60 Cyg_IORB iorb1, iorb2;
61 cyg_int32 baud_rate, i;
62
63 iorb1.callback = NULL;
64 iorb1.buffer = message1;
65 iorb1.buffer_length = sizeof(message1) - 1;
66 CYG_DEVICE_SERIAL_RS232_NAME.io_write_asynchronous(&iorb1);
67
68 iorb2.buffer = message2;
69 iorb2.buffer_length = sizeof(message2) - 1;
70 CYG_DEVICE_SERIAL_RS232_NAME.io_write_blocking(&iorb2);
71
72 for (i = 0; i < 1000000; i++); // Delay to flush the tx buffer
73
74 if ((baud_rate = CYG_DEVICE_SERIAL_RS232_NAME.get_baud_rate()) >= 0) {
75 CYG_TEST_PASS_FAIL(
76 (CYG_DEVICE_SERIAL_RS232_NAME.set_baud_rate(baud_rate) >= 0),
77 "Setting baud rate to previous baud rate.");
78 } else {
79 CYG_TEST_FAIL("Could not get baud rate.");
80 }
81
82 CYG_TEST_PASS_EXIT("serial_test");
83 }
84
85 /* Make calls to the rest of the API */
86 void entry_bogus(CYG_ADDRWORD data)
87 {
88 Cyg_IORB iorb;
89 char buf[1024];
90 iorb.buffer = buf;
91 iorb.buffer_length = sizeof(buf);
92
93 // Set mode to interrupt
94 CYG_DEVICE_SERIAL_RS232_NAME.set_kmode((cyg_uint32)1);
95 // CYG_DEVICE_SERIAL_RS232_NAME.get_kmode(); // Doesn't exist yet
96
97 // These could go in the entry0 routine
98 CYG_DEVICE_SERIAL_RS232_NAME.get_line_mode();
99 CYG_DEVICE_SERIAL_RS232_NAME.set_line_mode(1);
100
101 CYG_DEVICE_SERIAL_RS232_NAME.get_baud_rate();
102 CYG_DEVICE_SERIAL_RS232_NAME.set_baud_rate(1);
103
104 CYG_DEVICE_SERIAL_RS232_NAME.set_read_mode(1);
105 // CYG_DEVICE_SERIAL_RS232_NAME.get_read_mode(); // Doesn't exist yet
106 // CYG_DEVICE_SERIAL_RS232_NAME.set_read_data(1, NULL, 0);
107 CYG_DEVICE_SERIAL_RS232_NAME.io_read_asynchronous(&iorb);
108 CYG_DEVICE_SERIAL_RS232_NAME.io_read_blocking(&iorb);
109 // CYG_DEVICE_SERIAL_RS232_NAME.io_read_cancel(&iorb);// Doesn't exist yet
110
111 CYG_DEVICE_SERIAL_RS232_NAME.set_write_mode(1);
112 // CYG_DEVICE_SERIAL_RS232_NAME.get_write_mode(); // Doesn't exist yet
113 CYG_DEVICE_SERIAL_RS232_NAME.io_write_asynchronous(&iorb);
114 CYG_DEVICE_SERIAL_RS232_NAME.io_write_blocking(&iorb);
115 // CYG_DEVICE_SERIAL_RS232_NAME.io_write_cancel(&iorb);// Doesn't exist yet
116 }
117
118 externC void
119 cyg_start(void)
120 {
121 CYG_TEST_INIT();
122
123 new_thread(entry0, 0);
124
125 Cyg_Scheduler::start();
126
127 CYG_TEST_FAIL_EXIT("Not reached");
128
129 entry_bogus(0); // To prevent selective linking from GC all the bogus calls.
130 }
131
132 #else // CYG_DEVICE_SERIAL_RS232_TX39_NAME
133
134 externC void
135 cyg_start(void)
136 {
137 CYG_TEST_INIT();
138 CYG_TEST_PASS_EXIT("N/A: required serial device not present");
139 }
140
141 #endif // CYG_DEVICE_SERIAL_RS232_TX39_NAME
142
143 // EOF tx39_serial_tests.cxx