u9n / dlms-cosem

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

Better error handling #96

Closed huebrick closed 5 months ago

huebrick commented 5 months ago

I have a suggestion on how to improve this library regarding the error handling when the communication is in some way interrupted.

So for example currently if the library sends a frame out to the meter and the meter doesn't respond it will just try to read the serial port into oblivion waiting for a msg that will never come for one reason or another. One way to get out of this would be if the library encounters this error then it can repeat the last action it tried to do and if it fails x times then it should exit. image In this example meter didn't turn on in time to start the connection, if it tried again a second later then it would have succeeded.

Basically in any case where data is not readable it should try again(I do understand its not so simple as just trying again but it should have a way to get out of these kinds of errors), communication over optical probes can be very unreliable if you get the correct combination of probe and meter(a lot of hair was lost to this cause 😄)

I do understand that this library is free and you are offering paid development of features so this is just a suggestion 😃

Krolken commented 5 months ago

Hi.

I appreciate all feedback. :) I just had a new kid and have not had time to give the library some love lately.

I know this is a problem, but it is usually just when you are trying to figure out the HDLC settings etc. Once everything is working well things flow quite ok.

I don't like the resend in the protocol or transport layer. If implemented it should be on the client. But I think this problem could be avoided with proper timeout handling as mentioned in #93. At least it would fail with a proper error.

huebrick commented 5 months ago

Hey, congratulations !!!

I agree if the library gave out an error when the serial timed out then it wouldn't be too much work for me to implement my own error handling.

Then we can consider this as a duplicate of #93

Thanks :)