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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [m68k/] [mvme162/] [consolex/] [cTest.c] - Blame information for rev 30

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

Line No. Rev Author Line
1 30 unneback
/*
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: cTest.c,v 1.2 2001-09-27 12:00:18 chris Exp $
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
 
35
rtems_driver_address_table Device_drivers[] = {
36
    CONSOLEX_DRIVER_TABLE_ENTRY
37
};
38
 
39
rtems_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>

powered by: WebSVN 2.1.0

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