Subject: Re: Connecting UPS to a mac....
To: David A. Gatwood <marsmail@globegate.utm.edu>
From: Henry B. Hotz <hotz@jpl.nasa.gov>
List: port-mac68k
Date: 06/12/1997 10:29:02
At 10:53 AM 6/12/97, David A. Gatwood wrote:
>I'm sending this to both NetBSD's mailing list and MkLinux's setup list
>because it's really applicable to either.  NetBSD folks, please note that
>since mklinux lists are closed, any posts to them from ppl who aren't
>subscribed will bounce.

So they don't get to hear from me.  Their loss.


>First, I'm assuming that the handshaking inputs generate an internal
>voltage of 5v or so and wait for that to be pulled low, right?  Assuming
>that's valid, the UPS shorts the pin to a second one in order to pull it
>low, but it appears that the grounding has to be done in the cable.
>Should there be a resistor on either side to prevent the handshaking pin
>from being completely grounded, or is that within spec?

First the "official" answer:  The interface uses RS-232 voltage levels,
therefore valid states are between 3-25 volts + or -.  Between -3V and +3V
is undefined.

Now a more realistic answer:  There is *usually*but*not*always* a bias in
the detection threshold so a shorted input does not generate random
garbage.  I don't know what the Mac does, but the default "unbiased"
threshold for the usual interface chip is the normal TTL threshold  (is
that 1.4 V?  I forget.)

These voltages are relative to the signal ground on the interface unless it
is a differential input, in which case forget all the above and just
compare the two paired inputs to see which is higher.  These references are
chosen to avoid sensitivity to noise on long interface cables.

>On another (more Linux-specific, probably) note, I need a way to reliably
>make sure that my program reliably catches the change in serial
>handshaking signal very quickly after that two minute warning, since it
>could take ~30 seconds to shut down and... estimates are estimates.  It
>obviously can't run checks continuously, or the load would go through the
>roof.  Is it safe to put a sleep(1) or sleep(2) or even sleep(5) in the
>loop without worrying about whether the process might get swapped out
>and not catch the change in status?

For BSD you would need to look at the termio ioctl() calls.  I would hope
there is one to just wait until something, anything happens on the
interface.  Alternatively you might be able to wait for something like a
clear-to-send condition.  I do get the impression that Bill S. has done a
pretty careful job with the serial drivers.

How safe the sleep() call is depends on how much your machine is swapping.
In any case small processes are less likely to get swapped.  Are all the
syscalls that would allow you to lock yourself in memory restricted to the
kernel, or can you do something if you're root?

Signature failed Preliminary Design Review.
Feasibility of a new signature is currently being evaluated.
h.b.hotz@jpl.nasa.gov, or hbhotz@oxy.edu