From: Ned F. <nfo...@wh...> - 2008-03-19 12:46:01
|
ani...@pa... wrote: > Hi All, > > I want to perform a serial timeout read through my gumstix ttyS2 > port.I use normal read function but it > gets stuck up when the controller at other end doesnot respond to it > or there is no physical connection between the two . > > How can i give a read timeout option in C ?? I tried NON blocking > option also but then i am not able to get data . It should be possible to open the port as non-blocking, and then perform your own polling of the port for new data, presumably with a usleep() somewhere in the loop so that your process does not hog the CPU. However, the preferred way is to use either poll() or select(); either one will wait for input from a specified group of ports (or any open files) and will return after a specified timeout if no data are available. All the documentation is in the man pages. -- Ned Forrester nfo...@wh... Oceanographic Systems Lab 508-289-2226 Applied Ocean Physics and Engineering Dept. Woods Hole Oceanographic Institution Woods Hole, MA 02543, USA http://www.whoi.edu/sbl/liteSite.do?litesiteid=7212 http://www.whoi.edu/hpb/Site.do?id=1532 http://www.whoi.edu/page.do?pid=10079 |