home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!dog.ee.lbl.gov!news!nosc!usenet
- From: geurin@texasex.nosc.mil
- Subject: Please Help with buffered serial I/O in SunOS
- Message-ID: <1992Sep16.013718.1525@nosc.mil>
- Sender: usenet@nosc.mil (Network News)
- Organization: Naval Ocean Systems Center, San Diego, CA
- Date: Wed, 16 Sep 1992 01:37:18 GMT
- Lines: 49
-
-
- Howdy-
-
- I have a problem getting a read() to /dev/ttya (or ttyb) to return
- when there aren't any characters to be read. I did set the O_NDELAY
- flag when opening the device:
-
-
- if ((sp_id = open(com,O_RDWR|O_NDELAY)) == -1)
- return(0);
-
- ioctl(sp_id,TIOCFLUSH,0);
- ioctl(sp_id,TIOCEXCL,0);
- ioctl(sp_id,TIOCGETP,&tty);
- tty.sg_ospeed=B9600;
- tty.sg_ispeed=B9600;
- tty.sg_flags=ANYP|RAW|TANDEM;
- ioctl(sp_id,TIOCSETP,&tty);
-
-
- Whenever a read() is executed, and there no chars to be read, read should
- return 0 for the number read, no? Well, whenever I issue a read(),
- the program just hangs there, waiting on something from the serial port.
-
- So, I tried using select():
-
-
- FD_ZERO(&fdset);
- FD_SET(sp_id, &fdset);
- if (select(ulimit(4,0), &fdset, 0, 0, 0) <0) {
- perror("select");
- exit(1);
- }
- if (FD_ISSET(sp_id, &fdset)) {
- numrd = read(sp_id,&ch,1);
-
- etc...
-
-
- Now, select() never returns! ulimit() returns OK (64).
-
- I must be missing something really basic, if both are waiting on
- the serial port.
-
- Please forgive if this is a stupid question.
-
- Any/All help will be greatly appreciated!
- Chance Geurin
- geurin@nosc.mil
-