Please login or register.

Login with username, password and session length

Author Topic: Libusb communication for CM15A, and Java  (Read 9291 times)

legarots

  • Newbie
  • Helpful Post Rating: 1
  • Posts: 9
Libusb communication for CM15A, and Java
« on: March 21, 2009, 12:58:01 PM »

I have libusb working with the CM15A to receive all data communication between the CM15A and my computer. It can see security devices (door/window/motion sensors) and the remote controls.

I couldn't get it to work at first, because I had uninstalled AHP. But after I re-installed AHP with ActiveAlert, then I could start getting all communication, even if those modules aren't in AHP. In fact, AHP is even running while my program is.

I'm on windows, so I'm using libusb-win32. I got it work on both Windows XP and Windows Vista, although Vista is much harder.

Libusb will work with many programming languages. I'm using Java, but it works for c/c++, VB, etc.

In my experience, getting Java to talk to libusb was the easy part. The hard part was getting libusb setup, and then the CM15A working with the libusb driver. I used a wrapper project called "Java libusb-win32". http://libusbjava.sourceforge.net/wp/?page_id=8    That is specific to Java. If you are using another language, you probably only need libusb-win32. See the link for the info on how to get what you need and how to set it up. It involves placing some dlls into c:\windows\system32. It is easier to get working on Windows XP - much harder to get it work on Vista. If you are installing on XP, use the link above. But, very important, if you want to use Vista, then use this installation instead: http://www.fileden.com/files/2006/8/22/180346/LIBUSB64Fix.zip

Once that's installed, you use a script called INF WIZARD to create an inf file for the driver installation for the CM15A device. The CM15A device will show up as "X10 USB ActiveHome (ACPI-Compliant)" Use the control panel -> device manager to change the driver to point to the INF file created by the wizard. Once you do that, the CM15A will work with libusb, but I don't think it will work in AHP anymore. You can switch the driver back and forth using the device manager when you want to use AHP, but I couldn't get AHP and libusb to work at the same time. That's fine for me, because I plan to control everything with my program, so I won't be using AHP.

Once libusb is working, you are now working with the raw byte data between the CM15A and your computer. You'll see data like this for a sensor opening, then closing:
Data: 0x5d 0x29 0x39 0x36 0x00 0xff 0x10 0x80
Data: 0x5d 0x29 0x39 0x36 0x80 0x7f 0x10 0x80

In the data above, 0x5d means RF received. Not sure about 0x29.
0x39 0x36 is the id for the sensor device.
0x00 0xff is command for open max delay, and 0x80 0x7f is the command for close max delay.
Not sure about 0x10 0x80.

You can find some info on the CM15A protocol here:
http://www.linuxha.com/athome/common/cm15d/cm15a.html

DISCLAIMER: I don't take responsibility for any of these programs, links, or what they might do to your computer  :)
Logged

Charles Sullivan

  • Hero Member
  • *****
  • Helpful Post Rating: 94
  • Posts: 1565
    • HEYU - X10 Automation for Linux, Unix, and Mac OSX
Re: Libusb communication for CM15A, and Java
« Reply #1 on: March 21, 2009, 04:01:32 PM »

Comparing the data streams you've posted with similar streams I receive from a DS10A with an RFXCOM RF receiver, I think you'll find they can be interpreted like this:

 Data: 0x5d 0x29 0x39 0x36 0x00 0xff 0x10 0x80
 Data: 0x5d 0x29 0x39 0x36 0x80 0x7f 0x10 0x80

 0x5d  -> AHP specific code - I don't see this.
 0x29  -> Number of significant _bits_ in remainder of stream ( = 41 = 5 bytes + 1 bit )
 0x39  -> Low byte of 16 bit security ID
 0x36  -> '3' = upper nybble of above 0x39; '6' = 1's complement  of lower nybble of above 0x39
 0x00 or 0x80 = data bitmap with bit values as follows:
    0000000  = open
    1000000  = close
    0000100  = MIN delay
    0000001  = Low battery
 0xff or 0x7f = 1's complement of above data bitmap
 0x10 -> High byte of 16 bit security ID
 0x80 -> upper bit is parity bit for above ID high byte.  (this parity bit is NOT reliable - ignore). Remaining 7 bits not used.

Logged
Yesterday it worked.
Today it doesn't work.
X10 on Windows is like that.

HEYU - X10 Automation for Linux, Unix, and Mac OS X     http://www.heyu.org

legarots

  • Newbie
  • Helpful Post Rating: 1
  • Posts: 9
Re: Libusb communication for CM15A, and Java
« Reply #2 on: March 21, 2009, 06:55:52 PM »

Thanks for the clarification on the codes  >!
Logged

jmattioni

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 4
Re: Libusb communication for CM15A, and Java
« Reply #3 on: April 11, 2009, 10:53:35 AM »

Does anyone know how to get the CM15A to send RF commands using libusb driver?

Thanks.
Logged
 

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