Checksum error in Plugwise Driver Dirk Engels
Posted: Thu Feb 16, 2012 6:30 pm
I'm struggling for a while now with the Plugwise driver from Dirk Engels.
When i request PowerInfo from my devices, some of them doesn't response.
I found that for the devices that didn't response, the had a to short send string:
Good sendstring (without checksum):
0012000D6F0000C3A6FC(20)
generated checksum for the above string:
FC0A(4)
Combined send string is:
0012000D6F0000C3A6FCFC0A (24)
Wrong sendstring (without checksum):
0012000D6F0000D3198D(20)
generated checksum for the above string:
1BE(3)
Combined send string is:
0012000D6F0000D3198D1BE (23)
The last string is 1 char to short and so i got no response from the circle.
this is the php function that generates the CRC.
Anyone a idea whats happening here?
When i request PowerInfo from my devices, some of them doesn't response.
I found that for the devices that didn't response, the had a to short send string:
Good sendstring (without checksum):
0012000D6F0000C3A6FC(20)
generated checksum for the above string:
FC0A(4)
Combined send string is:
0012000D6F0000C3A6FCFC0A (24)
Wrong sendstring (without checksum):
0012000D6F0000D3198D(20)
generated checksum for the above string:
1BE(3)
Combined send string is:
0012000D6F0000D3198D1BE (23)
The last string is 1 char to short and so i got no response from the circle.
this is the php function that generates the CRC.
Code: Select all
/**
*
* The make Crc Checksum function creates a 16bit CRC checksum of the input
* string.
* @param string $string
*/
public function makeCrcCheckSum($string) {
$crc = 0x0000;
for ($i = 0, $j = strlen($string); $i < $j; $i++) {
$x = (($crc >> 8) ^ ord($string[$i])) & 0xFF;
$x ^= $x >> 4;
$crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF;
}
return strtoupper(dechex($crc));
}