Please login or register.

Login with username, password and session length
Advanced search  

News:

The New WIFI Module is now available!
                   *****Here's the link******

Pages: [1] 2 3 ... 5

Author Topic: mochad, X10 CM15A/CM19A Linux device driver  (Read 99164 times)

mmauka

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 41
mochad, X10 CM15A/CM19A Linux device driver
« on: December 10, 2010, 12:55:50 AM »

mochad is a Linux TCP gateway daemon for the X10 CM15A RF (radio frequency) and PL (power line) controller and the CM19A RF controller.

mochad stands for Multiple Online Controllers for Home Automation Daemon. Pronouce like mocha-d, not mo-chad.

mochad is now on sourceforge.net.

    http://sourceforge.net/projects/mochad

Many things are To Be Done but it works on Ubuntu 10.04 and 10.10 and three OpenWrt devices: LinkSys NSLU2 (very old), Seagate DockStar, and Buffalo WZR-HP-G300NH WiFi router. However, details on building for OpenWrt are not in the README yet. TBD is creating a package for easier building and installation.

See the README for more details on which X10 modules are known to work with mochad.

mochad is not a full home automation program. It is a device driver with TCP socket interface. mochad is implemented using libusb-1.0 so is not a Linux kernel device driver.

Post questions or comments here or on the sourceforge discussion page.
Logged

pconroy

  • Hero Member
  • *****
  • Helpful Post Rating: 9
  • Posts: 294
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #1 on: December 10, 2010, 09:56:26 PM »

I'm lost.

Does mochad control the CM15A and CM19A?
thx
Logged

mmauka

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 41
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #2 on: December 10, 2010, 10:38:35 PM »

I'm lost.

Does mochad control the CM15A and CM19A?
thx

Sorry, yes. mochad runs in the background and controls the CM15A and CM19A. mochad accepts TCP connections on port 1099 so client programs such as netcat can send RF/PL commands to mochad and receive RF/PL events from mochad.

I expanded the README into a Wikipage <http://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page>. This is clearer than my late night posting.

I forgot to add mochad supports RF camera events/commands as well.

RFCAM <camera command>

where <camera command> is one of the following:

CAMUP CAMDOWN CAMLEFT CAMRIGHT CAMCENTER CAMSWEEP CAMPRESET1 CAMPRESET2
CAMPRESET3 CAMPRESET4 CAMPRESET5 CAMPRESET6 CAMPRESET7 CAMPRESET8 CAMPRESET9
CAMEDITPRESET1 CAMEDITPRESET2 CAMEDITPRESET3 CAMEDITPRESET4 CAMEDITPRESET5
CAMEDITPRESET6 CAMEDITPRESET7 CAMEDITPRESET8 CAMEDITPRESET9

I do not own any X10 cameras so this is based on examining USB packets generated by AHP when clicking buttons in the virtual remote control pad for the VK7X module. I am interested in hearing if this actually works.

Logged

pconroy

  • Hero Member
  • *****
  • Helpful Post Rating: 9
  • Posts: 294
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #3 on: December 11, 2010, 08:05:43 PM »

Way cool!

Did you reverse engineer the CM15A protocol????

Logged

mmauka

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 41
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #4 on: December 11, 2010, 09:25:20 PM »

I did reverse engineer but with a lot of help from existing X10 protocol documentation listed in the README file and from USB Snoopy. USB Snoopy is an open source Windows USB sniffer.

Macros and timers are too complex so they are not supported. Looks like there are some similarities to the CM11A but there are too many differences for me to figure out.

The standard X10 PL, X10 RF, and X10 RF security packets should all work. The X10 camera commands are incomplete.

To Do list

Hotplug support so mochad runs when a CM15A/CM19A is plugged in. Currently, the controller must be plugged in when the mochad starts. If not, mochad bails out with a warning message in /var/log/messages.

Use GNU autotools/automake because most packaging tools require them.

Create Ubuntu and OpenWrt packages for easier installation.
Logged

Brandt

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 722
  • Sorry miss, I was giving myself an oil-job.
    • Nerd Stuff - Programming, Electronics, Mechanics
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #5 on: December 11, 2010, 10:13:25 PM »

what does TCP have to do with anything?
Logged
Nerd Stuff - Programming, Electronics, Mechanics

domus.Link PHP Frontend for Heyu

Linux, Heyu, and CM11a on a Sheevaplug
http://forum.heyu.org/ - http://wiki.heyu.org/


Wishlist: AB8SS, ISY-99i, RFXCOM, Oregon Sensors
Owner: Rain8II, RCS TXB16, Switchlincs, w800usb, XTBM, XTB-IIR

mmauka

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 41
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #6 on: December 12, 2010, 12:45:43 AM »

TCP is the way applications communicate with mochad and the CM15A/CM19A. I have not used heyu or misterhouse but I was thinking they might be able to use mochad as a backend device driver by opening a TCP socket to it.
Logged

Brandt

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 722
  • Sorry miss, I was giving myself an oil-job.
    • Nerd Stuff - Programming, Electronics, Mechanics
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #7 on: December 12, 2010, 02:10:27 AM »

well you could join the heyu_users email list and post about it and see what people have to say
Logged
Nerd Stuff - Programming, Electronics, Mechanics

domus.Link PHP Frontend for Heyu

Linux, Heyu, and CM11a on a Sheevaplug
http://forum.heyu.org/ - http://wiki.heyu.org/


Wishlist: AB8SS, ISY-99i, RFXCOM, Oregon Sensors
Owner: Rain8II, RCS TXB16, Switchlincs, w800usb, XTBM, XTB-IIR

mmauka

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 41
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #8 on: December 12, 2010, 03:46:23 PM »

mochad is still a work in progress and I am writing my own HA app using mochad with more than one controller. Using more than one controller is the original, and still the primary, reason for the network interface. If I had more time I would get involved in other projects but it is not possible right now.
Logged

coolguy1233457

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 10
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #9 on: December 20, 2010, 01:03:58 PM »

Hi there !!

First, thank you so much for your work, very appreciated...

I was using heyu for it's CM17A (firecracker) support to send commands to my CM15A.

Now, with mochad, I can get rid of the CM17A and have a look at the CM15A transmitted and received x10
commands.

But ...

I have a question, the dim and bright commands (of a normal lamp module) do not behave like with
heyu.  Can you give an explanation of what is the number 0..31 that we give ?  With heyu, that was the number
of dim or bright steps (steps of 6% with a CM15A) sent to the device. 

Also, an interesting feature to add would be adding a feature that would watch for certain command or
logs to launch a user defined script.  I think I'll do that my way, but when the daemon starts, it
would be interesting to have a log file (and not having to log with netstat).

Will you develop mochad actively ??? what's on your todo list ?

Thanks again
Logged

mmauka

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 41
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #10 on: December 20, 2010, 05:58:33 PM »

I'm glad to hear it is working for you.

There are two dim commands.

pl a1 dim 0..31     sends the dim command for older lamp modules

This only works with older lamp modules. I am fairly new to X10 so my gear has
been purchased in the last couple of years so none of my lamp modules
understand this command.

As far as I can tell, 0..31 is the number of steps to dim or brighten. The way
to make it go to 50% dim is to first turn the lamp on to full brightness then
send a dim 15. But this is just a guess because I have no way to test this.

pl a1 xdim 0..63    sends the extended pre-set dim

If you have newer lamp modules (LM465) with soft-start, the xdim command is
required. 0..63 is the absolute intensity level so for 50% send 32, 75% send
48, etc. 63 is a special value that means go to maximum intensity instantly.
62 is the maximum intensity with soft-start.

The value can range from 0..255 according to the X10 specification but the
LM465 ignores the higher values. The upper two bits are supposed to control the
rate at which the intensity changes (faster or slower) but the LM465 is not
affected.

I like the idea of mochad write a log file. I usually do something like this
"nc localhost 1099 >logfile.txt &" but it is one extra step.

At least for the moment, mochad is more like an SDK than a full HA application
like heyu or misterhouse. It is fairly easy to use Perl as a scripting language
to implement your own HA app. Any language that can connect to a TCP socket can
be used.

For example, bash has a socket programming API so shell programmers can connect
to mochad directly. It is "merely" a matter of examining ASCII text strings for
the desired events. This is simple enough for a single device but will get
complex if you have a house full of various kinds of modules. But the minimum
amount of code to create a useful HA app is quite small. BTW, flite is a small
text-to-speech command line program.

#!/bin/bash
#This bash program connects to mochad then scans for alert/normal events from
#a specific DS10A. The lamp or appliance module M1 is turned on
#for alerts and off for normal. Assuming flite is installed, voice prompts
#should also be heard.
#Sample event generated by mochad for a DS10A
#12/20 11:53:58 Rx RFSEC Addr: EF:43:80 Func: Contact_alert_min_low_DS10A

# Connect TCP socket to 192.168.1.254 port 1099 on handle 6.
exec 6<>/dev/tcp/192.168.1.254/1099

# RF devices send the same event multiple times so to avoid multiple
# PL commands and voice prompts, keep track of the device state.
ds10state="unknown"

while read <&6
do
    # Show the line on standard output just for debugging.
    echo $REPLY >&1
    case $REPLY in
        *Rx\ RFSEC\ Addr:\ EF:43:80*alert*)
        if [ "$ds10state" != "alert" ]
        then
                echo "pl m1 on" >&6
                flite -t "Door open"
                ds10state="alert"
        fi
        ;;
        *Rx\ RFSEC\ Addr:\ EF:43:80*normal*)
            if [ "$ds10state" != "normal" ]
            then
                echo "pl m1 off" >&6
                flite -t "Door closed"
                ds10state="normal"
            fi
        ;;
    esac
done

Logged

coolguy1233457

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 10
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #11 on: December 21, 2010, 09:33:43 AM »

hello,

Have you really tested the dim and xdim with a lamp module ?
I have LM465 modules, and I've bought very recently, probably they're the newer model.

xdim doesn't work at all, does nothing (I could post the nc output, if you want).
dim doesn't work at all like you say... i really don't understand how it works...
it doesn't seem to be at % of the max intensity

with heyu, the dim command was really a small step in increasing or decreasing the
intensity of about 6%, and it worked fine.   I am not sure there was a way
to tell the module to directly go to 50% or 75% of the max intensity.
In fact, if possible, both ways of controlling the intensity are
interesting... depending on the application !

are you able to test it out ?

the on and off commands are working fine thought...

yes, redirecting the nc output was what I was doing (a line I added to rc.local or rc.start)
but why not use a init script with the syslog facility ?
and I was thinking of something like your bash script to keep an eye on events
and exec some scripts... 

give me news as soon as you "put some light" on the dim/bright commands ;-)
« Last Edit: December 21, 2010, 09:35:26 AM by coolguy1233457 »
Logged

Brian H

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 288
  • Posts: 12514
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #12 on: December 21, 2010, 09:40:46 AM »

Unless X10 has changed things again.
All my recent LM465s with soft start will not dim to 0%. The lowest I have gotten is about an estimated 20%.
Logged

coolguy1233457

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 10
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #13 on: December 21, 2010, 11:52:20 AM »

well maybe, but whatever the number I put in the command
pl a1 dim 0..31
it gets to minimum intensity (almost off).

Logged

Brian H

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 288
  • Posts: 12514
Re: mochad, X10 CM15A/CM19A Linux device driver
« Reply #14 on: December 21, 2010, 12:38:35 PM »

Could be. I only used the standard dim and not extended dim commands in my tests.
Are they soft start?
Logged
Pages: [1] 2 3 ... 5
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.