OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [ppp/] [current/] [tests/] [ppp_test_support.inl] - Blame information for rev 811

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      tests/ppp_test_support.c
4
//
5
//      PPP testing support routines
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 2003 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later
16
// version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
//
27
// As a special exception, if other files instantiate templates or use
28
// macros or inline functions from this file, or you compile this file
29
// and link it with other works to produce a work based on this file,
30
// this file does not by itself cause the resulting work to be covered by
31
// the GNU General Public License. However the source code for this file
32
// must still be made available in accordance with section (3) of the GNU
33
// General Public License v2.
34
//
35
// This exception does not invalidate any other reasons why a work based
36
// on this file might be covered by the GNU General Public License.
37
// -------------------------------------------
38
// ####ECOSGPLCOPYRIGHTEND####
39
// ####BSDALTCOPYRIGHTBEGIN####
40
// -------------------------------------------
41
// Portions of this software may have been derived from FreeBSD, OpenBSD,
42
// or other sources, and if so are covered by the appropriate copyright
43
// and license included herein.
44
// -------------------------------------------
45
// ####BSDALTCOPYRIGHTEND####
46
//==========================================================================
47
//#####DESCRIPTIONBEGIN####
48
//
49
// Author(s):    nickg
50
// Contributors: nickg
51
// Date:         2003-07-01
52
// Purpose:
53
// Description:  This file contains routines that are used by the PPP tests.
54
//
55
//####DESCRIPTIONEND####
56
//
57
//==========================================================================
58
 
59
// PPP test support
60
 
61
#include 
62
 
63
#include 
64
#include 
65
#include 
66
 
67
#include 
68
 
69
#include 
70
#include 
71
 
72
#include 
73
 
74
#include 
75
 
76
//==========================================================================
77
 
78
static cyg_serial_baud_rate_t ppp_test_set_baud( cyg_serial_baud_rate_t baud )
79
{
80
#ifdef CYGPKG_PPP_TESTS_AUTOMATE
81
    cyg_io_handle_t     handle;
82
    cyg_serial_info_t   cfg;
83
    int                 err;
84
    int                 len = sizeof(cfg);
85
    char                buf[30];
86
    int                 blen;
87
    cyg_serial_baud_rate_t old_baud;
88
 
89
 
90
    CYG_TEST_INFO( "Switching baud rate" );
91
 
92
    err = cyg_io_lookup( CYGPKG_PPP_TEST_DEVICE, &handle );
93
 
94
    if( err != 0 ) {
95
        CYG_TEST_INFO("cyg_io_lookup: failed");
96
    }
97
 
98
    sprintf( buf, "BAUD:%03d\r\n", baud );
99
    blen = strlen(buf);
100
 
101
    err = cyg_io_write( handle, buf, &blen );
102
 
103
    if( err != 0 ) {
104
        CYG_TEST_INFO("cyg_io_write: failed");
105
    }
106
 
107
    // Wait for those characters to reach the remote end
108
    cyg_thread_delay(200);
109
 
110
    err = cyg_io_get_config( handle,
111
                             CYG_IO_GET_CONFIG_SERIAL_INFO,
112
                             &cfg,
113
                             &len);
114
 
115
    if( err != 0 ) {
116
        CYG_TEST_INFO("cyg_io_get_config: failed");
117
    }
118
 
119
    cfg.flags |= CYGNUM_SERIAL_FLOW_RTSCTS_RX|CYGNUM_SERIAL_FLOW_RTSCTS_TX;
120
 
121
    old_baud = cfg.baud;
122
    cfg.baud = baud;
123
 
124
    err = cyg_io_set_config( handle,
125
                             CYG_IO_SET_CONFIG_SERIAL_INFO,
126
                             &cfg,
127
                             &len);
128
 
129
    if( err != 0 ) {
130
        CYG_TEST_INFO("cyg_io_set_config failed");
131
    }
132
 
133
    // Wait for other end to switch...
134
    cyg_thread_delay(100);
135
 
136
    CYG_TEST_INFO( "Baud rate switched" );
137
 
138
    return old_baud;
139
 
140
#else
141
    return 0;
142
#endif
143
 
144
 
145
}
146
 
147
//==========================================================================
148
 
149
static void ppp_test_announce( char *buf )
150
{
151
#ifdef CYGPKG_PPP_TESTS_AUTOMATE
152
    cyg_io_handle_t     handle;
153
    int                 err;
154
    int                 blen;
155
 
156
//    cyg_thread_delay(200);
157
 
158
    CYG_TEST_INFO( "Sending announce string" );
159
 
160
    err = cyg_io_lookup( CYGPKG_PPP_TEST_DEVICE, &handle );
161
 
162
    if( err != 0 ) {
163
        CYG_TEST_INFO("cyg_io_lookup: failed");
164
    }
165
 
166
    blen = strlen(buf);
167
 
168
    err = cyg_io_write( handle, buf, &blen );
169
 
170
    if( err != 0 ) {
171
        CYG_TEST_INFO("cyg_io_write: failed");
172
    }
173
 
174
    blen = 2;
175
    err = cyg_io_write( handle, "\r\n", &blen );
176
 
177
    if( err != 0 ) {
178
        CYG_TEST_INFO("cyg_io_write: failed");
179
    }
180
 
181
    cyg_thread_delay(200);
182
 
183
    CYG_TEST_INFO( "Announce string sent" );
184
#endif
185
}
186
 
187
//==========================================================================
188
 
189
static void ppp_test_finish(void)
190
{
191
#ifdef CYGPKG_PPP_TESTS_AUTOMATE
192
    cyg_io_handle_t     handle;
193
    int                 err;
194
    char                *buf = "FINISH\r\n";
195
    int                 blen;
196
 
197
//    cyg_thread_delay(200);
198
 
199
    CYG_TEST_INFO( "Sending FINISH" );
200
 
201
    err = cyg_io_lookup( CYGPKG_PPP_TEST_DEVICE, &handle );
202
 
203
    if( err != 0 ) {
204
        CYG_TEST_INFO("cyg_io_lookup: failed");
205
    }
206
 
207
    blen = strlen(buf);
208
 
209
    err = cyg_io_write( handle, buf, &blen );
210
 
211
    if( err != 0 ) {
212
        CYG_TEST_INFO("cyg_io_write: failed");
213
    }
214
 
215
    cyg_thread_delay(200);
216
 
217
    CYG_TEST_INFO( "FINISH sent" );
218
#endif
219
}
220
 
221
//==========================================================================

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.