Page 5 of 13

Re: Powerlink protocol description

Posted: Sun Sep 08, 2013 5:22 pm
by uAlex73
@tek:

Some progress has been made, but Visonic seem to have made it impossible to detect which PIR had movement ... you only can see that -something- happened. See the Vera Plugin for the specific code changes ;-)

Re: Powerlink protocol description

Posted: Sun Sep 08, 2013 8:23 pm
by Rene
Visonic reports the zone the motion has been detected in and the zone is assigned to a specific motion sensor.

Re: Powerlink protocol description

Posted: Tue Sep 10, 2013 9:17 am
by dad
uAlex73 wrote:Yes, when i finally fired out how the powerlink communication is started, i got it working on the RS232 too :D

Just send an invalid download request, and the PM30 will ask you to enroll :-)
uAlex73,

Could you give more detail on the steps you took to do this? I have a similar setup using a PM30 and would prefer to use perl if possible (I think you said on another thread that you are using perl).

Thanks

D

Re: Powerlink protocol description

Posted: Sat Oct 19, 2013 10:07 am
by HadePee
Does anyone know what byte 7 does represent when the System State Flag (byte 4) does report a problem.

xx xx b1 b2 b3 b4 b5 b6 b7 b9 b9
0d a5 00 04 00 05 00 00 10 03 04 00 43 f6 0a

Byte 4 contains 0x04 (state flag), meaning Ready (bit 0) & Problem (bit 2)
Byte 7 contains 0x10. Normally this is alway 0x00.

The Powermax+ logs this event (byte 7, 0x10) when I disconnect the telephone line.

As long the telephone line is disconnected, every zone motion contains 0x10 in byte 7. For example motion in zone 14 (byte 5, 0x0e)
0d a5 00 04 00 25 0e 05 10 03 04 00 43 c3 0a

Is there a list known of what byte 7 relates to??

Thanks!
Henk.

Re: Powerlink protocol description

Posted: Thu Dec 19, 2013 10:04 am
by uAlex73
There are 2 options given to calculate the checksum, the first one is always working.

The following one is NOT:

Code: Select all

Other way to calculate the checksum:
1. Sum all the payload bytes in a word;
2. Subtract both high and low byte from FFFF;
3. Low byte contains the checksum.
It should be:

Code: Select all

Other way to calculate the checksum:
1. Sum all the payload bytes in a word;
2. Add high and low byte together into variable total
3. If total is > 255 then substract 255
4. Subtract total from FF;
5. Low byte contains the checksum.
BTW, the following shows the "bug":
Total=1019 - 0x03FB => 0xFFFF - 0x03 - 0xFB => 0xFF01 => 0x01 (OK)
Total=1020 - 0x03FC => 0xFFFF - 0x03 - 0xFC => 0xFF00 => 0x00 (OK)
Total=1021 - 0x03FD => 0xFFFF - 0x03 - 0xFD => 0xFEFF => 0xFF (NOT OK) - Should be: 0xFE
Total=1022 - 0x03FE => 0xFFFF - 0x03 - 0xFE => 0xFEFE => 0xFE (NOT OK) - Should be: 0xFD
Total=1023 - 0x03FF => 0xFFFF - 0x03 - 0xFF => 0xFEFD => 0xFD (NOT OK) - Should be: 0xFC
Total=1024 - 0x0400 => 0xFFFF - 0x04 - 0x00 => 0xFFFB => 0xFB (OK)

Re: Powerlink protocol description

Posted: Thu Dec 19, 2013 12:55 pm
by Mario from Spain
Hello

I'm trying to write some basic HomeSeer script to interface with my Powermax PRO via RS232

Somebody has a vb.net example to share with me?

Thank you very much.

Mario

Re: Powerlink protocol description

Posted: Tue Jan 07, 2014 4:32 pm
by bartbakels
Mario,

Any luck writting the script,I am also quite intrested in this script. especially for HS3 (maybe I can assist in rewriting it for hs3). at this moment I use the hs2 plugin, but this will not be ported to HS3.

regards

bart

Re: Powerlink protocol description

Posted: Tue Jan 07, 2014 5:59 pm
by Mario from Spain
Hi Bart

I did some preliminary tests but I'm having some issues with the checksum calculation. I hope a fellow member share a working code.

Re: Powerlink protocol description

Posted: Tue Jan 07, 2014 6:31 pm
by wwolkers
Maybe this is of any use to you (this is what's being used in DomotiGa):

Code: Select all

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Check the CRC of the received data
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub CheckCRC(bData As Byte[]) As Boolean

  Dim bChecksum As Byte
  Dim bDataTmp As Byte[]

  ' first copy the bData - else we loose information
  bDataTmp = bData.Copy()
  ' Remove the preamble
  bDataTmp.Extract(0, 1)
  ' Remove the postamble
  bDataTmp.Pop()

  ' Check if Count > 0
  If bDataTmp.Count > 0 Then

    ' Copy and remove the checksum
    bChecksum = bDataTmp.Pop()

    ' Check if calculation and checksum match
    If CalculateCRC(bDataTmp) = bChecksum Then Return True
  Endif

  Return False

End
you can find the complete source here: domotiga.nl/projects/domotiga/repositor ... tiGa3/.src

Re: Powerlink protocol description

Posted: Tue Jan 07, 2014 9:24 pm
by uAlex73
@Mario:

If you got issues, maybe you can share some code / examples where it goes wrong?

Re: Powerlink protocol description

Posted: Wed Jan 08, 2014 12:10 pm
by dad
uAlex73 wrote:@Mario:

If you got issues, maybe you can share some code / examples where it goes wrong?
As an alternative this is my perl code to do the checksum ( I am a perl beginner so I am sure it can be improved):

Code: Select all

sub CalcChksum {
 my $chkstring = shift;
 # Read last 4 char which should include x43 checksum indicator
 my $chksum = substr($chkstring, -4);
 my $chkout = "";
 my $base = 0xFFFF;

 # Check for checksum character
 if(substr($chksum, 0, 2) ne "43"){
  # If no checksum return C1 no checksum error
  $chkout = "ERR:C1";
  return $chkout;
 }
 else{
  # Otherwise calculate checksum
  if(substr($chkstring, 0, 2) eq "0d"){
   # Strip off carriage return
   $chkstring = substr($chkstring, 2, -2);
  }
  # Get checksum value by removing lead 43
  $chksum = substr($chksum, -2);
  # Convert ASCII check string back to hex and then convert and calculate in decimal
  my @bytes = unpack('C*', pack('H*', $chkstring));
  my $chk = 0;
  # Split into decimal byte values and sum
  foreach my $num (@bytes){
   $chk = $chk + $num;
  }
  # convert decimal check value to hex
  my $outhex =  sprintf("%04x",$chk);
  # Split checksum into hi and lo bytes
  my @pairs = $outhex =~ /../sg;
  my $hibyte = hex "$pairs[0]";
  my $lobyte = hex "$pairs[1]";
  # Perform checksum calculation (FFFF - hibyte - lobyte) and return lo byte of result
  my $chkcalc = substr(sprintf("%04x",$base - $hibyte - $lobyte), -2);
  # If checksum OK set checksum code to OK
  if($chkcalc eq $chksum){
   $chkout = "OK";
  }
  else{
   # If lobyte = FF hibyte appears to be used
   # so check hibyte or return C2 checksum calculation error
   $chkcalc = substr(sprintf("%04x",$base - $hibyte - $lobyte), 0, 2);
   if($chkcalc eq $chksum){
    $chkout = "OK";
   }
   else{
    $chkout = "ERR:C2";
   }
  }
  return  $chkout;
 }
}
# End of sub CalcChksum
HTH -comments improvements welcome.

Dad

Re: Powerlink protocol description

Posted: Wed Jan 08, 2014 11:17 pm
by Romac
uAlex73 wrote:@nlrb:

I am trying to get my PowerMaster 30 work as as i want. I manage to get the status update from the PM30 (after i send a message). How can i get "near" real-time sensor updates from the PM30 as you have build into the Vera package?

None of those messages are send out on the serial on this moment?
I'm looking into purchasing an alarm system and want to use the sensor information in Homeseer to activate other events. I know this is possible with the PowerMax and RFXCom. The PowerMaster seems to be a more modern unit with new technology but without the option to use RFXCom, due to the PowerG technology.

Is there a way through the Powerlink protocol that makes in possible to use the sensor information (or any other way)?

Re: Powerlink protocol description

Posted: Thu Jan 09, 2014 11:12 am
by uAlex73
I have the PowerMaster 30 (UK) here and I am getting the motion sensor events now (you need to enable "always on" on the motion sensor first) via the serial. It isn't realtime, like the PowerMax. I get them once a minute. I initially had some timing issues in the code i am using, which sometimes drop the packet (and an invalid checksum calculation ;-().

If you want to be 100% safe, then possible the PowerMax + RFXCom option is the way to go. For PowerMaster there will be never a device like RFXCom as you correctly mentioned.

For support of your PowerMax/Master, you need to write the code yourself or use supporting software like HomeSeer/DomotiGa/Vera.

Re: Powerlink protocol description

Posted: Thu Jan 09, 2014 1:43 pm
by dad
@uAlex: Thanks for the PM, I cannot reply yet as I have not posted enough. Yes my code works - Initially it was failing when the lobyte evaluated to FF, by trial and error I found that if that is the case the checksum appears to be the hibyte instead. Since then all the messages received have calculated correctly.

Dad

Re: Powerlink protocol description

Posted: Thu Jan 09, 2014 8:55 pm
by Romac
uAlex73 wrote:I have the PowerMaster 30 (UK) here and I am getting the motion sensor events now (you need to enable "always on" on the motion sensor first) via the serial. It isn't realtime, like the PowerMax. I get them once a minute. I initially had some timing issues in the code i am using, which sometimes drop the packet (and an invalid checksum calculation ;-().

If you want to be 100% safe, then possible the PowerMax + RFXCom option is the way to go. For PowerMaster there will be never a device like RFXCom as you correctly mentioned.

For support of your PowerMax/Master, you need to write the code yourself or use supporting software like HomeSeer/DomotiGa/Vera.
Can I ask you why you choose the PowerMaster over the PowerMax? Was this because of the newer technology or are there any other reasons that make up for the downside of not being able to get the sensor information directly? The possibilities of communicating through Powerlink or RFXCom seem a big plus for the PowerMax.