X10 Home Control System

In the process of tidying up the loft I came across some X10 Home Control equipment and wondered if it would be usable under FreeBSD... I did find some posts from 1995 which suggested it was supported at one point. Just wondered if anyone had used it more recently.

Before I delve any further I'll need to find a way of attaching a serial port since they seem to have disappeared from PCs a while back. So the next question arises... Does FreeBSD provide support for a USB Serial port?
 
Yes, various USB to serial adapters work. I have used PL2303, CH340, CP2102, and even that other brand that used to be good until the company got nasty.
 
A year later...

I now have my USB/serial connector. I plug it into my ThinkPad X220, on the console I see:-
Code:
ugen1.4: <vendor 0x1a86 USB2.0-Ser> at usbus1
uchcom0 on uhub2
uchcom0: <vendor 0x1a86 USB2.0-Ser, rev 1.10/2.54, addr4> at usbus1
uchcom0 : CH341 detected

How do I know which comport to use? I presume it is cuaU0... What speed? and what do I type in to cu
to see if there is any life in the X10 control unit?

It's a long time since I last used it, and can't remeber how it was setup and any instructions are long gone.
 
Simple technique: Do a directory listing in /dev before plugging it in, then another after. The new cuaXX that showed up must have been it.

In theory, there should be a more sensible technique, where for each device in the /dev file system you can find out what "upstream" device it is connected to (like disk ada5 is connected to SATA port ata2, or similarly that /dev/cuaU0 is on ugen5.1). If you knew about your server hardware, you can even map where the ports like ata2 or ugen5.1 are physically installed, so you can automatically check the wiring.

I don't know how to do that on FreeBSD, other than by watching dmesg scroll by and taking educated guesses; on Linux it can be done by walking around in the /sys file system, which can even be automated and done programmatically. In a previous job, we used this technique all the way to disk enclosures (through SAS expanders) to verify that the wiring was done correctly.
 
Find the documentation for the X10 controller. Figure out the protocol it wants to speak over the serial wires (starting with pinout, baud rate, software v. hardware flow control). Connect the X10 controller to the serial port (the USB thing). If you are a pessimist, you could now use a voltmeter to make sure the hardware is connected correctly, check the voltage levels on the TxD and RxD pins, and whatever hardware flow control lines are needed. Let's be optimistic, and assume that the hardware just works out of the box (with modern 9-pin connectors, I find that to be true 80% of the time). If the protocol (the character sequences that need to be sent) are halfway suitable for being typed and viewed by a human, then use some terminal emulator program (I'm fond of miniterm.py, but there are many others). Configure it for the correct baudrate and flow control, enter it. Send some command to the device (most devices have a "hallo" or "ping" or "what is your identity and version" command, and look at the output. Often, these protocols are a bit binary, and require stuff like "control T to start the command, and a "*" at the end, no newline". Usually, you can put your terminal emulator program into some mode where your outgoing traffic is echoed, and all the incoming traffic is displayed in hex instead of characters. This allows you to verify that some communication is going on.

Once you are at this point, find your favorite programming language (mine happens to be Python), and download/install/use a serial communications package for it (for me that's pySerial). Write a short program that sends a short command to the device, waits for the reply, and decodes it. Once this works, the rest of the control is a question of patience: Design and write code that sends more and more commands, and decodes more and more responses. Over Christmas I did that for two new serial devices (an Omega PID controller, and a RedLion voltmeter, both with serial ports), and each of those took me two or three hours only.

As you go along, this will get difficult. Most likely the device is slow enough that you'll want your program to do other things while waiting for the serial port delays (9600 baud means ~1ms per character!), and at some point you'll probably want to be able to catch unsolicited (asynchronous) data from the device. Both will mean that your program will become multi-threaded, and that will require locking of the data structures. This is work, but for an experienced software engineer getting a basic communication thing (asynchronous, threaded, locked, with error handling) should take only a few days for a handful of commands and responses. You are not an experienced software engineer yet; when you're done with this project, you will be.
 
Thanks for the detailed description about what I need to do. One of the problems is that the controller (a CM12U) unit is so old that documentation is difficult to get hold of, and I'm not sure if it still actually works. I tried using a voltmeter but it didn't fit in the holes, but after sticking some pins in I managed to get a reading of 0.25V - don't know what I should expect....but seems there may be some sign of life.

As for controlling it I've found some software which is designed for Linux, and it's Perl based so it may well work on FreeBSD.

I even came across some FreeBSD man pages but they don't mention the CM12, just the CM11, but that might work...
 
Having just installed heyu I'm unable to communicate with the X10 controller... This could be because I've specified the wrong com port, or my USB/serial connector doesn't work or the controller is FUBAR.

Any suggestions as to how to test the connector? I'm thinking of digging out my old USR Courier HST modem if all else fails..
 
A serial port should in theory be either +12V or -12V. In practice, modern serial ports tend to run +5 and -5V. A reading of 0.25V on a data pin (not ground) like TxD, RxD, CTS, RTS, or DTR is bad. At least TxD and RxD must never be near ground if both sides are plugged in.

The easiest way to measure it is to solder up or buy an adapter connector, where each individual line is accessible.
 
Back
Top