source: rtems/c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c @ e4c07444

4.104.114.84.95
Last change on this file since e4c07444 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 17, 1999 at 5:51:34 PM

Updated copyright notice.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  Test program for consolex.
3 *
4 *  NOTE:  This program must be put together as an executable. :)
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems.h>
17#include <rtems/libio.h>
18#include <consolex.h>
19
20#include <stdio.h>
21#include <unistd.h>
22#include <sys/types.h>
23#include <sys/stat.h>
24#include <fcntl.h>
25#include <termios.h>
26
27#if ! defined(O_NDELAY)
28# if defined(solaris2)
29#  define O_NDELAY O_NONBLOCK
30# elif defined(RTEMS_NEWLIB)
31#  define O_NDELAY _FNBIO
32# endif
33#endif
34
35rtems_driver_address_table Device_drivers[] = {
36    CONSOLEX_DRIVER_TABLE_ENTRY
37};
38
39rtems_task      Init(rtems_task_argument arg)
40{
41    char        buf[128];
42    int         fd;
43    struct termios      t;
44
45    printf("Console test.\n");
46   
47    if((fd = open("/dev/tty00",O_RDWR)) < 0){
48        printf("Can't open device.\n");
49        return;
50    }
51    tcgetattr(fd,&t);
52    t.c_cflag = B9600|CS8;
53    tcsetattr(fd,TCSANOW,&t);
54    printf("iflag=%07o, oflag=%07o, cflag=%07o, lflag=%07o\n",
55           t.c_iflag,t.c_oflag,t.c_cflag,t.c_lflag);
56
57    do{
58        write(fd,"Your name? ",11);
59        read(fd,buf,sizeof(buf));
60        write(fd,"Hi ",3);
61        write(fd,buf,strlen(buf));
62    }while(*buf != '!');
63   
64    close(fd);
65   
66    printf("Done.\n");
67
68    exit(0);
69}
70
71#define CONFIGURE_INIT
72#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
73#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
74#include <confdefs.h>
Note: See TracBrowser for help on using the repository browser.