Home automation interface possible? (as mod)


I currently use X10 protocol to control my home lights. I have a web interface set up using mochad which works really well. Unfortunately this means I need to have a server running all the time so that I can use this :(. I used to use the server for network storage as well, but since making the mods to my Humax I can now use that instead :). With the web interface already running I guess that it must be possible (at least in theory) to do the control from my Humax (HD)?

Is this possible?
What would I need to try to get this up and running? My guess would be that I would need to compile mochad on the Humax, first ensuring that all the dependencies are there (I think the main ones are libusb-1.0-0-dev and netcat)?

I realise that this is pretty niche and won't be of interest to many people (and also that I'll need my box powered on for it to work), but any suggestions on how I could go about experimenting with this would be appreciated!
Good luck with this, but my main beef with X10 is the lack of a status back-channel. Unfortunately there doesn't seem to be anything better.
You could either cross compile it on another Linux box or compile it natively on the HDR. I think the latter option should be easier. To do this just install the packages 'gcc' and 'header-files' (they are quite large). There is also 'uclibc-devel' but I don't think you will need this.
Black Hole - agreed X10 is far from perfect but I haven't found much in the way of decent alternatives!

xyz321 - thanks for the suggestions, here is what I've tried so far:

installed all the packages noted above via the web interface along with ssh
ssh'ed into the humax (mine is an HD box) with the user:root and password:humax
copied the source onto the box and unzipped it (I used samba for this as it was easier)
./configure in the source folder (I needed to change the permissions on configure to make it executable - not sure why this was necessary?)
make in the source folder - it failed due to not having libusb with the error:

mochad.c:71:31: fatal error: libusb-1.0/libusb.h: No such file or directory
compilation terminated.
make: *** [mochad.o] Error 1
in the configure output I also got the following "no" lines:

checking for library containing libusb_init... no

checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
I guess that either uclibc-devel should replace libusb or I need compile libusb for the humax first?
Any further ideas?
OK I tried downloading the latest version of libusb here:

and configured and built

./configure --build=arm-linux --prefix=/media/drive1/mod

make install

I had to change permissions on libusb-1.0.8/install-sh to make it executable, but otherwise it seems to have worked?!

the header file libusb.h has appeared in /media/drive1/mod/usr/include/libusb-1.0/
this contains all the stuff that mochad seems to need, but I'm still getting the "no" lines in the configure output?

Any ideas why it's not finding the libusb.h header file?
EDIT: Actually it does seem to be finding the header file (if I change the name it gives a different error!) but I can't seem to get the examples for libusb to run so maybe that's not installed correctly?
Perhaps I need to specify a different --build target?
OK I tried downloading the latest version of libusb here:

and configured and built
Yes, you will need to compile and install libusb - it is not installed by the Humax firmware.

./configure --build=arm-linux --prefix=/media/drive1/mod

make install
The HD/HDR uses the build target 'mipsel-linux'. You shouldn't really need to specify the build target to configure if you are compiling on the box.
This looks like you are compiling on an HD, if this is the case then I think there should be a symlink from /mod to /media/drive1. To make it portable I would use a prefix of /mod so that it would also work on the HDR. You may need to hack the source so that it looks for any config files in the /mod tree (probably not relevant to libusb).
Yes I'm compiling on an HD.
I hadn't noticed the /mod symlink - I'll use that instead!
I initially tried it without specifying a target and it complained:
checking build system type... ./config.guess: unable to guess system type

hence me guessing at the build target!

I've now recompiled using:
./configure --build=mipsel-linux --prefix=/mod
make install
it does give the following warning:

libtool: install: warning: remember to run `libtool --finish /usr/local/lib'
test -z "/mod/include/libusb-1.0" || .././install-sh -c -d "/mod/include/libusb-1.0"
I'm not sure if that is important though
I'm still getting the same issue when I come to configure mochad though so I guess it's not finding a functional libusb for some reason.
I'll try to get into the source when I find more free time...
Thanks for your help so far!
I'm not really sure why that doesn't work for you. I tried compiling it using a cross-compiler and it seemed to be fine. I could package up libusb and send it to you if you wish.

I notice that mochad uses hotplug2. You may have to hack the /etc/mdev/run-and-gun script to include the contents of the mochad '20-usb-x10' file. Note that the pvr uses mdev to control the hotplugging operation (athough the actual mounting of the disks seems to be performed by the humax application). The files in /etc are stored in flash memory so to replace them you would have to build a new flash image. An easier way might be to relocate these scripts within the /mod tree.
This is probably a daft question but is it possible to lift the Humax Linux image and run it in a vmware partition? If so all development and compiling could be done in the virtual environment and then the finished compiled program copied to the Humax. Obviously the TV recorder software would have to be disabled because the hardware would not be present but for your testing with the web server and mochad I would have thought it would work.
Off the top of my head I think it is a daft question - a virtual machine such as VMware, MSVM, Virtualbox simulates PC hardware not Humax hardware. The Humax Linux will have been compiled to suit the limitations of the Humax physical implementation.
No such thing as a daft question, only daft answers. VMWare does not support the mips architecture. Other Humax operating systems have been virtualised in the past using QEMU, which does, but not running the settop binary which requires Humax hardware. This environment does not lend itself to development work. All current development is made in userland and compilation can be done either on-the-box, or cross-compiled on another linux system. There would be no advantage in attempting to do what you suggest.
Sorry, been a bit busy with other stuff for the last month. If the offer of a cross compiled libusb is still available it would be good to give that a try.

I'll also look at the run-and-gun script script when I get the chance.

OK, here is libusb, libusb-devel and mochad. I think libusb should be OK but when I try to run mochad, without anything connected, top shows 50% CPU usage (i.e. 100% of one of the cores).

The mochad binary is started from /mod/etc/init.d. You may wish to look at hotplug. Since your last message the mdev run-and-gun script has been updated in the latest mod firmware. This added hooks to allow scripts in /mod/etc/mdev to initialise hotplugged devices. For an example see the ntfs-3g package which uses this mechanism to remount ntfs disks. I am not sure whether this will work with a generic usb device. You may need to modify /etc/mdev.conf to look for a generic device but I can't see any obvious support mechanism within the busybox mdev.

[af123: If you want to add libusb to the repository then that's probably fine but mochad is still very much work in progress]


  • libusb.zip
    170.5 KB · Views: 1
  • mochad.zip
    17 KB · Views: 1
Excellent, thanks for that. They all seem to have installed, but like you I'm seeing mochad using 50% CPU.
After some brief testing it's currently failing as the humax IP is refusing netcat connections, but I'll try to look at it a bit further.
Just done some more testing. Mochad seems to be hanging on a call to libusb_init. I guess this is why it's using a whole CPU core?
I can't see anything mdev related in my /mod/etc folder - I think this is because I'm running on an HD rather than an HDR?