Author Topic: Questions on ZWave source code  (Read 46491 times)

kinman

  • Regular Poster
  • **
  • Posts: 23
    • View Profile
Questions on ZWave source code
« on: December 21, 2007, 06:18:08 am »
Dear all, I have looked at the ZWave source code (LinuxMCE-1.1-SRC/src/ZWave) and I have some questions:
- Is there any document such as command reference or programming guide for the ZWave computer interface?
- What is the difference between asynchronize and synchronize mode?
- In my understanding, the ZWave computer interface seems to be a passive device, the software send a command to and then wait for response from it. How the software receive PIR events/triggers from the computer interface?

cheers /kin

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Questions on ZWave source code
« Reply #1 on: December 21, 2007, 06:40:27 am »
The design for the Z-wave code has an interface that communicates with the DCE router (Zwave.cpp), and inserts Zwave jobs into a queue.  This queue is read by the low-level Z-wave interface PlutoZWSerialApi(.h,.cpp), which handles the low-level communication with the Zwave transciever.

Asynchronous mode creates threads that run this process asynchronously, with the DCE interface adding jobs to the queue and the Z-wave interface removing them as quickly as it can.  The threads are synchronized via mutexs in order to keep things in line.
Synchronous mode has the DCE interface send commands directly to the Z-wave interface.

SerialConnection.* is a layer over the serial communication which takes care about the general protocol specification like communication parameters, the start of every message, the checksum algorithm etc.

The Zwave computer interface is a bi-directional serial device, so when it receives notifications from other devices, it can pass them on to the PC.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Questions on ZWave source code
« Reply #2 on: December 21, 2007, 08:01:36 am »
Is the ZWave driver bidirectional?  I was under the impression it wasn't..

If so, HOW do they set the device state?!?!?!?!? (I can only find events ON/OFF to fire )
:)
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Questions on ZWave source code
« Reply #3 on: December 21, 2007, 08:48:45 am »
Currently, it only fires PIR sensor commands.  It doesn't feed back light states, though a lot of the polling code is in there.  I'll poke back around in it this weekend and see if there are any more clues in there.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Questions on ZWave source code
« Reply #4 on: December 21, 2007, 09:03:25 am »
Thanks Pete, I started another thread where I found where the state is saved in the database...
but I really don't want to modify the database if I don't have to..
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

kinman

  • Regular Poster
  • **
  • Posts: 23
    • View Profile
Re: Questions on ZWave source code
« Reply #5 on: December 21, 2007, 10:09:43 am »
Thank you Pete. It seems the programming document for ZWave interface is only for hardware and software vendors internal use. Otherwise I have to reverse engineering the LinuxMCE-1.1-SRC/src/ZWave.

Can I say that asynchronous mode is multi-thread? synchronous mode is single-thread and the commands/responses are sent/received sequencially?

Can I treat the ZWave computer interface as a Hayes modem? Send "AT" command and wait for "OK". Except that PIR events will be received without sending command.

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Questions on ZWave source code
« Reply #6 on: December 21, 2007, 05:23:54 pm »
You are exactly correct in that the asynchronous mode is multi-threaded.  The synchronous mode is single-threaded.  As for treating the interface as a modem, I'm not exactly sure what you mean.  When you send an ON/OFF command, it sends that command to the transciever, then waits for a reply or a timeout, and passes that information back.

Unfortunately, Zensys charges a lot for the dev. kit and access to the protocol documentation.  The Pluto guys may have the latest versions, and depending on the licensing, may be able to release them.

kinman

  • Regular Poster
  • **
  • Posts: 23
    • View Profile
Re: Questions on ZWave source code
« Reply #7 on: December 21, 2007, 06:55:33 pm »
I got it Pete! I find those commercial software for ZWave are lack of flexibility. MrHouse has limited support for ZWave. It seems the ultimate solution is Pluto/LinuxMCE. Instead of looking for document and source code, I better learn how to program on the DCE platform.

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Questions on ZWave source code
« Reply #8 on: December 21, 2007, 07:12:41 pm »
Sounds good.  Let me know how I can help.  The more automation options the better.  There's been rumor of updated Zwave support in this new release, but I haven't heard anything for sure.  The current Zwave implementation only supports a few, out of production adapters, so there is a strong need to update it to support modern adapters with the current Zwave protocol.

totallymaxed

  • LinuxMCE God
  • ****
  • Posts: 4660
  • Smart Home Consulting
    • View Profile
    • Dianemo - at home with technology
Re: Questions on ZWave source code
« Reply #9 on: December 21, 2007, 09:39:00 pm »
Sounds good.  Let me know how I can help.  The more automation options the better.  There's been rumor of updated Zwave support in this new release, but I haven't heard anything for sure.  The current Zwave implementation only supports a few, out of production adapters, so there is a strong need to update it to support modern adapters with the current Zwave protocol.

Hmmm... well I may have been the source for that little rumour. Unfortunately the main Z-wave engineer at Pluto has recently moved on to another company so this has not happened!

Please send me a private message as I might be able to help you on the tech documentation etc etc.

Merry Christmas

Andrew
Andy Herron,
CHT Ltd

For Dianemo/LinuxMCE consulting advice;
@herron on Twitter, totallymaxed+inquiries@gmail.com via email or PM me here.

Get Dianemo-Rpi2 ARM Licenses http://forum.linuxmce.org/index.php?topic=14026.0

Get RaspSqueeze-CEC or Raspbmc-CEC for Dianemo/LinuxMCE: http://wp.me/P4KgIc-5P

Facebook: https://www.facebook.com/pages/Dianemo-Home-Automation/226019387454465

http://www.dianemo.co.uk

PeteK

  • Guru
  • ****
  • Posts: 408
    • View Profile
Re: Questions on ZWave source code
« Reply #10 on: December 21, 2007, 09:44:19 pm »
Not Eugen?

totallymaxed

  • LinuxMCE God
  • ****
  • Posts: 4660
  • Smart Home Consulting
    • View Profile
    • Dianemo - at home with technology
Re: Questions on ZWave source code
« Reply #11 on: December 21, 2007, 09:56:46 pm »
Andy Herron,
CHT Ltd

For Dianemo/LinuxMCE consulting advice;
@herron on Twitter, totallymaxed+inquiries@gmail.com via email or PM me here.

Get Dianemo-Rpi2 ARM Licenses http://forum.linuxmce.org/index.php?topic=14026.0

Get RaspSqueeze-CEC or Raspbmc-CEC for Dianemo/LinuxMCE: http://wp.me/P4KgIc-5P

Facebook: https://www.facebook.com/pages/Dianemo-Home-Automation/226019387454465

http://www.dianemo.co.uk

kinman

  • Regular Poster
  • **
  • Posts: 23
    • View Profile
Re: Questions on ZWave source code
« Reply #12 on: December 22, 2007, 10:38:23 am »
I find Pete is the new author :D

// Author: PeteK <pete.k@plutohome.com>, (C) 2007

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Questions on ZWave source code
« Reply #13 on: December 22, 2007, 10:51:27 am »
Kinman,

I'm integrating the Insteon PLM using GSD/Ruby.. and I'm almost done.
I've learned quite a bit of 'tricks'...
if your serious about zwave integration via gsd, keep in touch with Pete and myself...
I wonder if the pluto team would 'lend' the devkit out...
ahh well, lemme finish the Insteon, then worry about the zwave...

Regards,
Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

kinman

  • Regular Poster
  • **
  • Posts: 23
    • View Profile
Re: Questions on ZWave source code
« Reply #14 on: December 24, 2007, 04:14:38 am »
Hi Dan/Pete, I am interesting in ZWave using GSD: LinuxMCE-1.1-SRC/src/Generic_Serial_Device/Embedded Devices/*/Ruby/ do you mean we can just work on *.rb no need *.cpp/*.h? Because I am familiar on Perl and afraid of thousand lines of C codes.

cheers/kin

« Last Edit: December 24, 2007, 04:55:34 am by kinman »