home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / programm / 4619 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.4 KB  |  54 lines

  1. Xref: sparky comp.unix.programmer:4619 comp.unix.internals:1790 comp.unix.questions:10929
  2. Path: sparky!uunet!jahangir!wayne
  3. From: wayne@jahangir.UUCP (wayne)
  4. Newsgroups: comp.unix.programmer,comp.unix.internals,comp.unix.questions
  5. Subject: termio novice question
  6. Keywords: termio
  7. Message-ID: <773@jahangir.UUCP>
  8. Date: 10 Sep 92 21:53:35 GMT
  9. Followup-To: poster
  10. Organization: MDC, NYC
  11. Lines: 41
  12.  
  13.  
  14.  
  15.  
  16.  
  17.      I wonder if anybody out there can help a novice with
  18. a termio question.  I am using a sun sparc/2 with SunOS 4.1.2
  19.  
  20.      I want to read a serial line into the serial port on  the back 
  21. of my sun. I want to run the line at 19200, 8 bits, 1 stop bit and no parity.
  22.  
  23.      Everything seems to work fine except when I try to change 
  24. c_cflag. Then it stops to work. 
  25.  
  26.      Could anybody please tell me what is wrong with the code fragement
  27. below?
  28.  
  29.  
  30.      - Wayne  wayne@mktdata.com
  31.  
  32. int fd;
  33. struct termios termios;
  34.  
  35.  
  36.   if ( ( fd = open( device, O_RDWR ) ) < 0 )
  37.     return -1;
  38.  
  39.  
  40.   if ( ioctl( fd, TCGETS, &termios ) < 0 )
  41.     return -1;
  42.  
  43. termios.c_iflag &= ~( INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT );
  44. termios.c_oflag &= ~OPOST;
  45. termios.c_lflag &= ~( ICANON | ISIG | ECHO );
  46. termios.c_cflag = ( B19200 | CS8 );             /* This doesnt seem to work.  */
  47. termios.c_cc[4] = KN_MIN;
  48. termios.c_cc[5] = KN_TIME;
  49.  
  50.   if ( ioctl( fd, TCSETS, &termios ) < 0 )
  51.     return -1;
  52.  
  53. return fd;
  54.