could be...
i checked it:
============== 1 packet ==============
Request.php:204 :: Good sendstring (without checksum):
0012000D6F0000D3198D (20)
Request.php:211 :: Generated Decimal CRC
446 (3)
Request.php:212 :: CRC decimal to Hex
1be (3)
combined send string:
0012000D6F0000D3198D1BE (23)
"response from ..... (plug?) ":
0000000000C264DF
===================================
============== 2 packet ==============
Request.php:204 :: Good sendstring (without checksum):
0026000D6F0000D3198D(20)
Request.php:211 :: Generated Decimal CRC
16964(5)
Request.php:212 :: CRC decimal to Hex
4244(4)
combined send string:
0026000D6F0000D3198D4244 (24)
Response from plug:
002700DD000D6F0000D3198D3F7D709BB612A7853C62D7FA00000000BA4C
===================================
This shows that the first dec-crc is also to short.
The first combined packet/string is wrong and the plug doesn't response.
The second combined packet/string is goed and the plug does response.
[/edit]
based on the following python script, i changed the checksum function:
python-plugwise / plugwise / protocol.py
look at lines:19, 157, 161
i made the following python script:
Code: Select all
#!/usr/bin/env python
import sys,struct,crcmod
# If no arguments were given, print a helpful message
if len(sys.argv)==1:
print 'Usage: dec'
sys.exit(0)
crc_func = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000)
print crc_func(sys.argv[1])
in php i change the code to:
Code: Select all
......
// $string = $sendstring;
$crc = exec("/home/marco/crcfun.py ".$string."");
return dechex($crc);
......
this gives the following result:
============== 1 packet ==============
Request.php:204 :: Good sendstring (without checksum):
0012000D6F0000D3198D (20)
Request.php:211 :: Generated Decimal CRC
446 (3)
Request.php:212 :: CRC decimal to Hex
1be (3)
combined send string:
0012000D6F0000D3198D1BE (23)
"response from ..... (plug?) ":
0000000000C264DF
===================================
============== 2 packet ==============
Request.php:204 :: Good sendstring (without checksum):
0026000D6F0000D3198D(20)
Request.php:211 :: Generated Decimal CRC
16964(5)
Request.php:212 :: CRC decimal to Hex
4244(4)
combined send string:
0026000D6F0000D3198D4244 (24)
Response from plug:
002700DD000D6F0000D3198D3F7D709BB612A7853C62D7FA00000000BA4C
===================================
yes,yes it is copied from above, because the python script gives exactly the same result.
Both script generate a short decimal CRC....
for those how want to play,check,debug,etc... the mac address of the plug is D3198D and i'm trying to receive the current power usage.
[/edit]
[edit2]
oke i found the following site:
crc-calculation
On this site you can generate multiple CRC on a string.
based on the driver i expect a "fc0a" CRC for "0012000D6F0000C3A6FC".
When i generate the ASCii CRC's i indeed see "CRC-CCITT (XModem) 0x
FC0A"
when i generate the ASCII CRC's for "0012000D6F0000C3A6FC" i get:
Code: Select all
1 byte checksum 48
CRC-16 0xB2A7
CRC-16 (Modbus) 0xA983
CRC-16 (Sick) 0x1CFD
CRC-CCITT (XModem) 0x01BE
CRC-CCITT (0xFFFF) 0xF706
CRC-CCITT (0x1D0F) 0x9E0A
CRC-CCITT (Kermit) 0x2A5A
CRC-DNP 0xAA6D
CRC-32 0x83C31987
CRC-CCITT (XModem) 0x
01BE
So it look likes that Digit had it all right!!
Probably the dechex() php function is missing the whole thing up....
The question now is, how can i solve this problem?!
[/edit2]
[edit3]
change Python to:
Code: Select all
crc_func = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000)
print str('%.4x' % crc_func(sys.argv[1]))
and....
IT WORKS!!!!!!!
the dechex() function from PHP messes the whole thing up.
anybody a native php fix?
[/edit3]