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

4.104.114.84.95
Last change on this file since d8ff793 was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

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