*** makefile.orig Fri May 28 03:41:27 1999 --- makefile Fri May 28 03:42:10 1999 *************** *** 2,10 **** OPT1 = -O -Wall # NetBSD/mac68k ! OPT2 = -DNETBSD # FreeBSD #OPT2 = -DFREEBSD # Linux (not supported) ! #OPT2 = -DLINUX # Others (modify this) #OPT2 = -DSPEED=2400 -DPORT_NAME=\"/dev/tty00\" --- 2,10 ---- OPT1 = -O -Wall # NetBSD/mac68k ! # OPT2 = -DNETBSD # FreeBSD #OPT2 = -DFREEBSD # Linux (not supported) ! OPT2 = -DLINUX # Others (modify this) #OPT2 = -DSPEED=2400 -DPORT_NAME=\"/dev/tty00\" *** tty.c.orig Fri May 28 03:41:33 1999 --- tty.c Fri May 28 06:36:26 1999 *************** *** 4,9 **** --- 4,13 ---- #include #include + #ifndef LINUX #include #include + #else + #include + #endif #include *************** *** 12,15 **** --- 16,23 ---- #endif + #ifdef LINUX + #define SPEED_PARAMS 16 + #endif + #ifndef PORT_NAME # if defined NETBSD *************** *** 17,20 **** --- 25,30 ---- # elif defined FREEBSD # define PORT_NAME "/dev/cuaa0" + # elif defined LINUX + # define PORT_NAME "/dev/cua0" # endif #endif *************** *** 24,33 **** struct termios tbuf; int init_tty() { ! if((fd = open(PORT_NAME, O_RDWR /* | O_NONBLOCK */, 0)) == -1){ return !0; } /* else { */ ! if(ioctl(fd, TIOCGETA, &org_tbuf) == -1){ fprintf(stderr, "ioctl error! (in stage to get original value)\n"); --- 34,50 ---- struct termios tbuf; + void deinit_tty(); + int init_tty() { ! int i; ! int speed_param[SPEED_PARAMS] = { 0, 50, 75, 110, 134, ! 150, 200, 300, 600, 1200, ! 1800, 2400, 4800, 9600, 19200, 38400}; ! ! if((fd = open(PORT_NAME, O_RDWR | O_NONBLOCK , 0)) == -1){ return !0; } /* else { */ ! if(tcgetattr(fd, &org_tbuf) == -1){ fprintf(stderr, "ioctl error! (in stage to get original value)\n"); *************** *** 35,42 **** } ! tbuf = org_tbuf; - cfsetispeed(&tbuf, SPEED); - cfsetospeed(&tbuf, SPEED); tbuf.c_lflag &= ~ICANON & ~ECHO & ~ISIG & ~IEXTEN & ~TOSTOP; tbuf.c_cflag &= ~CSIZE & ~PARENB & ~CSTOPB; --- 52,73 ---- } ! memmove(&tbuf, &org_tbuf, sizeof(struct termios)); ! ! i = 0; ! while(1){ ! if(i == SPEED_PARAMS){ ! deinit_tty(); ! printf("Invalid value of parameter SPEED: %d", SPEED); ! exit(-1); ! } ! ! if(SPEED == speed_param[i]){ ! cfsetispeed(&tbuf, i); ! cfsetospeed(&tbuf, i); ! break; ! } ! i++; ! } tbuf.c_lflag &= ~ICANON & ~ECHO & ~ISIG & ~IEXTEN & ~TOSTOP; tbuf.c_cflag &= ~CSIZE & ~PARENB & ~CSTOPB; *************** *** 45,49 **** tbuf.c_oflag &= ~OPOST; ! if(ioctl(fd, TIOCSETA, &tbuf) == -1){ fprintf(stderr, "ioctl error! (in stage to set tty value)\n"); --- 76,80 ---- tbuf.c_oflag &= ~OPOST; ! if(tcsetattr(fd, TCSANOW, &tbuf) == -1){ fprintf(stderr, "ioctl error! (in stage to set tty value)\n"); *************** *** 57,61 **** { if(fd != -1) { ! if(ioctl(fd, TIOCSETA, &org_tbuf) == -1){ fprintf(stderr, "ioctl error! (in stage to restore original value)\n"); --- 88,92 ---- { if(fd != -1) { ! if(tcsetattr(fd, TCSANOW, &org_tbuf) == -1){ fprintf(stderr, "ioctl error! (in stage to restore original value)\n"); *************** *** 69,74 **** { unsigned char buf; ! ! read(fd, &buf, 1); return (unsigned char)buf; --- 100,105 ---- { unsigned char buf; ! ! while(read(fd, &buf, 1) == -1); return (unsigned char)buf; *************** *** 79,83 **** int retval; ! retval = write(fd, &data, 1); return retval; --- 110,114 ---- int retval; ! while((retval = write(fd, &data, 1)) == -1); return retval;