olliiiver / sml_parser

Low memory C++ library to parse Smart Message Language (SML) data from smart meters.
GNU Lesser General Public License v2.1
35 stars 15 forks source link

Hangs with Unexpected byte! Message #21

Closed tmandel123 closed 1 year ago

tmandel123 commented 1 year ago

I wanted to try out the arduino example (Continuously loops through a static message from RAM and outputs information) The example compiled fine. When I used my own counter data from my Holley DTZ541 ZECA I was not able to get any valid data. I already checked the CRC of my own data. The data are valid.

The unexpected byte! Message beginns at 0xf1,0x06,0x77,0x07,0x01,0x00 (after 106 bytes)

When I use my IR-Sensor with other software like https://github.com/mhop/fhem-mirror/blob/master/fhem/FHEM/47_OBIS.pm all data are extracted fine.

Here is my version of _ehzbin.h

// clang-format off
// Formatted example data from https://github.com/devZer0/libsml-testing

const unsigned char ehz_bin[] = {
0x1b,0x1b,0x1b,0x1b,0x01,0x01,0x01,0x01,0x76,0x04,0x00,0x00,0x01,0x62,0x00,0x62,
0x00,0x72,0x65,0x00,0x00,0x01,0x01,0x76,0x01,0x01,0x07,0x00,0x00,0x00,0x12,0x9c,
0x06,0x0b,0x0a,0x01,0x48,0x4c,0x59,0x02,0x00,0x15,0xb8,0xaa,0x72,0x62,0x01,0x65,
0x00,0x12,0x9c,0x06,0x01,0x63,0xa9,0xae,0x00,0x76,0x04,0x00,0x00,0x02,0x62,0x00,
0x62,0x00,0x72,0x65,0x00,0x00,0x07,0x01,0x77,0x07,0xff,0xff,0xff,0xff,0xff,0xff,
0x0b,0x0a,0x01,0x48,0x4c,0x59,0x02,0x00,0x15,0xb8,0xaa,0x07,0x01,0x00,0x62,0x0a,
0xff,0xff,0x72,0x62,0x01,0x65,0x00,0x12,0x9c,0x06,0xf1,0x06,0x77,0x07,0x01,0x00,
0x60,0x32,0x01,0x01,0x01,0x01,0x01,0x01,0x04,0x48,0x4c,0x59,0x01,0x77,0x07,0x01,
0x00,0x60,0x01,0x00,0xff,0x01,0x01,0x01,0x01,0x0b,0x0a,0x01,0x48,0x4c,0x59,0x02,
0x00,0x15,0xb8,0xaa,0x01,0x77,0x07,0x01,0x00,0x01,0x08,0x00,0xff,0x65,0x00,0x1c,
0x91,0x04,0x72,0x62,0x01,0x65,0x00,0x12,0x9c,0x06,0x62,0x1e,0x52,0xff,0x65,0x00,
0x13,0xe9,0x89,0x01,0x77,0x07,0x01,0x00,0x02,0x08,0x00,0xff,0x01,0x72,0x62,0x01,
0x65,0x00,0x12,0x9c,0x06,0x62,0x1e,0x52,0xff,0x63,0x06,0x3b,0x01,0x77,0x07,0x01,
0x00,0x10,0x07,0x00,0xff,0x01,0x01,0x62,0x1b,0x52,0x00,0x52,0x22,0x01,0x77,0x07,
0x01,0x00,0x24,0x07,0x00,0xff,0x01,0x01,0x62,0x1b,0x52,0x00,0x52,0x89,0x01,0x77,
0x07,0x01,0x00,0x38,0x07,0x00,0xff,0x01,0x01,0x62,0x1b,0x52,0x00,0x52,0x3e,0x01,
0x77,0x07,0x01,0x00,0x4c,0x07,0x00,0xff,0x01,0x01,0x62,0x1b,0x52,0x00,0x52,0x5b,
0x01,0x77,0x07,0x01,0x00,0x20,0x07,0x00,0xff,0x01,0x01,0x62,0x23,0x52,0xff,0x63,
0x09,0x3d,0x01,0x77,0x07,0x01,0x00,0x34,0x07,0x00,0xff,0x01,0x01,0x62,0x23,0x52,
0xff,0x63,0x09,0x46,0x01,0x77,0x07,0x01,0x00,0x48,0x07,0x00,0xff,0x01,0x01,0x62,
0x23,0x52,0xff,0x63,0x09,0x40,0x01,0x77,0x07,0x01,0x00,0x1f,0x07,0x00,0xff,0x01,
0x01,0x62,0x21,0x52,0xfe,0x62,0x45,0x01,0x77,0x07,0x01,0x00,0x33,0x07,0x00,0xff,
0x01,0x01,0x62,0x21,0x52,0xfe,0x62,0x30,0x01,0x77,0x07,0x01,0x00,0x47,0x07,0x00,
0xff,0x01,0x01,0x62,0x21,0x52,0xfe,0x62,0x49,0x01,0x77,0x07,0x01,0x00,0x51,0x07,
0x01,0xff,0x01,0x01,0x62,0x08,0x52,0x00,0x53,0x00,0xf0,0x01,0x77,0x07,0x01,0x00,
0x51,0x07,0x02,0xff,0x01,0x01,0x62,0x08,0x52,0x00,0x52,0x78,0x01,0x77,0x07,0x01,
0x00,0x51,0x07,0x04,0xff,0x01,0x01,0x62,0x08,0x52,0x00,0x53,0x00,0xdf,0x01,0x77,
0x07,0x01,0x00,0x51,0x07,0x0f,0xff,0x01,0x01,0x62,0x08,0x52,0x00,0x53,0x01,0x2f,
0x01,0x77,0x07,0x01,0x00,0x51,0x07,0x1a,0xff,0x01,0x01,0x62,0x08,0x52,0x00,0x53,
0x01,0x2d,0x01,0x77,0x07,0x01,0x00,0x0e,0x07,0x00,0xff,0x01,0x01,0x62,0x2c,0x52,
0xff,0x63,0x01,0xf4,0x01,0x77,0x07,0x01,0x00,0x00,0x02,0x00,0x00,0x01,0x01,0x01,
0x01,0x07,0x35,0x30,0x31,0x30,0x30,0x32,0x01,0x77,0x07,0x01,0x00,0x60,0x5a,0x02,
0x01,0x01,0x01,0x01,0x01,0x05,0x36,0x31,0x33,0x39,0x01,0x01,0x01,0x63,0x8b,0xb3,
0x00,0x76,0x04,0x00,0x00,0x03,0x62,0x00,0x62,0x00,0x72,0x65,0x00,0x00,0x02,0x01,
0x71,0x01,0x63,0xe8,0x23,0x00,0x00,0x00,0x1b,0x1b,0x1b,0x1b,0x1a,0x02,0xed,0xd4
};
const unsigned int ehz_bin_len = 560;
olliiiver commented 1 year ago

Hi @tmandel123.

thanks for attaching the example data from your meter.

I can parse the message with the version from PR #20

START
...
End of block at level 0
Received checksum: D4ED
Calculated checksum: D4ED
>>> FINAL! Checksum OK
>>> Manufacturer.............:
>>> Power T1    (1-0:1.8.1)..: -3.000 Wh
>>> Power T1+T2 (1-0:1.8.0)..: 130496.900 Wh
tmandel123 commented 1 year ago

Hi @olliiiver, thanks for you advice. The results when using PR https://github.com/olliiiver/sml_parser/pull/20 look much better now under native-client.

I will give it a try with arduino_serial example, but need some time to setup everythink.

What I also have to verify is, why Power T1 und Manufacturer are not giving me good results.

tmandel123 commented 1 year ago

A short feedback. I didn't got any valid data from Manufacturer but anyway I don't really need these static information. But anything else seems to work fine. Even negative values (while feeding with PV energy) are shown correctly.

Nice job @olliiiver