[comp.sys.amiga.tech] Sharing the serial device

lphillips@lpami.wimsey.bc.ca (Larry Phillips) (07/21/90)

In <31946@cup.portal.com>, Thyss@cup.portal.com (Brian TT Fudge) writes:
>Recently I was fooling around with the serial device and found that there
>was almost no use for sharing the serial device.  Is it just me, or do others
>have problems when they try it too?

Well, there's plenty of use for sharing the serial port. I don't have problems
sharing it, except for some ill-mannered terminal programs that open it in
EXCLUSIVE mode.

>I open 2 ports and 2 devices.  One to read from and one to write to.  Every-
>thing works fine.  I runback the program and then runback another one.  I
>loose every other character.  One program gets one character and the other
>the next. 

That's because there are READs outstanding from both programs. Sharing means
that a READ will be satisfied by the program currently holding it, and that any
other programs that want to READ will have to take their place in line. I can
remember starting up about 6 or 7 ATerms once, and watching the characters go
'round-robin' in the windows. Quite useless, but funny to watch. If you want to
share the port, you will have to ensure that any programs that are not using
it, do not have any outstanding READ commands pending. WRITE commands are less
of a problem.

>When I quit the program (close both devices and both ports), the TR (terminal
>ready) light on my modem goes off, meaning the serial device was closed.  I
>don't think that should happen since I should have 4 serial devices open, and
>closing 2 of them shouldn't close all 4.

That doesn't happen to me, because I don't use all 7 wires in my cables. I have
only three wires hooked up (TxD, RxD, and GND). I can exit any terminal program
and simply start another one. I have never bothered trying to find out what the
behaviour is under 7 wire operation, so I can't offer much advice there. Yes,
the port should not drop DTR while ANY programs have the device open.

I posted SerMod as part of ROBBS some time ago. It shows how the serial port
can be shared for both transmit and receive.

-larry

--
Sex is better than logic, but I can't prove it.
+-----------------------------------------------------------------------+ 
|   //   Larry Phillips                                                 |
| \X/    lphillips@lpami.wimsey.bc.ca -or- uunet!van-bc!lpami!lphillips |
|        COMPUSERVE: 76703,4322  -or-  76703.4322@compuserve.com        |
+-----------------------------------------------------------------------+

Thyss@cup.portal.com (Brian TT Fudge) (07/21/90)

Recently I was fooling around with the serial device and found that there
was almost no use for sharing the serial device.  Is it just me, or do others
have problems when they try it too?

I open 2 ports and 2 devices.  One to read from and one to write to.  Every-
thing works fine.  I runback the program and then runback another one.  I
loose every other character.  One program gets one character and the other
the next. 

When I quit the program (close both devices and both ports), the TR (terminal
ready) light on my modem goes off, meaning the serial device was closed.  I
don't think that should happen since I should have 4 serial devices open, and
closing 2 of them shouldn't close all 4.

Am I totally missing the point?  Should I give some example code?  Is there
a book on programming the serial device?  The 1.3RKM:Libs&Devs doesn't say
too much on sharing and I don't have the autodocs or hardware manuals.

Any help would be greatly appreciated...

Thanks

Thyss@cup.portal.com   or  ucbvax!sun!portal!cup.portal.com!thyss