Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C source for X-10 control? (part 2/2)

1 view
Skip to first unread message

Tim Rosmus

unread,
May 18, 1994, 4:53:29 PM5/18/94
to

---- Cut Here and feed the following to sh ----
#!/bin/sh
# this is X10.02 (part 2 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file x10/xread.c continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 2; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping x10/xread.c'
else
echo 'x - continuing file x10/xread.c'
sed 's/^X//' << 'SHAR_EOF' >> 'x10/xread.c' &&
X * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
X * (maynard!campbell). You may freely copy, use, and distribute this software
X * subject to the following restrictions:
X *
X * 1) You may not charge money for it.
X * 2) You may not remove or alter this copyright notice.
X * 3) You may not claim you wrote it.
X * 4) If you make improvements (or other changes), you are requested
X * to send them to me, so there's a focal point for distributing
X * improved versions.
X *
X * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
X * by doing the System V port and adding some nice features. Thanks!
X */
X
X#include <stdio.h>
X#include <signal.h>
X#include <setjmp.h>
X#include "x10.h"
X
Xunsigned alarm();
Xvoid sigtimer();
X
X/*
X * xread(fd, buf, count, timeout)
X *
X * Timed read. Works just like read(2) but gives up after
X * timeout seconds, returning whatever's been read so far.
X */
X
Xstatic jmp_buf jb;
X
Xxread(fd, buf, count, timeout)
Xunsigned char *buf;
X{
Xint total;
X
Xtotal = 0;
Xif (setjmp(jb))
X return(total);
X
X(void) signal(SIGALRM, sigtimer);
X(void) alarm((unsigned) timeout);
X
Xwhile (count--)
X {
X if (read(fd, (char *) buf, 1) < 1)
X {
X (void) alarm(0);
X (void) signal(SIGALRM, SIG_IGN);
X return(total);
X }
X buf++;
X total++;
X }
X(void) alarm(0);
X(void) signal(SIGALRM, SIG_IGN);
Xreturn(total);
X}
X
Xvoid
Xsigtimer()
X{
Xlongjmp(jb, 1);
X}
SHAR_EOF
echo 'File x10/xread.c is complete' &&
chmod 0644 x10/xread.c ||
echo 'restore of x10/xread.c failed'
Wc_c="`wc -c < 'x10/xread.c'`"
test 1412 -eq "$Wc_c" ||
echo 'x10/xread.c: original size 1412, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/Makefile ==============
if test -f 'x10/Makefile' -a X"$1" != X"-c"; then
echo 'x - skipping x10/Makefile (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/Makefile' &&
XHOME = .
XBIN = .
XGROUP = sys
XOWNER = edm
X
X# set DFLAGS equal to:
X# -DVENIX if using VENIX
X# -DSYSV if using SYSTEM V
X# -DVOID if compiler doesn't understand 'void'
X# -DMINIEXCH if using the DEC mini-exchange
X# -DXDIR=\"fullpath_name/x10\" if not using default of "."
X# DFLAGS = -DXDIR=\"$(HOME)/x10\"
XDFLAGS =
X
XCFLAGS = -O $(DFLAGS)
XLDFLAGS = -z -i
X#LIBS = -lc_s # uncomment if using shared libraries
X
XSRCS = data.c date.c delete.c diagnostic.c dump.c fdump.c \
X finfo.c fload.c info.c getslot.c message.c miniexch.c \
X monitor.c prints.c readid.c reset.c schedule.c setclock.c \
X tty.c unit.c x10.c xread.c
X
XOBJS = data.o date.o delete.o diagnostic.o dump.o fdump.o \
X finfo.o fload.o info.o getslot.o message.o miniexch.o \
X monitor.o prints.o readid.o reset.o schedule.o setclock.o \
X tty.o unit.o x10.o xread.o
X
Xx10: $(OBJS)
X cc $(LDFLAGS) -o x10 $(OBJS) $(LIBS)
X if [ -f /usr/bin/mcs ]; then mcs -c x10; fi
X chgrp $(GROUP) x10
X chmod 2755 x10
X chown $(OWNER) x10
X
X$(OBJS): x10.h
X
Xinstall: x10
X mv x10 $(BIN)
X
Xlint:
X lint $(DFLAGS) $(SRCS)
X
Xshar: x10.shar.1 x10.shar.2
X
Xx10.shar.1:
X shar README REVIEW Makefile x10.[1h] >x10.shar.1
X
Xx10.shar.2:
X shar $(SRCS) > x10.shar.2
X
Xclean:
X rm -f *.o
X
Xclobber: clean
X rm -f x10
SHAR_EOF
chmod 0644 x10/Makefile ||
echo 'restore of x10/Makefile failed'
Wc_c="`wc -c < 'x10/Makefile'`"
test 1238 -eq "$Wc_c" ||
echo 'x10/Makefile: original size 1238, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/data.c ==============
if test -f 'x10/data.c' -a X"$1" != X"-c"; then
echo 'x - skipping x10/data.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/data.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/data.c' &&
X/*
X * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
X * (maynard!campbell). You may freely copy, use, and distribute this software
X * subject to the following restrictions:
X *
X * 1) You may not charge money for it.
X * 2) You may not remove or alter this copyright notice.
X * 3) You may not claim you wrote it.
X * 4) If you make improvements (or other changes), you are requested
X * to send them to me, so there's a focal point for distributing
X * improved versions.
X *
X * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
X * by doing the System V port and adding some nice features. Thanks!
X */
X
X#include <stdio.h>
X#include <ctype.h>
X#include "x10.h"
X
Xextern int tty;
Xextern char flag;
Xextern struct hstruct
X housetab[];
X
Xc_data(argc, argv)
Xchar *argv[];
X{
Xunsigned datano, id, unit;
Xunsigned char buf[6];
Xchar hletter;
Xint n, hcode;
X
Xif (argc != 5) usage(E_WNA);
X
X/* parse the housecode */
Xhletter = argv[2][0];
Xif (isupper(hletter)) hletter = tolower(hletter);
Xfor (n = 0, hcode = -1; n < 16; n++)
X if (housetab[n].h_letter == hletter)
X {
X hcode = housetab[n].h_code;
X break;
X }
Xif (hcode == -1) error("invalid house code");
X
X/* parse the unit number */
Xif (!sscanf(&argv[2][1], "%d", &unit) || unit < 1 || unit > 16)
X error("bad unit number, must be between 1 and 16");
X
X/* parse the description id */
Xif (!sscanf(argv[4], "%d", &id) || id < 1 || id > 255)
X error("bad description id, must be a number between 1 and 255");
X
X/* parse the state */
Xif (strcmp(argv[3], "on") == 0)
X id |= 0x80;
Xelse if (strcmp(argv[3], "off") == 0);
Xelse error("bad state, must be 'on' or 'off'");
X
X/* get first available slot number from the x10 */
Xdatano = getslot(GETDATA);
X
X/* get descriptions for all id's */
Xreadid();
X
Xbuf[0] = DATALOAD;
Xbuf[1] = datano << 1;
Xbuf[2] = datano >> 7 | 0x4;
Xbuf[3] = hcode | unit - 1;
Xbuf[4] = id;
Xbuf[5] = 0;
X
Xfor (n = 3; n < DICMD - 1; n++) /* compute checksum */
X buf[DICMD - 1] += buf[n];
X
Xsendsync();
X(void) write(tty, (char *) buf, sizeof(buf));
Xchkack();
X
Xflag = 0; /* header wanted */
Xpdata(&buf[3], datano); /* reassure user */
X}
SHAR_EOF
chmod 0644 x10/data.c ||
echo 'restore of x10/data.c failed'
Wc_c="`wc -c < 'x10/data.c'`"
test 2133 -eq "$Wc_c" ||
echo 'x10/data.c: original size 2133, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/README ==============
if test -f 'x10/README' -a X"$1" != X"-c"; then
echo 'x - skipping x10/README (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/README' &&
XDESCRIPTION
X
Xx10 is a little program for hacking a BSR X10 "Powerhouse" home
Xcontrol device. This gizmo, currently sold by DAK (a discount mail
Xorder house) for $49.95, can remotely control lights and appliances
Xin your house by signaling over the house wiring. Since most people
Xknow what the X10 system does (see the DAK catalog for details; Radio
XShack also sells X10 stuff) I won't describe it in detail here.
X
XThe gizmo comes with software for IBM PCs, Apples, or Commodores, but
XI wanted to hang it off my UNIX box. So I wrote this program.
X
XThe BSR X10 Powerhouse connects to a computer with an RS232 interface.
XIt can store up to 128 events; each event can turn on, turn off, or dim
Xup to sixteen slave units. The X10 box has a battery backed up clock
Xwhich the computer can read, which turned out to be one of its biggest
Xuses for me -- my computer doesn't have a battery clock.
X
XEach slave unit has a one-letter housecode ranging from A to P (for 16
Xdifferent codes) and a number from 1 to 16. x10's command structure
Xis pretty primitive. See the man pages for details.
X
XINSTALLATION
X
XHopefully, the only file that needs to be configured for your
Xsystem is the makefile. You may need to review x10.h and tty.c
Xif you experience any trouble.
X
XChange BIN to the location of your favorite directory.
XChange OWNER to whichever login you want.
XKeep the GROUP set to sys.
X
Xthe DFLAGS line in the makefile needs to be configured as follows:
X
X add -DVENIX if you are using Venix
X add -DSYSV if you are using System III or V
X add -DMINIEXCH if you are using the DEC mini-exchange
X add -DVIOD if your compiler doesn't have type void
X add -DXDIR=\"fullpath_name/x10\" if you don't want to
X use the default path of the current directory
X
XAfter changing the makefile for your system, do 'make'.
XNext, cd as 'root' to /dev and link the root filesystem
Xand tty port connected to the 'X10' as follows:
X ln root_fs_special_device x10fs
X ln tty_port x10
X
XThe port connected to the x10 should not have a getty running.
XThe root filesystem needs to be set to group 'sys' and mode 440.
X('x10 date' is the only command that requires this. If you do
Xnot want to do it because you're worried about security, do not
Xcreate /dev/x10fs. All other features of x10 will work.) The
Xtty port connected to the x10 needs to be changed to the owner
Xof the 'X10 device', and the mode needs to be set to 600.
X
XFinially, do 'make install' as root to install x10 in the proper
Xlocation, with the proper owner and the proper permissions.
X
XPORTABILITY
X
XThis has been tested under VENIX/Rainbow, which is basically V7 (thus
Xthere are no short-identifier problems), and on System V, Release 3.0.
XIt should run OK under BSD-flavor UNIX.
X
XNOTES
X
XI'm running my X10 through a DEC Mini-Exchange, which is a dumb little
X8-port programmable port selector. (My computer has only one, count 'em,
Xserial port with modem control, which is why I use the Mini-Exchange.)
X
XThere are two VENIX-specific hacks in x10. First, my routine hangup()
Xdepends on a modification I made to the VENIX tty driver that causes it
Xto drop DTR if you set the baud rate to zero, and raise it again when
Xyou set the baud rate to a nonzero number. Most modern flavors of UNIX
Xhave an ioctl or something to do this.
X
XSecond, there are a number of occurrences of:
X
X sleep(SMALLPAUSE);
X
Xwhere SMALLPAUSE is #defined to be -10. This is a VENIX-specific hack
Xthat means sleep for 10 60ths of a second, or 1/6th of a second. This
Xisn't critical; if VENIX is not defined in the makefile, SMALLPAUSE is
Xset to 1.
X
XEXAMPLES
X
XExample contents of an id file:
X
X1 Bedroom switched table lamp
X2 Office switched floor lamp
X3 Living room ceiling lights
X4 Front porch and garrage lights
X5 Family room hanging lamp
X6 Family room portable radio
X7 Thermostat
X8 Bedroom protable tv
X
XExample output of the 'x10 dump all' command using the above id file:
X
X SLOT UNIT STATE ID DESCRIPTION
X 0 c1 Off 001 Bedroom switched table lamp
X 1 c2 Off 002 Office switched floor lamp
X 2 c3 Off 003 Living room ceiling lights
X 3 c4 Off 004 Front porch and garrage lights
X 4 c5 Off 005 Family room hanging lamp
X 5 c6 Off 006 Family room portable radio
X 6 c7 Off 007 Thermostat
X 7 c8 Off 008 Bedroom protable tv
X
X EVENT STATE MODE DAYS TIME UNITS
X 0 On Normal Everyday 21:00 c5
X 1 Off Normal Everyday 22:30 c1-8
X 2 Dim 8 Normal Everyday 21:15 c3
X 3 Off Normal Everyday 21:45 c3
X 4 On Today 21:33 c1
X 5 Dim 4 Security Weekdays 20:15 c2
X 6 Off Normal Weekend 1:00 c1-2,6-7
X
X- Larry Campbell (maynard!campbell)
X with help from John Chmielewski (rogue!jlc)
X September 1, 1986
SHAR_EOF
chmod 0644 x10/README ||
echo 'restore of x10/README failed'
Wc_c="`wc -c < 'x10/README'`"
test 4967 -eq "$Wc_c" ||
echo 'x10/README: original size 4967, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/REVIEW ==============
if test -f 'x10/REVIEW' -a X"$1" != X"-c"; then
echo 'x - skipping x10/REVIEW (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/REVIEW (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/REVIEW' &&
X===========================================================================
XX10 PowerHouse Product Review Joseph M. Newcomer
X===========================================================================
X
X[I gather from reading this several times that the X10 Powerhouse is
Xa BSR controller which allows one to turn on and off various electrical
Xoutlets in your house by sendigh digital radio signals through the power
Xlines to remote switches. -wab]
X
XI bought an X10 PowerHouse with IBM-PC software a while back from the nice
Xfolks at DAK. I couldn't get it to work, so hadn't reported on it.
X
XWhat I can now report is success. The basic problem was the interface
Xwas dead. This was hard to determine, since pushing an on/off key actually
Xsent data to the machine, and the machine was clearly sending data to
Xthe PowerHouse controller, but the controller never responded to the computer.
XI finally got around to calling them, and got their technical guy on the line.
XHe had me do a couple experiments and determined that it was dead. Within
Xa week I received a new unit with a return letter to return the old (dead) one.
X
XIt took a bit more experimental computer science to get it working. The
Xdocumentation told me how to install DOS on my X10 disk, but not how
Xto install X10 software on my hard disk. So of course I got it wrong;
XI failed to install "X10.DAT". I'm not sure what this does but it is
Xcritical; without it, the interface still appears to be dead. (The
Xdifferences was that 'local control' at the interface would actually
Xactivate devices!) The error message is definitely misleading. Anyway,
XI installed X10.DAT and it worked.
X
XThe user interface is rather tasteful. No silly little house icons with 5
Xbedrooms and no libraries or computer rooms (as the Radio Shack product) and
Xyou can assign any house/unit code to any device (unlike Radio Shack where you
Xhave to artificially use up all the "A" units to be able to use a "B" unit,
Xand you can't have multiple assignments to the same code). I'd have done a
Xfew things differently, but at least they got it really well done. You can
Xsave configurations on disk files, and load the files, so I now have "normal"
Xand "away" modes. You can temporarily "freeze" a request so it is effectively
X"turned off" without actually losing the data, although on the whole I prefer
Xto use different files for this.
X
X
XIt comes with three manuals, all rather detailed but certainly not
Xcomplete. There is an owner's manual which tells how to install
Xcontrollers and configure them. There is the software manual, which
Xtells how to use the software they deliver with it. Finally, there
Xis the programming guide, which gives in nearly-infinitesimal detail
Xall of the async protocols for actually communicating with it. This
Xdetail, alas, misses a few key questions and isn't entirely clear
Xanyway, but most of it appears to be there. If you have a compulsion
Xto program it yourself, which I think is largely unnecessary given
Xthe not-bad-at-all software, you may end up on the phone to New
XJersey. On the other hand, they seem anxious to help.
X
XA Good Buy, in my estimation. joe
X
X===========================================================================
XRe:DAK BSR X10 Powerhouse Interface Larry Campbell
X===========================================================================
X
XOne small contradiction to Joe Newcomer's otherwise accurate review
Xof the BSR X10 Powerhouse in Info-IBMPC Digest V5 #68. He said that
Xit looked like the protocol manual was incomplete, and that anyone
Xtrying to actually write software for the thing would probably have
Xto make a few phone calls to New Jersey. (He also wondered why anyone
Xwould want to write such software since the program shipped with the
Xbox was so good.)
X
XI had to write my own software since I am not using an IBM PC running
XMS-DOS, but rather a DEC Rainbow running VENIX. I was able to get my
Xsoftware working without any calls to New Jersey. Actually there were
Xa couple of omissions in the manual, but I was able to figure them out
Xwithout any trouble. All in all, I think the protocol manual is pretty
Xgood.
X
XAnother nifty feature of the BSR box that I think Joe failed to mention
Xis that it contains a battery backed up clock. Since there isn't a
Xreasonable way to get a clock into a Rainbow (there are some hacks on
Xthe market at about $125, or more than twice the cost of the BSR box),
XI also hacked up a way for my system to query the BSR box at boot time
Xfor the date and time.
X
XAll in all, I agree with Joe: the box is nifty and a bargain at $49.90.
X
XLarry Campbell The Boston Software Works, Inc.
X 120 Fulton Street, Boston MA 02109
XUUCP: {alliant,wjh12}!maynard!campbell (617) 367-6846
SHAR_EOF
chmod 0644 x10/REVIEW ||
echo 'restore of x10/REVIEW failed'
Wc_c="`wc -c < 'x10/REVIEW'`"
test 4778 -eq "$Wc_c" ||
echo 'x10/REVIEW: original size 4778, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/date.c ==============
if test -f 'x10/date.c' -a X"$1" != X"-c"; then
echo 'x - skipping x10/date.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/date.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/date.c' &&
X/*
X * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
X * (maynard!campbell). You may freely copy, use, and distribute this software
X * subject to the following restrictions:
X *
X * 1) You may not charge money for it.
X * 2) You may not remove or alter this copyright notice.
X * 3) You may not claim you wrote it.
X * 4) If you make improvements (or other changes), you are requested
X * to send them to me, so there's a focal point for distributing
X * improved versions.
X *
X * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
X * by doing the System V port and adding some nice features. Thanks!
X */
X
X#include <stdio.h>
X#include <time.h>
X#ifdef SYSV
X#include <sys/types.h>
X#endif
X/*
X * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
X * (maynard!campbell). You may freely copy, use, and distribute this software
X * subject to the following restrictions:
X *
X * 1) You may not charge money for it.
X * 2) You may not remove or alter this copyright notice.
X * 3) You may not claim you wrote it.
X * 4) If you make improvements (or other changes), you are requested
X * to send them to me, so there's a focal point for distributing
X * improved versions.
X *
X * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
X * by doing the System V port and adding some nice features. Thanks!
X */
X
X#include <sys/param.h>
X#include "x10.h"
X
Xextern struct tm *localtime();
X
Xextern long lseek();
X
Xextern int
X Idays,
X Ihours,
X Iminutes;
X
X/* ARGSUSED */
X
Xc_date(argc, argv)
Xchar *argv[];
X{
Xint rf, today;
Xstruct tm *tp;
Xlong curtime, time();
X
Xif (argc != 2) usage(E_2MANY);
Xcurtime = time((long *)0);
Xtp = localtime(&curtime);
Xtoday = dowX2U(Idays);
Xwhile (tp->tm_wday % 7 != today)
X tp->tm_wday++, tp->tm_mday++;
X
X#ifdef VENIX
X(void) printf("%2d%02d%02d%02d%02d\n",
X tp->tm_year, tp->tm_mon+1, tp->tm_mday, Ihours, Iminutes);
X#else
X(void) printf("%02d%02d%02d%02d%2d\n",
X tp->tm_mon+1, tp->tm_mday, Ihours, Iminutes, tp->tm_year);
X#endif
X}
SHAR_EOF
chmod 0644 x10/date.c ||
echo 'restore of x10/date.c failed'
Wc_c="`wc -c < 'x10/date.c'`"
test 2032 -eq "$Wc_c" ||
echo 'x10/date.c: original size 2032, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/delete.c ==============
if test -f 'x10/delete.c' -a X"$1" != X"-c"; then
echo 'x - skipping x10/delete.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/delete.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/delete.c' &&
X/*
X * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
X * (maynard!campbell). You may freely copy, use, and distribute this software
X * subject to the following restrictions:
X *
X * 1) You may not charge money for it.
X * 2) You may not remove or alter this copyright notice.
X * 3) You may not claim you wrote it.
X * 4) If you make improvements (or other changes), you are requested
X * to send them to me, so there's a focal point for distributing
X * improved versions.
X *
X * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
X * by doing the System V port and adding some nice features. Thanks!
X */
X
X#include <stdio.h>
X#include "x10.h"
X
Xextern int tty;
X
Xc_delete(argc, argv)
Xchar *argv[];
X{
Xregister unsigned cmdsize, n, arg;
Xunsigned number;
Xchar buf[12];
X
Xif (argc < 4) usage(E_NMA);
X
Xif (strncmp(argv[2], EVENTS, sizeof(EVENTS) - 2) == 0)
X cmdsize = EVCMD;
Xelse if (strcmp(argv[2], DATA) == 0)
X cmdsize = DICMD;
Xelse error("unknown delete request");
X
Xbuf[0] = DATALOAD;
X
Xfor (arg = 3; arg < argc; arg++)
X {
X if (!sscanf(argv[arg], "%d", &number))
X (void) fprintf(stderr,
X "ignored non-numeric event number\n");
X
X if (cmdsize == EVCMD)
X {
X if (number > ETOTAL - 1)
X {
X (void) fprintf(stderr,
X "ignored event number greater than 127\n");
X continue;
X }
X buf[1] = number << 3;
X buf[2] = (number >> 5) & 0x3;
X }
X else
X {
X if (number > DTOTAL - 1)
X {
X (void) fprintf(stderr,
X "ignored data slot number greater than 255\n");
X continue;
X }
X buf[1] = number << 1;
X buf[2] = (number >> 7) | 0x4;
X }
X
X for (n = 3; n < cmdsize; n++)
X buf[n] = 0;
X
X sendsync();
X (void) write(tty, buf, cmdsize);
X
X chkack();
X }
X}
SHAR_EOF
chmod 0644 x10/delete.c ||
echo 'restore of x10/delete.c failed'
Wc_c="`wc -c < 'x10/delete.c'`"
test 1719 -eq "$Wc_c" ||
echo 'x10/delete.c: original size 1719, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/diagnostic.c ==============
if test -f 'x10/diagnostic.c' -a X"$1" != X"-c"; then
echo 'x - skipping x10/diagnostic.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/diagnostic.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/diagnostic.c' &&
X/*
X * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
X * (maynard!campbell). You may freely copy, use, and distribute this software
X * subject to the following restrictions:
X *
X * 1) You may not charge money for it.
X * 2) You may not remove or alter this copyright notice.
X * 3) You may not claim you wrote it.
X * 4) If you make improvements (or other changes), you are requested
X * to send them to me, so there's a focal point for distributing
X * improved versions.
X *
X * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
X * by doing the System V port and adding some nice features. Thanks!
X */
X
X#include <stdio.h>
X#include "x10.h"
X
Xextern int tty, timeout;
X
X/* ARGSUSED */
X
Xc_diagnostic(argc, argv)
Xchar *argv[];
X{
Xchar buf[1];
X
Xif (argc != 2) usage(E_2MANY);
Xbuf[0] = DIAGNOSE;
Xsendsync();
X(void) write(tty, buf, 1);
Xtimeout = DTIMEOUT;
Xchkack();
Xtimeout = TIMEOUT;
X}
SHAR_EOF
chmod 0644 x10/diagnostic.c ||
echo 'restore of x10/diagnostic.c failed'
Wc_c="`wc -c < 'x10/diagnostic.c'`"
test 920 -eq "$Wc_c" ||
echo 'x10/diagnostic.c: original size 920, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/events ==============
if test -f 'x10/events' -a X"$1" != X"-c"; then
echo 'x - skipping x10/events (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/events (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/events' &&
X EVENT STATE MODE DAYS TIME UNITS
X 0 On Normal Sunday 7:30 m1-2,8
X 1 On Normal Monday 5:30 m1-2,8
X 2 On Normal Tuesday 5:30 m1-2,8
X 3 On Normal Wednesday 5:30 m1-2,8
X 4 On Normal Thursday 5:30 m1-2,8
SHAR_EOF
chmod 0644 x10/events ||
echo 'restore of x10/events failed'
Wc_c="`wc -c < 'x10/events'`"
test 353 -eq "$Wc_c" ||
echo 'x10/events: original size 353, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/id ==============
if test -f 'x10/id' -a X"$1" != X"-c"; then
echo 'x - skipping x10/id (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/id (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/id' &&
SHAR_EOF
chmod 0644 x10/id ||
echo 'restore of x10/id failed'
Wc_c="`wc -c < 'x10/id'`"
test 0 -eq "$Wc_c" ||
echo 'x10/id: original size 0, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/schedules/normal ==============
if test ! -d 'x10/schedules'; then
echo 'x - creating directory x10/schedules'
mkdir 'x10/schedules'
fi
if test -f 'x10/schedules/normal' -a X"$1" != X"-c"; then
echo 'x - skipping x10/schedules/normal (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/schedules/normal (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/schedules/normal' &&
Xx10 reset m
Xx10 setclock
X
X# Bedroom lights and radio on and off in the mornings on workdays.
Xx10 schedule m2,7 normal sun 7:15 on
Xx10 schedule m2,7 normal sun 8:45 off
Xx10 schedule m2,7 normal mon 6:00 on
Xx10 schedule m2,7 normal mon 7:30 off
Xx10 schedule m2,7 normal tue 6:00 on
Xx10 schedule m2,7 normal tue 7:30 off
Xx10 schedule m2,7 normal wed 6:00 on
Xx10 schedule m2,7 normal wed 7:30 off
Xx10 schedule m2,7 normal thu 6:00 on
Xx10 schedule m2,7 normal thu 7:30 off
Xx10 schedule m2,7 normal fri 6:00 on
Xx10 schedule m2,7 normal fri 7:30 off
X
X# Turn on the living room light(s) at random in the evening for effect.
Xx10 schedule m1 security sun 20:30 on
Xx10 schedule m1 security sun 22:30 off
Xx10 schedule m1 security mon 20:00 on
Xx10 schedule m1 security mon 22:30 off
Xx10 schedule m1 security tue 20:00 on
Xx10 schedule m1 security tue 22:00 off
Xx10 schedule m1 security wed 20:00 on
Xx10 schedule m1 security wed 22:00 off
Xx10 schedule m1 security thu 20:30 on
Xx10 schedule m1 security thu 22:30 off
Xx10 schedule m1 security fri 20:30 on
Xx10 schedule m1 security fri 22:30 off
Xx10 schedule m1 security sat 20:30 on
Xx10 schedule m1 security sat 22:30 off
X
SHAR_EOF
chmod 0755 x10/schedules/normal ||
echo 'restore of x10/schedules/normal failed'
Wc_c="`wc -c < 'x10/schedules/normal'`"
test 1156 -eq "$Wc_c" ||
echo 'x10/schedules/normal: original size 1156, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/schedules/away ==============
if test -f 'x10/schedules/away' -a X"$1" != X"-c"; then
echo 'x - skipping x10/schedules/away (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/schedules/away (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/schedules/away' &&
X
Xx10 reset m
Xx10 setclock
X
Xx10 schedule m1,2 security weekday 6:30 on
Xx10 schedule m8 security weekday 7:30 on
Xx10 schedule m1,2 security weekend 6:30 on
Xx10 schedule m8 security weekend 7:30 on
X
Xx10 schedule m1,2 security weekday 7:30 off
Xx10 schedule m8 security weekday 8:30 off
Xx10 schedule m1,2 security weekend 7:30 off
Xx10 schedule m8 security weekend 8:30 off
X
Xx10 schedule m12 security weekday 12:00 on
Xx10 schedule m12 security weekday 13:00 off
Xx10 schedule m12 security weekend 12:00 on
Xx10 schedule m12 security weekend 13:00 off
X
Xx10 schedule m8 security weekday 14:00 on
Xx10 schedule m8 security weekend 14:00 on
X
Xx10 schedule m1,2 security weekday 17:00 on
Xx10 schedule m1,2 security weekend 17:00 on
X
Xx10 schedule m8 security weekday 21:00 off
Xx10 schedule m8 security weekend 21:00 off
X
Xx10 schedule m1,2 security weekday 23:00 off
Xx10 schedule m1,2 security weekend 23:00 off
X
SHAR_EOF
chmod 0755 x10/schedules/away ||
echo 'restore of x10/schedules/away failed'
Wc_c="`wc -c < 'x10/schedules/away'`"
test 896 -eq "$Wc_c" ||
echo 'x10/schedules/away: original size 896, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/schedules/normal.old ==============
if test -f 'x10/schedules/normal.old' -a X"$1" != X"-c"; then
echo 'x - skipping x10/schedules/normal.old (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/schedules/normal.old (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/schedules/normal.old' &&
Xx10 reset m
Xx10 setclock
X
X# Lights and stereo on and off in the mornings on workdays.
Xx10 schedule m1,2,7,8 normal sun 7:15 on
Xx10 schedule m1,2,7,8 normal sun 8:45 off
Xx10 schedule m1,2,7,8 normal mon 5:30 on
Xx10 schedule m1,2,7,8 normal mon 7:30 off
Xx10 schedule m1,2,7,8 normal tue 5:30 on
Xx10 schedule m1,2,7,8 normal tue 7:30 off
Xx10 schedule m1,2,7,8 normal wed 5:30 on
Xx10 schedule m1,2,7,8 normal wed 7:30 off
Xx10 schedule m1,2,7,8 normal thu 5:30 on
Xx10 schedule m1,2,7,8 normal thu 7:30 off
Xx10 schedule m1,2,7,8 normal fri 5:30 on
Xx10 schedule m1,2,7,8 normal fri 7:30 off
X
X# Set-back thermostat control on every night at 11:00pm.
X# And at times while I am at work.
Xx10 schedule m16 normal e 23:00 on
Xx10 schedule m16 normal sun 8:30 on
Xx10 schedule m16 normal mon 7:30 on
Xx10 schedule m16 normal tue 7:30 on
Xx10 schedule m16 normal wed 7:30 on
Xx10 schedule m16 normal thu 7:30 on
Xx10 schedule m16 normal fri 7:30 on
X
X# Turn off at appropriate times through the week.
Xx10 schedule m16 normal sun 5:30 off
Xx10 schedule m16 normal mon 4:30 off
Xx10 schedule m16 normal mon 16:00 off
Xx10 schedule m16 normal tue 4:30 off
Xx10 schedule m16 normal tue 16:00 off
Xx10 schedule m16 normal wed 4:30 off
Xx10 schedule m16 normal wed 16:00 off
Xx10 schedule m16 normal thu 4:30 off
Xx10 schedule m16 normal thu 16:00 off
Xx10 schedule m16 normal fri 4:30 off
Xx10 schedule m16 normal fri 16:00 off
Xx10 schedule m16 normal sat 8:00 off
X
SHAR_EOF
chmod 0755 x10/schedules/normal.old ||
echo 'restore of x10/schedules/normal.old failed'
Wc_c="`wc -c < 'x10/schedules/normal.old'`"
test 1429 -eq "$Wc_c" ||
echo 'x10/schedules/normal.old: original size 1429, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/schedules/christmas ==============
if test -f 'x10/schedules/christmas' -a X"$1" != X"-c"; then
echo 'x - skipping x10/schedules/christmas (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/schedules/christmas (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/schedules/christmas' &&
Xx10 reset m
Xx10 setclock
X
X# Bedroom lights and radio on and off in the mornings on workdays.
Xx10 schedule m2,7 normal sun 7:30 on
Xx10 schedule m2,7 normal sun 8:45 off
Xx10 schedule m2,7 normal mon 6:00 on
Xx10 schedule m2,7 normal mon 8:30 off
Xx10 schedule m2,7 normal tue 6:00 on
Xx10 schedule m2,7 normal tue 8:30 off
Xx10 schedule m2,7 normal wed 6:00 on
Xx10 schedule m2,7 normal wed 8:30 off
Xx10 schedule m2,7 normal thu 6:00 on
Xx10 schedule m2,7 normal thu 8:30 off
Xx10 schedule m2,7 normal fri 6:00 on
Xx10 schedule m2,7 normal fri 8:30 off
X
X# Turn on the living room light(s) at random in the evening for effect.
Xx10 schedule m1 security e 18:30 on
Xx10 schedule m1 security e 22:30 off
X
X# Coffee maker
Xx10 schedule m5 normal sun 9:00 on
Xx10 schedule m5 normal sun 10:30 off
Xx10 schedule m5 normal mon 6:00 on
Xx10 schedule m5 normal mon 8:15 off
Xx10 schedule m5 normal tue 6:00 on
Xx10 schedule m5 normal tue 8:15 off
Xx10 schedule m5 normal wed 6:00 on
Xx10 schedule m5 normal wed 8:15 off
Xx10 schedule m5 normal thu 6:00 on
Xx10 schedule m5 normal thu 8:15 off
Xx10 schedule m5 normal fri 6:00 on
Xx10 schedule m5 normal fri 8:15 off
Xx10 schedule m5 normal sat 7:30 on
Xx10 schedule m5 normal sat 9:30 off
X
X# Christmas lights
Xx10 schedule m6 normal e 17:30 on
Xx10 schedule m6 normal e 22:30 off
X
SHAR_EOF
chmod 0755 x10/schedules/christmas ||
echo 'restore of x10/schedules/christmas failed'
Wc_c="`wc -c < 'x10/schedules/christmas'`"
test 1293 -eq "$Wc_c" ||
echo 'x10/schedules/christmas: original size 1293, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/schedules/normal.old.old ==============
if test -f 'x10/schedules/normal.old.old' -a X"$1" != X"-c"; then
echo 'x - skipping x10/schedules/normal.old.old (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/schedules/normal.old.old (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/schedules/normal.old.old' &&
Xx10 reset m
Xx10 setclock
X
X# Lights and stereo on in the mornings on workdays.
Xx10 schedule m1,2,8 normal sun 7:30 on
Xx10 schedule m1,2,8 normal mon 5:30 on
Xx10 schedule m1,2,8 normal tue 5:30 on
Xx10 schedule m1,2,8 normal wed 5:30 on
Xx10 schedule m1,2,8 normal thu 5:30 on
X
X# Set-back thermostat control on every night at 11:00pm.
X# And at times while I am at work.
Xx10 schedule m16 normal e 23:00 on
Xx10 schedule m16 normal sun 8:30 on
Xx10 schedule m16 normal mon 7:30 on
Xx10 schedule m16 normal mon 1:30 on
Xx10 schedule m16 normal tue 7:30 on
Xx10 schedule m16 normal tue 1:30 on
Xx10 schedule m16 normal wed 7:30 on
Xx10 schedule m16 normal wed 1:30 on
Xx10 schedule m16 normal thu 7:30 on
Xx10 schedule m16 normal thu 1:30 on
X
X# Turn off at appropriate times through the week.
Xx10 schedule m16 normal sun 7:00 off
Xx10 schedule m16 normal sun 12:00 off
Xx10 schedule m16 normal mon 5:00 off
Xx10 schedule m16 normal mon 11:30 off
Xx10 schedule m16 normal mon 5:30 off
Xx10 schedule m16 normal tue 5:00 off
Xx10 schedule m16 normal tue 11:30 off
Xx10 schedule m16 normal tue 5:30 off
Xx10 schedule m16 normal wed 5:00 off
Xx10 schedule m16 normal wed 11:30 off
Xx10 schedule m16 normal wed 5:30 off
Xx10 schedule m16 normal thu 5:00 off
Xx10 schedule m16 normal thu 11:30 off
Xx10 schedule m16 normal thu 5:30 off
Xx10 schedule m16 normal fri 9:00 off
Xx10 schedule m16 normal sat 9:00 off
X
SHAR_EOF
chmod 0755 x10/schedules/normal.old.old ||
echo 'restore of x10/schedules/normal.old.old failed'
Wc_c="`wc -c < 'x10/schedules/normal.old.old'`"
test 1374 -eq "$Wc_c" ||
echo 'x10/schedules/normal.old.old: original size 1374, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/schedules/normal.pdt ==============
if test -f 'x10/schedules/normal.pdt' -a X"$1" != X"-c"; then
echo 'x - skipping x10/schedules/normal.pdt (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/schedules/normal.pdt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/schedules/normal.pdt' &&
Xx10 reset m
Xx10 setclock
X
X# Bedroom lights and radio on and off in the mornings on workdays.
X# Unit 14 is the sprinkler.
Xx10 schedule m2,7,14 normal sun 7:15 on
Xx10 schedule m14 normal sun 8:15 off
Xx10 schedule m2,7 normal sun 8:45 off
X
Xx10 schedule m2,7,14 normal mon 6:30 on
Xx10 schedule m14 normal mon 7:30 off
Xx10 schedule m2,7 normal mon 8:00 off
X
Xx10 schedule m2,7,14 normal tue 6:30 on
Xx10 schedule m14 normal tue 7:30 off
Xx10 schedule m2,7 normal tue 8:00 off
X
Xx10 schedule m2,7,14 normal wed 6:30 on
Xx10 schedule m14 normal wed 7:30 off
Xx10 schedule m2,7 normal wed 8:00 off
X
Xx10 schedule m2,7,14 normal thu 6:30 on
Xx10 schedule m14 normal thu 7:30 off
Xx10 schedule m2,7 normal thu 8:00 off
X
Xx10 schedule m2,7,14 normal fri 6:30 on
Xx10 schedule m14 normal fri 7:30 off
Xx10 schedule m2,7 normal fri 8:00 off
X
Xx10 schedule m14 normal sat 6:30 on
Xx10 schedule m14 normal sat 7:30 off
X
X# Turn on the living room light(s) at random in the evening for effect.
Xx10 schedule m1 security sun 18:30 on
Xx10 schedule m1 security sun 22:30 off
Xx10 schedule m1 security mon 18:00 on
Xx10 schedule m1 security mon 22:30 off
Xx10 schedule m1 security tue 18:00 on
Xx10 schedule m1 security tue 22:00 off
Xx10 schedule m1 security wed 18:00 on
Xx10 schedule m1 security wed 22:00 off
Xx10 schedule m1 security thu 18:30 on
Xx10 schedule m1 security thu 22:30 off
Xx10 schedule m1 security fri 18:30 on
Xx10 schedule m1 security fri 22:30 off
Xx10 schedule m1 security sat 18:30 on
Xx10 schedule m1 security sat 22:30 off
X
SHAR_EOF
chmod 0755 x10/schedules/normal.pdt ||
echo 'restore of x10/schedules/normal.pdt failed'
Wc_c="`wc -c < 'x10/schedules/normal.pdt'`"
test 1503 -eq "$Wc_c" ||
echo 'x10/schedules/normal.pdt: original size 1503, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= x10/normal.events ==============
if test -f 'x10/normal.events' -a X"$1" != X"-c"; then
echo 'x - skipping x10/normal.events (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting x10/normal.events (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'x10/normal.events' &&
X EVENT STATE MODE DAYS TIME UNITS
X 0 On Normal Sunday 7:30 m1-2,8
X 1 On Normal Monday 5:30 m1-2,8
X 2 On Normal Tuesday 5:30 m1-2,8
X 3 On Normal Wednesday 5:30 m1-2,8
X 4 On Normal Thursday 5:30 m1-2,8
X 5 On Normal Everyday 23:00 m16
X 6 On Normal Sunday 8:30 m16
X 7 On Normal Monday 7:30 m16
X 8 On Normal Monday 1:30 m16
X 9 On Normal Tuesday 7:30 m16
X 10 On Normal Tuesday 1:30 m16
X 11 On Normal Wednesday 7:30 m16
X 12 On Normal Wednesday 1:30 m16
X 13 On Normal Thursday 7:30 m16
X 14 On Normal Thursday 1:30 m16
X 15 Off Normal Sunday 7:00 m16
X 16 Off Normal Sunday 12:00 m16
X 17 Off Normal Monday 5:00 m16
X 18 Off Normal Monday 11:30 m16
X 19 Off Normal Monday 5:30 m16
X 20 Off Normal Tuesday 5:00 m16
X 21 Off Normal Tuesday 11:30 m16
X 22 Off Normal Tuesday 5:30 m16
X 23 Off Normal Wednesday 5:00 m16
X 24 Off Normal Wednesday 11:30 m16
X 25 Off Normal Wednesday 5:30 m16
X 26 Off Normal Thursday 5:00 m16
X 27 Off Normal Thursday 11:30 m16
X 28 Off Normal Thursday 5:30 m16
X 29 Off Normal Friday 9:00 m16
X 30 Off Normal Saturday 9:00 m16
SHAR_EOF
chmod 0644 x10/normal.events ||
echo 'restore of x10/normal.events failed'
Wc_c="`wc -c < 'x10/normal.events'`"
test 1809 -eq "$Wc_c" ||
echo 'x10/normal.events: original size 1809, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
rm -f _shar_seq_.tmp
echo You have unpacked the last part
exit 0
--
Internet: <t...@mdd.comm.mot.com> | Tim Rosmus (Sys Analyst)
Motorola-X400-ID: <ctr...@email.mot.com> | Motorola - Wireless Data Group
UUCP: <....uunet!mdisea!tim> | 19807 North Creek Parkway
FAX: < 206 - 487 - 5800 > | Bothell, WA USA (206) 487-5928
0 new messages