Right now, the ppower program can send STATUS_REQUEST
to two way modules (which include not only tranceivers
but also the LM14A and AM14A lamp and appliance
modules), and one can watch the response with "ppower
-m", but that's not very convenient and very hard to
script.
ppower should either:
1) have a special query mode which would ask for a
module's status and then wait (up to a few seconds) for
a response and then print that (maybe -s could be used
for this, and -i could be used for getting info from
the CM11a -- that would be sort of consistant with
heyu's commands).
or
2) recognize a command in the form "ppower
[device]:STATUS_REQUEST" and do the wait-and-print-info
thing.
Option 1 seems like a better choice to me, because it
keeps the behavior consistant -- just sending a command
should always be a quiet operation unless there is a
problem.
It's unfortunate that the reply to a status request
doesn't include the device number, so you pretty much
have to assume that the first response on the
appropriate housecode is the one you want. Ah well.
Here is a simple shell script that implements the
desired behavior in a really kludgy way:
#!/bin/sh
ppower $1$2:status_request
tlimit -t 1 -- ppower -m 2>/dev/null | \
awk "/Housecode $1.*STATUS/ { print \$8 }"
Housecode as first parameter, device as second.
"tlimit" is a simple program which runs a given command
with a time limit (in this case 1 second). It'd
actually be nice if "ppower -m" could do this by itself
-- I'lll make that a separate feature request.
Random musing: if a response is not forthcoming, and
the device is on the housecode that the CM11a is
listening for, maybe the query mode should fallback to
spitting out the state as known to the CM11a. Not as
reliable, perhaps, but better than nothing. Or maybe
this behavior should be a separate flag of even mode.
Reference URLs:
<http://www.pigselectronics.com/products/LM14A.htm>
<http://www.pigselectronics.com/products/AM14A.htm>
Logged In: YES
user_id=276685
Oh, also, the above kludge-script requires the
fflush(stdout); patch to work properly.