Thread View: comp.sys.next.programmer
3 messages
3 total messages
Started by Carlin Wiegner
Mon, 10 Aug 1992 19:31
Serial Port Question...
Author: Carlin Wiegner
Date: Mon, 10 Aug 1992 19:31
Date: Mon, 10 Aug 1992 19:31
5 lines
651 bytes
651 bytes
Can multiple applications montior and read/write to the same serial or ethernet port? CW --
Re: Serial Port Question...
Author: moose
Date: Tue, 11 Aug 1992 15:45
Date: Tue, 11 Aug 1992 15:45
18 lines
1059 bytes
1059 bytes
In article <1992Aug10.193155.14621@usenet.ins.cwru.edu> aj681@cleveland.Freenet.Edu (Carlin Wiegner) writes: > > Can multiple applications montior and read/write to the same > serial or ethernet port? > CW > -- Sure, for about 3 seconds. DPSAddFD, which is glue for select(), does not like having stuff on the serial port stolen from it between spotting it and getting your program to read it. There are workarounds, but it will usually cause your program to hang. -- Michael Rutman | moose@svcdudes.com Cubist | makes me a NeXT programmer Software Ventures | maker of MicroPhone II #include <std.disclaimer>
Re: Serial Port Question...
Author: Chris Lloyd
Date: Tue, 11 Aug 1992 22:50
Date: Tue, 11 Aug 1992 22:50
35 lines
2244 bytes
2244 bytes
In article <1992Aug11.154515.14514@svcdudes.com> moose@svcdudes.com writes:
>In article <1992Aug10.193155.14621@usenet.ins.cwru.edu>
>aj681@cleveland.Freenet.Edu (Carlin Wiegner) writes:
>>
>> Can multiple applications montior and read/write to the same
>> serial or ethernet port?
>
>Sure, for about 3 seconds. DPSAddFD, which is glue for select(), does not
>like having stuff on the serial port stolen from it between spotting it and
>getting your program to read it. There are workarounds, but it will usually
>cause your program to hang.
Ah, don't be such a pessimist :) The devices are perfectly happy to have
any number of readers and writers, if the programs doing the reading and
writing are aware (the programmer was aware) that other programs will be
reading or writing then there is no big deal, you just have to do your IO
correctly.
select() (which DPSAddFD() uses) is just an indicator that says "Ok, there
is something here", if your program hangs, it's in the handlers read().
writing is somewhat of a non-issue in most cases.
The best way to do this is to set the serial port to non-blocking IO
with { int i=1; ioctl(fd,FIONBIO,&i); }, in concert with select()/DPSAddFD(),
you will be notified of incoming data, then when your handler is called,
you check for errno being EWOULDBLOCK on error'ed read()'s and chalk them
up to someone else reading the data (ignore it). Otherwise processing
as usual...
There are a slew of ways to do this without hanging your program, if the
above doesn't suit the needs, I'd be happy to suggest several more.
la la la,
--
:: Christopher Lloyd :: a74k110@titan.ucc.umass.edu :: Yrrid, Inc. ::
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads