I'm having trouble getting the CRC check to match. I tried to implement the algorithm described here
http://forum.ekmmetering.com/viewtopic.php?f=4&t=5#p557
My implementation is here...
https://github.com/jwtd/ekm-omnimeter/b ... r/crc16.rb
Response from snippet (2nd byte through third from last byte, inclusive):
\x10$\x1500030000023400311088001820740000000000000000000047930000279700000000000000001250124700000022800288000000002848000360800000000006456 100 100C000002264001100000031000040000800000000000000000000000000000000000000000000000000000000001404080300101801!\r\n\x03
Expected CRC Value: "x\x7F" -> "787f"
Response snippet using ruby's s.bytes method
[16, 36, 21, 48, 48, 48, 51, 48, 48, 48, 48, 48, 50, 51, 52, 48, 48, 51, 49, 49, 48, 56, 56, 48, 48, 49, 56, 50, 48, 55, 52, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 55, 57, 51, 48, 48, 48, 48, 50, 55, 57, 55, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 50, 53, 48, 49, 50, 52, 55, 48, 48, 48, 48, 48, 48, 50, 50, 56, 48, 48, 50, 56, 56, 48, 48, 48, 48, 48, 48, 48, 48, 50, 56, 52, 56, 48, 48, 48, 51, 54, 48, 56, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 54, 52, 53, 54, 32, 49, 48, 48, 32, 49, 48, 48, 67, 48, 48, 48, 48, 48, 50, 50, 54, 52, 48, 48, 49, 49, 48, 48, 48, 48, 48, 48, 51, 49, 48, 48, 48, 48, 52, 48, 48, 48, 48, 56, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 52, 48, 52, 48, 56, 48, 51, 48, 48, 49, 48, 49, 56, 48, 49, 33, 13, 10, 3]
Running these bytes through the normal CRC algo, I get 38708
I'm using a little indian processor, so I didn't reverse the bytes.
Masking the CRC per the thread, I get 13335, which does not match the last two bytes.
One thing I noticed in that thread I linked to above is that the bytes from the sample response look more like this...
Response snippet by unpacking string as hex bytes s.split().map{ |i| i.unpack('H*')[0]}
["10", "24", "15", "30", "30", "30", "33", "30", "30", "30", "30", "30", "32", "33", "34", "30", "30", "33", "31", "31", "30", "38", "38", "30", "30", "31", "38", "32", "30", "37", "34", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "34", "37", "39", "33", "30", "30", "30", "30", "32", "37", "39", "37", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "31", "32", "35", "30", "31", "32", "34", "37", "30", "30", "30", "30", "30", "30", "32", "32", "38", "30", "30", "32", "38", "38", "30", "30", "30", "30", "30", "30", "30", "30", "32", "38", "34", "38", "30", "30", "30", "33", "36", "30", "38", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "36", "34", "35", "36", "20", "31", "30", "30", "20", "31", "30", "30", "43", "30", "30", "30", "30", "30", "32", "32", "36", "34", "30", "30", "31", "31", "30", "30", "30", "30", "30", "30", "33", "31", "30", "30", "30", "30", "34", "30", "30", "30", "30", "38", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "30", "31", "34", "30", "34", "30", "38", "30", "33", "30", "30", "31", "30", "31", "38", "30", "31", "21", "0d", "0a", "03"]
I'm thinking maybe I have the byte unpacking incorrect???