x10d.c (c) Copyright Daniel D. Lanciani 1995-1999 All rights reserved.
x10d.c is licensed free of charge for personal and internal business use only. x10d.c may not be distributed for profit, nor may it be included in products or otherwise distributed by commercial entities to their clients or customers without the prior written permission of the author.
TO THE E XTENT ALLOWED BY APPLICABLE LAW, x10d.c IS PROVIDED "AS IS", WITH NO EXPRESS OR IMPLIED WARRANTY, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL THE AUTHOR BE LIABLE FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE x10d.c EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
These copyright, license, and disclaimer notices must be included with all copies of x10d.c. Modified versions of x10d.c must be marked as such.
To start with this package is an interface between Linux and the CM11 for X10 communications. It should work under other Unix OS's but may require some modifications to one of more files. I don't have a better name for it so it has been named X10D. I'm not sure what Dan Lanciani calls it. Dan is the original author, www.danlan.com. These modifications are not supported by Dan. Any questions should either be posted to comp.home.automation but would be best sent via email directly to me (firstname.lastname@example.org). I'm going to include Dan's original header and it mostly applies to my modifications too.
To compile x10d you can either use the Makefile include or type:gcc -O2 -o x10d x10d.c -lbsd
I'm assuming that you have successfully compiled the software. Now copy the x10d executable into any directory you wish, I recommend /usr/local/sbin . If you want to have x10d start up when you boot you're system modify the appropriate rc file (rc.local or add a file to the rc directory for run level 3 if you are using SysVinit). Just give it the full path to x10d.
Now create the directory /usr/local/lib/hcs and create the files x10d.access and x10d.log.
x10d.log is a log file that contains information about Extended commands. For most users this file is probably not very important.
The file x10d.access is important, it's the access list. You can allow certain machines a connection to the x10d. Here is a sample from my machine:127.0.0.1 127.0.0.1 192.168.24.0 192.168.24.0
The first line allows a specific host (127.0.0.1 or local on most machines) to connect. The second line permit all machines on the 192.168.24.0 network to connect to the port. All other machines will denied a connection to the x10d. If you do not have an x10d.access file then any machine is allowed to connect.
Now it's time for you to modify /etc/services, your services file will look something like this at the end of the file (this is just an example):# # Unofficial but necessary (for NetBSD) services # supfilesrv 871/tcp # SUP server supfiledbg 1127/tcp # SUP debugging
The number 1127 in the last line is the important number that we need. In your file that number may differ, in fact the last line may look entirely different. The most important part of that line is the number (which is the socket number). Open the /etc/services file with your favorite editor. add the following line to the very end of the file:hamx10 1128/tcp # Used by Dan's original x10d
The above line is the default service name used by x10d. The 1128 is just one more than the previous last line from /etc/services. From the man page on services (man services) we have the following:
Each line describes one service, and is of the form:service-name port/protocol [aliases ...] where: service-name is the friendly name the service is known by and looked up under. It is case sensitive. Often, the client program is named after the service- name. port is the port number (in decimal) to use for this service. protocol is the type of protocol to be used. This field should match an entry in the protocols(5) file. Typical values include tcp and udp. aliases is an optional space or tab separated list of other names for this service (but see the BUGS section below). Again, the names are case sensi- tive.
Note: x10talk requires that you have netpipes installed and working on your machine. Netpipes can be d/l'd from ftp://ftp.purplefrog.com/pub/netpipes/
To install X10Talk copy x10talk.sh into a directory in the users path. A suggestion is /usr/local/bin. Then cd to that directory and perform the following commands:ln -sf x10talk.sh on ln -sf x10talk.sh off ln -sf x10talk.sh bright ln -sf x10talk.sh dim
I have an X10 thermostat so the following commands have been added:ln -sf x10talk.sh setback ln -sf x10talk.sh setforward
Create a local users file called .x10alias, it's format is as follows:# .x10alias # This file contains one column of aliases followed by a TAB and # a second column of device codes, a third column may be added but # must start with a # sign and be separated by a TAB # tv a16 # TV set in the computer room dl c1 # Desklamp used for testing (Computer room) xmas a15 # Christmas lights around the house hutch a2 # The tv hutch in the living room therm c16 # Computer room themostat
The above is my home .x10alias file and is just a sample. The is one very important note! Each column is seperated by a TAB! Do not use spaces and I wouldn't recommend using more that 1 TAB!
Once started up in the rc the following applies:
(Excerpt from one of Dan's original messages about x10d)>The daemon does not do any scheduling or the like; it simply >accepts commands from multiple clients in a standardized format >and delivers received X10 messages to those clients (unless they >disable this with the "Q" command). Assuming you have the daemon >running on its standard port (which I label as "hamx10" in >/etc/services), you can telnet to it thus: > telnet <host running x10d> hamx10 >and issue command lines consisting of house code letters followed >by numeric X10 functions. You can see the function table in the >source and some named functions (ON, OFF, DIM, BRI, ALLLIGHTSON, >ALLUNITSOFF) are accepted for convenience. A sample command >might be: > A1AON >to turn on module A1. Your own commands will be echoed back >(along with any received commands) unless you use the "Q" command >toggle.
That pretty much sums it up for the interface to the tcp connection, except that to quit the connection you need to type ^]q and enter (that ^] is the key sequence Ctrl key and the ] key simultaneously, followed by the q key the the Enter key).
X10Talk is a shell script originally written by James Derrick, I modified part of it's behaviour, but it's really still mostly James' code. You will need the netpipes packages (use a search engine and search for netpipes).To turn on x10 device a1 type: on a1 To turn off p13 type: off p13
Through the usage of the .x10alias file you can create aliases for various x10 devices. For example, if you have a tv defined in the alias file then the following command should work:on tv
The following commands are supported on, off, dim, bright, setback, and setforward. The device number may be from a1 to p16.
Currently there is no real error checking on the shell script. But the x10d will basically not do much if you send it invalid commands. Later I'll probably sit down and rewrite the shell script in C. This will permit a few more options and better error checking.
Any bugs found in any of the documentation or the code should be forwarded to me and I'll attempt to fix them in a timely fashion. Please keep in mind that this package is not my primary concern, my family, employment and education are.
Neil Cherry (email@example.com)
Obviously there is work to be done but here are a few things I need to work on soon:
- Better document the whole application package.
- Document the grouping side effect of the x10talk.sh shell script. Yes you can group like house codes together in the aliases file.
- Add info about Karl Denninger's HomeDaemon software. This software provides xtend like functionality, it works very nicely!
- Add in the extended command support, the status command, the All X commands and anything else missing from X10talk.sh
- Get the add on in the code for X10d. I'm adding command line options and a few other things.