spacemanspiff2007 / SmlLib

A library for the SML (Smart Message Language) protocol
GNU General Public License v3.0
27 stars 9 forks source link

CRC Errors #12

Closed sebbegg closed 1 year ago

sebbegg commented 1 year ago

Hi there,

I'm using smllib to monitor my smartmeter. Occasionally (rather frequently lately) I'm seeing CRC errors like the one below:

monitoring-smartmeter-exporter-1  |   File "/usr/local/lib/python3.10/site-packages/smllib/reader.py", line 58, in get_frame
monitoring-smartmeter-exporter-1  |     raise CrcError(msg, crc_msg, crc_calc)
monitoring-smartmeter-exporter-1  | smllib.errors.CrcError: (b'\x1b\x1b\x1b\x1b\x01\x01\x01\x01v\x05\tPA\xbab\x00b\x00rc\x01\x01v\x01\x01\x05\x03\x1a\xc0\x94\x0b\t\x01ISK\x00\x04i\xb2\xb8\x01\x01c\x08\xf3\x00v\x05\tPA\xbbb\x00b\x00rc\x07\x01w\x01\x0b\t\x01ISK\x00\x04i\xb2\xb8\x07\x01\x00b\n\xff\xffrb\x01e\x05;\x82\x87ww\x07\x81\x81\xc7\x82\x03\xff\x01\x01\x01\x01\x04ISK\x01w\x07\x01\x00\x00\x00\t\xff\x01\x01\x01\x01\x0b\t\x01ISK\x00\x04i\xb2\xb8\x01w\x07\x01\x00\x01\x08\x00\xffe\x00\x00\x01\x82\x01b\x1eR\xffY\x00\x00\x00\x00\x05\xab\xdb\xdd\x01w\x07\x01\x00\x01\x08\x01\xff\x01\x01b\x1eR\xffY\x00\x00\x00\x00\x05\xaboW\x01w\x07\x01\x00\x01\x08\x02\xff\x01\x01b\x1eR\xffY\x00\x00\x00\x00\x00\x00l\x86\x01w\x07\x01\x00\x10\x07\x00\xff\x01\x01b\x1bR\x00U\x00\x00\x01\'\x01w\x07\x81\x81\xc7\x82\x05\xff\x01\x01\x01\x01\x83\x02\xc4\xd3$\xa0\xa77\xda\x15B\xe0j\xbf\xdd\x95\xd4\xf1\xd4\xe4\x1aL\xa4\xa5g\x05\xc9"_\xeeT\x87\x91\x80\xdcn\x1b\x1b\x1b\x1b\x01\x01\x01\x01v\x05\tPA\xbdb\x00b\x00rc\x01\x01v\x01\x01\x05\x03\x1a\xc0\x95\x0b\t\x01ISK\x00\x04i\xb2\xb8\x01\x01c;o\x00v\x05\tPA\xbeb\x00b\x00rc\x07\x01w\x01\x0b\t\x01ISK\x00\x04i\xb2\xb8\x07\x01\x00b\n\xff\xffrb\x01e\xc7\x82\x05\xff\x01\x01\x01\x01\x83\x02\xc4\xd3$\xa0\xa77\xda\x15B\xe0j\xbf\xdd\x95\xd4\xf1\xd4\xe4\x1aL\xa4\xa5g\x05\xc9"_\xeeT\x87\x91\x80\xdcn:\x93\x8a\xcf\x88z\x9a\xdf}\xb4h#\xe2_\x01\x01\x01c\xaaD\x00v\x05\tPA\xbfb\x00b\x00rc\x02\x01q\x01c\xbe\x7f\x00\x1b\x1b\x1b\x1b\x1a\x00vH', 30280, 23196)

Some frames in between always seem fine and yield proper data. Can I expect this to be a "hardware" issue possibly related to the IR reader (in which case I'd probably catch & ignore them)? Or could this be some other issue?

spacemanspiff2007 commented 1 year ago

Or could this be some other issue?

For me CRC works without issues so this is probably a hardware issue. Maybe the reader is not 100% correct on the meter or something else.

spacemanspiff2007 commented 1 year ago

Another option could be that another Program is accessing the serial port and reading small chunks of data thus making the received frame invalid.

TooMuchAir commented 1 year ago

I have the same issue and I doubt it is due to other program accessing the port. I am not able to read from the port again in another script once it has been opened in my SMLReader program: "serial.serialutil.SerialException: Port is already open.". For me, about 30 readings fail every hour +/- 3. Below is an extract from my log. What strikes me is frequency of the failures: The vast majority seem to occur exactly 90 or 180 seconds after the last. I wonder if this is caused by an overflow within the the meter and/or a bug. My meter is a Holley EHZ 541-ZD (Rheinenergie).

Perhaps others who have similar issues can comment to get to the bottom of this!

19:00:34,002 SMLReader: WARNING  CRC failure.
19:02:03,999 SMLReader: WARNING  CRC failure.
19:05:03,993 SMLReader: WARNING  CRC failure.
19:06:33,986 SMLReader: WARNING  CRC failure.
19:08:03,989 SMLReader: WARNING  CRC failure.
19:09:34,002 SMLReader: WARNING  CRC failure.
19:11:03,998 SMLReader: WARNING  CRC failure.
19:12:34,004 SMLReader: WARNING  CRC failure.
19:14:03,997 SMLReader: WARNING  CRC failure.
19:15:34,025 SMLReader: WARNING  CRC failure.
19:17:51,005 SMLReader: WARNING  CRC failure.
19:19:20,979 SMLReader: WARNING  CRC failure.
19:23:07,957 SMLReader: WARNING  CRC failure.
19:24:37,954 SMLReader: WARNING  CRC failure.
19:26:41,954 SMLReader: WARNING  CRC failure.
19:29:42,946 SMLReader: WARNING  CRC failure.
19:31:12,939 SMLReader: WARNING  CRC failure.
19:32:42,936 SMLReader: WARNING  CRC failure.
19:37:09,928 SMLReader: WARNING  CRC failure.
19:38:39,932 SMLReader: WARNING  CRC failure.
19:40:09,943 SMLReader: WARNING  CRC failure.
19:41:39,919 SMLReader: WARNING  CRC failure.
19:43:09,916 SMLReader: WARNING  CRC failure.
19:44:39,913 SMLReader: WARNING  CRC failure.
19:47:21,917 SMLReader: WARNING  CRC failure.
19:48:51,905 SMLReader: WARNING  CRC failure.
19:50:21,917 SMLReader: WARNING  CRC failure.
19:51:51,902 SMLReader: WARNING  CRC failure.
19:53:21,895 SMLReader: WARNING  CRC failure.
19:54:51,892 SMLReader: WARNING  CRC failure.
19:56:21,911 SMLReader: WARNING  CRC failure.
19:57:51,900 SMLReader: WARNING  CRC failure.
19:59:21,898 SMLReader: WARNING  CRC failure.
20:02:16,928 SMLReader: WARNING  CRC failure.