Plugwise and Linux

Plugwise Forum about Plugwise devices and the Source software.
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by Snelvuur »

didn't know you had a plugwise set too ron.. i have one also, so first beta tester is here too haha :)

// Erik (binkey.nl)
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Plugwise and Linux

Post by RDNZL »

Yes, have one, I even peeked at the protocol.
I saw some patterns too...

Switching on/off

Code: Select all

563	0.00045077	PlugwisePC.exe	IRP_MJ_WRITE	VCP0	SUCCESS	Length 30: ....0023000D6F000023711FCDB1..	
564	0.00000367	PlugwisePC.exe	IOCTL_SERIAL_WAIT_ON_MASK	VCP0	SUCCESS		
565	0.00000280	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
566	0.07991979	PlugwisePC.exe	IOCTL_SERIAL_WAIT_ON_MASK	VCP0	SUCCESS		
567	0.00000145	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
568	0.00000291	PlugwisePC.exe	IRP_MJ_READ	VCP0	SUCCESS	Length 92: PutFifoUnicast 40 : 000D6F000023711F......000000C1AB92...Inspect	
569	0.00000103	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
570	0.03096140	PlugwisePC.exe	IOCTL_SERIAL_WAIT_ON_MASK	VCP0	SUCCESS		
571	0.00000177	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
572	0.00000073	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
573	0.00000256	PlugwisePC.exe	IRP_MJ_READ	VCP0	SUCCESS	Length 55: emberMessageSentHandler()  ** ClusterId 40 **  Status 0	
574	0.00000306	PlugwisePC.exe	IOCTL_SERIAL_WAIT_ON_MASK	VCP0	SUCCESS		
575	0.00000206	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
576	0.00000087	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
577	7.11877595	PlugwisePC.exe	IOCTL_SERIAL_WAIT_ON_MASK	VCP0	SUCCESS		
578	0.00000261	PlugwisePC.exe	IRP_MJ_READ	VCP0	SUCCESS	Length 125:  **.. ClusterId 40  Success...41 : 000D6F000023711F......0024000	
579	0.00000092	PlugwisePC.exe	IOCTL_SERIAL_GET_COMMSTATUS	VCP0	SUCCESS		
580	0.00079485	PlugwisePC.exe	IRP_MJ_WRITE	VCP0	SUCCESS	Length 30: ....0012000D6F00001C8F32DF40..	
581	0.02195993	PlugwisePC.exe	IOCTL_SERIAL_WAIT_ON_MASK	VCP0	SUCCESS		
Mdamen
Forum Moderator
Forum Moderator
Posts: 390
Joined: Sat Nov 22, 2008 6:58 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by Mdamen »

I've just release a first version of what I call POL (Plugwise On Linux)
It's available here:

http://www.maartendamen.com/node/35

I will post some more details later on... off to bed now... my eyes only see code right now [:)]

Please share your testing experience!

--
Maarten Damen

www.maartendamen.com
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by Snelvuur »

can you also post the ".py" ?

// Erik (binkey.nl)
Mdamen
Forum Moderator
Forum Moderator
Posts: 390
Joined: Sat Nov 22, 2008 6:58 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by Mdamen »

As promised a partly protocol description (only on/off is implemented, I plan to implement more later on)

<b>Serial port settings</b>
The serial port settings used to connect to the plugwise stick (USB) are the following:

- Baud rate: 115200
- Data bits: 8
- Stop bits: 1
- Parity: none

<b>Packet header</b>
Every command send to the plugwise stick must have a valid packet header.

Example packet header:

Code: Select all

<ENQ><ENQ><ETX><ETX>
The hexadecimal representation of the above is:

Code: Select all

\x05\x05\x03\x03
<b>Packet end</b>
Every command send must be ended by a control feed followed by a linefeed.

Example packet end:

Code: Select all

<CR><LF>
The hexadecimal representation of the above is:

Code: Select all

\x0d\x0a
<b>Analyzing the on/off packet</b>
In this part I analyze the on/off packet.
Because examples say more then a thousand words, here's an example of an ON packet:

Code: Select all

<ENQ><ENQ><ETX><ETX>0017000A1100003111AB01AC92<CR><LF>
Let's rip the guy apart! [:)]

The first 4 characters represent a function code, in this case it's the on/off function represented by the "0017" characters.

Followed by the function code is the mac address of your device. In this example the mac address is: 00A1100003111AB

Then followed by the mac address is the function value, in this case it's 01. 01 in this function represents "ON". If it stated "00" it would have meant "OFF"

Last but not least, the toughest nut to crack. The last value, in this case the 4 characters "AC92" is a CRC16 value.
For more information about CRC please see the following wikipedia article:

http://en.wikipedia.org/wiki/Cyclic_redundancy_check

The CRC16 value is calculated over the following parts of the packet:
- Function code
- MAC address
- Function value/new state

In this example the CRC16 value is calculated over the following string:

Code: Select all

0017000A1100003111AB01
The CRC checksum used is not a standard one, it has the following properties (in some documents refered to as the xmodem or ymodem CRC):

- Polynomial: 0x11021
- Seed value: 0x00000
- Xor mask: 0x00000
- Width: 16

I tried to describe the protocol as good as possible, let me know if something is unclear and I will try to explain.

--
Maarten Damen

www.maartendamen.com
wwolkers
Member
Member
Posts: 273
Joined: Tue Sep 23, 2008 10:10 am
Location: Netherlands
Contact:

Plugwise and Linux

Post by wwolkers »

Nice work Maarten! thanks!

this is helpfull info indeed.
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Plugwise and Linux

Post by Bwired »

Great work!
Next is the powerusage and powertotal :-)
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by Snelvuur »

If you can find out the rest of the information, i'am sure i can miss a couple of beers :)

// Erik (binkey.nl)
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Plugwise and Linux

Post by Digit »

This is great! :-)
Pieterpaul
Member
Member
Posts: 145
Joined: Sat Jul 05, 2008 7:00 pm
Location: Netherlands

Plugwise and Linux

Post by Pieterpaul »

Wow, this is more than great!
It even looks like we'll be able to do better than VMWare or Wine...
User avatar
TANE
Forum Moderator
Forum Moderator
Posts: 4806
Joined: Fri Apr 06, 2007 9:46 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by TANE »

Sounds good..
This can also be used in Homeseer for controlling
Mdamen
Forum Moderator
Forum Moderator
Posts: 390
Joined: Sat Nov 22, 2008 6:58 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by Mdamen »

Good News! I got the power reading working...
Will be releasing a new version of POL soon!

Chak, let me know if you need a Windows version of it for homeseer purposes!

The options in the new 0.2 version:

Code: Select all

POL (Plugwise on Linux) v0.2 / Maarten Damen

Usage: pol <options>

Options:
  -p  --port <port>  Serial port of the Plugwise stick, for example: /dev/ttyUSB0
  -o  --on <macaddress>  Power on plugwise device with specified MAC address
  -f  --off <macaddress>  Power off plugwise device with specified MAC address
  -w  --watt <macaddress>  Get current watt usage for device with specified MAC address
  -h  --help   This help text
--
Maarten Damen

www.maartendamen.com
User avatar
TANE
Forum Moderator
Forum Moderator
Posts: 4806
Joined: Fri Apr 06, 2007 9:46 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by TANE »

Maarten.
It will be nice to have standalone plugin for Homeseer without running the Plugwise software.
Paul from UK is going to build the plugin for Homeseer..

Do you think It will be also possible to build op plugwise network without plugwise software?

Great work..you going to make lot of people happy.
Mdamen
Forum Moderator
Forum Moderator
Posts: 390
Joined: Sat Nov 22, 2008 6:58 pm
Location: Netherlands
Contact:

Plugwise and Linux

Post by Mdamen »

I will look into that Chak, for now you have to use the source software to connect all your modules etc. All the anylyzing is really time consuming... the power info took me around 10 hours I guess [:)]

--
Maarten Damen

www.maartendamen.com
t006
Starting Member
Starting Member
Posts: 26
Joined: Wed Oct 08, 2008 8:09 pm
Location: Netherlands

Plugwise and Linux

Post by t006 »

Maarten,

Can you publish the source so I can compile it for the AMD64?
Post Reply

Return to “Plugwise Forum”