home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sun.misc
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!mlb.semi.harris.com!sloth.mlb.semi.harris.com!pjp
- From: pjp@sloth.mlb.semi.harris.com (Pat J. Pinchera)
- Subject: How do I Detect Pending Data on a Serial Port?
- Date: Mon, 11 Jan 1993 21:58:18 GMT
- Nntp-Posting-Host: sloth.mlb.semi.harris.com
- Organization: Interface & Control Systems, Inc., Melbourne FL
- Sender: news@mlb.semi.harris.com
- Message-ID: <1993Jan11.215818.29796@mlb.semi.harris.com>
- Lines: 20
-
- I've openend up the serial port (/dev/tty[ab]) on my Sun IPC using the
- 'open' command. I get back a file descriptor. How can I detect if there
- is any data ready for reading, i.e. a Peek?
-
- I've tried ioctl(fd, I_PEEK, arg) but this really only applies to
- STREAMS, not File Descriptors. Then I tried ioctl(fd, FIONREAD, &num),
- but this is supposed to apply to 'files' per the filio man page. Note
- that both of these calls seemed to work in a simple C test program, but
- when I tried to use them in my big C++ project, they both returned -1
- and set errno to ENOTTY, which means the specified request does not
- apply to the kind of object I specified in 'fd'.
-
- Does anyone know how to do this? I want to be able to tell if there's
- data there without actually doing the read, because that would 'consume'
- the data. Reply here or e-mail. If this goes like my last couple of
- posts, I'll suddenly discover the answer in about 2 hours :-)
-
- Thanks,
- Pat
-
-