u9n / dlms-cosem

A Python library for DLMS/COSEM
Other
80 stars 41 forks source link

FLAG in FCS causes invalid frames #97

Closed huebrick closed 4 months ago

huebrick commented 4 months ago

I have found a problem where if the 7E flag is found in the FCS filed the library ends the frame there and causes the "HDLC frame could not be parsed. Need more data" error. Here is the recording of the communication on the hardware level: SENT DATA: image

0x7E·0xA0·0x1C·0x00·0x02·0x3C·0x47·0x03·0x32·0xF6·0x85·0xE6·0xE6·0x00·0xC0·0x01·0xC1·0x00·0x01·0x01·0x00·0x20·0x20·0x00·0xFF·0x01·0x00·0x5A·0x62·0x7E

RECIEVD DATA: image

0x7E·0xA0·0x1B·0x03·0x00·0x02·0x3C·0x47·0x52·0xD5·0x51·0xE6·0xE7·0x00·0xC4·0x01·0xC1·0x00·0x09·0x06·0x01·0x00·0x20·0x20·0x00·0xFF·0x7E·0x8C·0x7E

And here is what the library did: SENT DATA: 7E A0 1C 00 02 3C 47 03 32 F6 85 E6 E6 00 C0 01 C1 00 01 01 00 20 20 00 FF 01 00 5A 62 7E RECIEVED DATA: 7E A0 1B 03 00 02 3C 47 52 D5 51 E6 E7 00 C4 01 C1 00 09 06 01 00 20 20 00 FF 7E

huebrick commented 4 months ago

Actually I am at fault here, I have added some code to the library to restart the communication when it reaches this error because I had very unreliable communication and I have not considered the impacts on the other parts of the library 😅 because its so rare to get the flag it really only came up on like few attributes from the 1000+ in the meter and even if it did come up i would chuck it up to bad communication on that scale of reading the whole meter.

Well I hope you didn't see the issues before this post, otherwise I would have wasted yours and my time 😄

Sorry again