diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1997-08-01 18:12:11 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1997-08-01 18:12:11 +0000 |
commit | 9deb5b8b2822eb49c7a31d35d37d9b59dcd6555c (patch) | |
tree | 2797615f5f5eab05772d2bb807ba95e0d632481b /c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c | |
parent | Merged very large and much appreciated patch from Chris Johns (diff) | |
download | rtems-9deb5b8b2822eb49c7a31d35d37d9b59dcd6555c.tar.bz2 |
Katsutoshi Shibuya (shibuya@mxb.meshnet.or.jp)of BU-Denken Co., Ltd.
(Sapporo, Japan) submitted the extended console driver for the
MVME162LX BSP and the POSIX tcsetattr() and tcgetattr() routines.
This device driver supports four serial ports, cooked IO, and
provides a portable base for Zilog 8530 based console drivers.
Diffstat (limited to 'c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c')
-rw-r--r-- | c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c b/c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c new file mode 100644 index 0000000000..899703892d --- /dev/null +++ b/c/src/lib/libbsp/m68k/mvme162/consolex/cTest.c @@ -0,0 +1,75 @@ +/* + * Test program for consolex. + * + * NOTE: This program must be put together as an executable. :) + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may 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> |