Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.xenix Subject: Re: getc help needed Summary: open the port with O_NDELAY and use read(2) Message-ID: <1204@virtech.UUCP> Date: 28 Sep 89 01:20:49 GMT References: <2056@leah.Albany.Edu> Distribution: usa Organization: Virtual Technologies Inc Lines: 29 In article <2056@leah.Albany.Edu>, tmm33@leah.Albany.Edu (Terry McCoy) writes: > I have looked at the getc function in the stdio.h header file and noticed that > it calls a function _filbuf. I think that this function is located within the > kernal and controls the pointers, flags and the counter within the structure Nope. _filbuf is a stdio library function that eventually uses read(2) to fill the buffer. > FILE. Any information on how this function works or how I could tell if data > has arrived at the serial port without waiting would be helpful. Since you are reading data off of the serial port you should use the following type of code: #includefd = open(TTY_PORT,O_RDWR+O_NDELAY....) if( (cnt=read(fd,buffer,512)) > 0 ) /* process the data */ else if( cnt == -1 ) /* handle read failure */ /* else cnt = 0 (no data available) */ -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+