u9n / dlms-cosem

A Python library for DLMS/COSEM
Other
79 stars 39 forks source link

HCS errors with Kaifa meters #68

Open gnumfen opened 10 months ago

gnumfen commented 10 months ago

I'm having problems decoding data from two Kaifa meters. The exception I'm getting is "HCS is not correct Calculated".

This is data from first meter: 7ea09b01000110561be6e7000f40000000090c07e7090401103400ff800000021209074b464d5f30303109103733343031353730313132353335343409084d41333034483444060000044f0600000000060000000006000000c0060000088f06000005aa060000057c06000008da06000008f906000008e6090c07e7090401103400ff8000000608c141c9060000000006001ae03806013151959d787e This is data from the second meter: 7ea11d01000110b0aee6e7000f4000000000022409060100000281ff09074b464d5f30303109060000600100ff09103733343031353730333037383433393509060000600107ff09074d41333034483409060100010700ff060000017209060100020700ff060000000009060100030700ff060000000009060100040700ff0600000050090601001f0700ff06000001be09060100330700ff060000047b09060100470700ff060000009409060100200700ff06000008ee09060100340700ff06000008e609060100480700ff06000008dd09060000010000ff090c07e709040111132dffffc40009060100010800ff0600bc0d9009060100020800ff060000000009060100030800ff06001c05dc09060100040800ff06000fed42acfd7e

As far as I can see there is more data in the header then on other meters.

Krolken commented 10 months ago

Hi.

I see a problem in the parsing of hdlc frames.

The meter is using a 1 byte and a 2 byte address, but when we calculate the hcs we are forcing the 2 byte address to a 1 byte address.

We should instead keep track of the initial length of the address so we can encode the address properly.

gnumfen commented 10 months ago

Hi I have done a attempt at fixing my problem. It is in my kaifa-branch in the cloned repo. I'm not very proud of the change in data_notification.py...