[comp.sys.mac.programmer] How do you write a parasitic module that uses the Serial Port?

alexis@ccnysci.UUCP (Alexis Rosen) (02/15/89)

I have an application. I want to write an external command for it which talks
to the serial port (reads AND writes). The only problem is that the app already
has the serial port open, and I don't want to disturb it in any way. I also
don't want to get locked out because the port is open (I know, damnit!).
Is there any way to do this? I haven't thought about it deeply yet, and I'd
appreciate it enormously if I never had to :-)


Alexis Rosen
alexis@ccnysci.uucp

tim@hoptoad.uucp (Tim Maroney) (02/16/89)

In article <1273@ccnysci.UUCP> alexis@ccnysci.UUCP (Alexis Rosen) writes:
>
>I have an application. I want to write an external command for it which talks
>to the serial port (reads AND writes). The only problem is that the app already
>has the serial port open, and I don't want to disturb it in any way. I also
>don't want to get locked out because the port is open (I know, damnit!).

Just do reads and writes on the open port.  The reference numbers are
always the same, so if you know it's already opened, there's no need
for you to open it.  Your only problems will be if, first, some sort of
weird mode has been set up on the port -- for instance, you don't want
to do this during break mode -- and second, async reads and writes are
being used.  You could probably coexist peacefully with async writes,
given request ordering, but async reads are a stickier problem.  If
there's an async read outstanding, you might need to cheat horribly in
ways that will no doubt break your code in the future if not sooner,
and which I would prefer not to discuss.  Fortunately, most serial port
programs use a naive synchronous polling design.
-- 
Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim
"Skip, witches!  Hop, toads!  Take your pleasure!"
    -- Aleister Crowley, THE BOOK OF LIES