From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078609810546.tru64-unix-managers.marc@archive.invalid> From: mgaluza () dejarnette ! com (Mike Galuza) Date: Fri, 21 Mar 1997 08:50:41 +0000 To: tru64-unix-managers Subject: SUMMARY: select on COM port X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078609810546 Thanks to the following for their responses. Dejan Muhamedagic Lars Bro, lab@dscc.dk "Jeffrey G. Micono 6533 (Ktech)" Here is my original question: > Hello. This question is more of a programming question so it may not > be appropriate for this list. If that's true, I apologize ahead of > time. Anyway, I'm having trouble doing a select() on a COM port. I > open /dev/tty00 with Read/Write permissions then do a select on it, but > it never comes back. I know the port is working okay because if I skip > the select and just read or write the fd it works fine. Does anyone > out there know if it is possible to do a select() on an RS232 connection? > And if so, is there anything special you have to do that I might be > missing? The response from Jeffrey G. Micono seems to have summed up the answer. > Mike, > > I kinda remember stumbling on this on an Ultrix box. Basically, > I was trying to select from both a socket descrip and a terminal > descrip. > > On Ultrix, this doesn't work. select did not work for character > special devices or files. > > Fortunately, you have other options in DU. If you are willing to > make your app multi-threaded, you can use regular old blocking > reads in separate threads for each fd. This gets rid of having > to use select and makes each thread very simple. The down side > is that you now have reentrancy and thread safety to be aware of > (and some possibly pretty hairy debugging sessions) > > If you must use one thread and select, you may have to write > a "shim" process that reads from the com port (using blocking > reads) and writes to a unix domain socket (or a socket on the > loopback ethernet). Then, your main program can select on the > unix domain socket and other sockets. > Since I am trying to do precisely what Jeffrey spoke of (doing a select on both a socket and a terminal descrip) I think I am having the same problem. I will probably use a thread to do a blocking read on the on the com port and then write whatever it gets to a socket where my main process will be hanging a select. Shouldn't be too tough. Oh, I almost forgot, I also downloaded the C-Kermit source code to see if it uses select. From what I could tell it didn't use select the way I need it on a com port, only on a socket. Thanks, again ---------------------------------------------------------------------- Michael Galuza DeJarnette Research Systems mgaluza@dejarnette.com 401 Washington Ave Suite 700 Voice: +1(410)583-0680 x691 Towson, MD 21204 Fax: +1(410)583-0696 ----------------------------------------------------------------------