New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: implement CRC check #10
Comments
Hi @ThinkPadNL, Interesting. This would be a nice addition to |
I'm not at home right now, so I can't give you an example telegram with a CRC, but I do have some code that could help here : |
@nrocco I'm willing to provide you with some sample data, but i don't want to spread my smartmeter' serial number everywhere on the net. But to do a CRC check on the samples you probably need the untouched telegram i guess? Please let me know how i can assist in this. |
@ThinkPadNL I agree with you, let us avoid spreading serial numbers everywhere on the net. How about posting the complete packet here with your serial number anonymised and share the latter via twitter direct message? |
@nrocco That's okay, what is your Twitter username? |
My twitter username is |
@nrocco I followed you (Fr...), please follow me back so i can send you a PM. |
Any progress so far :D ? |
No much progress I am afraid. I have tried several python crc libraries such as Do you have any working code? |
Yes, i saw this code: https://gathering.tweakers.net/forum/list_message/48049109#48049109 I also found this reference about the CRC16 that is used for the P1 packets: https://github.com/mhe/dsmr4p1/blob/master/dsmr4p1.go#L18 Maybe the DSMR specs can also be useful: http://files.domoticaforum.eu/uploads/Smartmetering/DSMR%20v4.0%20final%20P1.pdf Have you also seen the code that jvhaarst mentions? I see some crc things in his code |
I just checked my code by running it for the first time in months, and my code is able to check the checksum. |
@ThinkPadNL, I will check the resources you provided. @jvhaarst Weird. I did look at your code (I am now using the same python crc package that you are using) but could not get it to work. |
@nrocco In the virtual environment in which I run it at the moment, pip freeze says :
|
Similar for me:
I have reason to believe it has something to do with This is something you do not do in https://github.com/jvhaarst/DSMR-P1-telegram-reader/blob/master/telegram_from_serial.py#L114 Instead you keep the binary data from
I will try to verify my assumptions. |
Reading through my code it indeed looks like the whole telegram needs to be crc'ed, so including the newlines. |
I am making slow progress on this feature but I am almost at the point of sumbmitting a pull request. Thanks for your patience, so far. |
Good to hear! Let me know if the CRC has been implemented 👍 |
@ThinkPadNL I just submitted a pull request that introduces the crc check, see #14 I would appreciate it if you could help me test this against a real smart meter (mine does not include checksums, unfortunately). If you could test it against python 2.x and python 3.x, that would be great. |
Nice! Like i said, i have very little programming skills. I want to help you test the things you said, but you have to explain me how haha ;) Where do i start now? |
@ThinkPadNL no worries, I did some testing against my smart meter from python 2 and python 3. I was comfortable enough to create a new release Packets without a valid crc no throw an exception. |
It works!
I also managed to rewrite the script i am using to put the data into InfluxDB (and then graph it with Grafana). This is the old version, this is the new version. Probably really ugly, but i am quite proud of myself already that i was able to mangle your new code into the old script (that i didn't make myself, i have almost no Python skills). P.S. Maybe you should also mention the |
Good to hear! You can expect more pull requests in the next couple of days to:
I will take your feedback into account. |
Hi @nrocco, yesterday @ThinkPadNL requested CRC as well in dsmrreader/dsmr-reader#188 and pointed me to your app. |
As far as i can see, the code doesn't have a CRC check to look if the incoming telegram is correct. However, the modern >=DSMR4 meters include a CRC at the end of the telegrams. With the CRC16 these can be checked, see also: https://gathering.tweakers.net/forum/list_messages/1704755
Would be nice if this would be implemented, to prevent false data being imported.
The text was updated successfully, but these errors were encountered: