home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:4619 comp.unix.internals:1790 comp.unix.questions:10929
- Path: sparky!uunet!jahangir!wayne
- From: wayne@jahangir.UUCP (wayne)
- Newsgroups: comp.unix.programmer,comp.unix.internals,comp.unix.questions
- Subject: termio novice question
- Keywords: termio
- Message-ID: <773@jahangir.UUCP>
- Date: 10 Sep 92 21:53:35 GMT
- Followup-To: poster
- Organization: MDC, NYC
- Lines: 41
-
-
-
-
-
- I wonder if anybody out there can help a novice with
- a termio question. I am using a sun sparc/2 with SunOS 4.1.2
-
- I want to read a serial line into the serial port on the back
- of my sun. I want to run the line at 19200, 8 bits, 1 stop bit and no parity.
-
- Everything seems to work fine except when I try to change
- c_cflag. Then it stops to work.
-
- Could anybody please tell me what is wrong with the code fragement
- below?
-
-
- - Wayne wayne@mktdata.com
-
- int fd;
- struct termios termios;
-
-
- if ( ( fd = open( device, O_RDWR ) ) < 0 )
- return -1;
-
-
- if ( ioctl( fd, TCGETS, &termios ) < 0 )
- return -1;
-
- termios.c_iflag &= ~( INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT );
- termios.c_oflag &= ~OPOST;
- termios.c_lflag &= ~( ICANON | ISIG | ECHO );
- termios.c_cflag = ( B19200 | CS8 ); /* This doesnt seem to work. */
- termios.c_cc[4] = KN_MIN;
- termios.c_cc[5] = KN_TIME;
-
- if ( ioctl( fd, TCSETS, &termios ) < 0 )
- return -1;
-
- return fd;
-