summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c
blob: ac02a4d83b8c7a9fcbfddcf6db4b8303fa59effe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 *  Test program for consolex.
 *
 *  NOTE:  This program must be put together as an executable. :)
 *
 *  COPYRIGHT (c) 1989-1999.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$ 
 */

#include <rtems.h>
#include <rtems/libio.h>
#include <consolex.h>

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>

#if ! defined(O_NDELAY)
# if defined(solaris2)
#  define O_NDELAY O_NONBLOCK
# elif defined(RTEMS_NEWLIB)
#  define O_NDELAY _FNBIO
# endif
#endif

rtems_driver_address_table Device_drivers[] = {
    CONSOLEX_DRIVER_TABLE_ENTRY
};

rtems_task	Init(rtems_task_argument arg)
{
    char	buf[128];
    int		fd;
    struct termios	t;

    printf("Console test.\n");
    
    if((fd = open("/dev/tty00",O_RDWR)) < 0){
	printf("Can't open device.\n");
	return;
    }
    tcgetattr(fd,&t);
    t.c_cflag = B9600|CS8;
    tcsetattr(fd,TCSANOW,&t);
    printf("iflag=%07o, oflag=%07o, cflag=%07o, lflag=%07o\n",
	   t.c_iflag,t.c_oflag,t.c_cflag,t.c_lflag);

    do{
	write(fd,"Your name? ",11);
	read(fd,buf,sizeof(buf));
	write(fd,"Hi ",3);
	write(fd,buf,strlen(buf));
    }while(*buf != '!');
    
    close(fd);
    
    printf("Done.\n");

    exit(0);
}

#define	CONFIGURE_INIT
#define	CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define	CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
#include <confdefs.h>