home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sun / misc / 6222 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.4 KB  |  32 lines

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