hallard / LibTeleinfo

Librairie Universelle Teleinformation (TIC)
95 stars 63 forks source link

Invalid trame #16

Closed azertylr closed 4 years ago

azertylr commented 4 years ago

Hello,

Thank for this very useful library!

I have some bad data coming out, for example : PAPP : 00220PHC HCHP : 00872w594

I'm using a callback function and read me->value; The me->name seems always valid but not the value. Do you have any idea of the problem please.

Thanks

BmdOnline commented 4 years ago

Hi, I have similar problems. First, I've applied latest pull request (add +1 in both strncpy in valueAdd function). Then, Ive applied similar update with memcpy (in valueAdd too).

But, sometimes some bad items are coming out. Not with values, but with names.

I've added an alphanumeric control (alpha/num/dot), and got these bad items :

pair : [ADj^5j7BASE].[010683453] is not alphanumeric pair : [VHHPHC].[A] is not alphanumeric pair : [~IINST].[003] is not alphanumeric pair : [IpHHPHC].[A] is not alphanumeric

I don't understand why we have these problems. Checksum seems to be correct when processing input.

Thanks for help.

hallard commented 4 years ago

I've published a fix that may in some case fix the issue, but, I say but because if you're on ESP8266 (moreover with soft serial) depending on your code the Serial may miss some char (example if interrrupted by IP stack) May be with latest version of ESP8266 framework the issue has gone, just let me know

BmdOnline commented 4 years ago

My actual fix, if I remember... : make valueRemove public, add attachData event, and check if label is alphanumeric, otherwise remove value, check mysql insert result and if label is wrong, remove value.

The second case may occurs when label is alphanumeric but not valid (for example VHHPHC).

I will try with your changes.

Thanks.

Edit : for now, I'm running on a breadboard and log a lot of debug informations. I will see if your changes correct my problems.

BmdOnline commented 4 years ago

Hi again,

I've upgraded :

Checking LibTeleinfo.cpp, I've changed (line 664) : strlcpy( buff, _recv_buff, len+1); to : strlcpy( buff, pline, len); I think use of pline parameter is better than _recv_buff, acconding to previous len = strlen(pline);

I have kept my changes :

With previous version, running about one month I've got 10 errors. I will see with these changes, and I'll let you know.

Thanks.

hallard commented 4 years ago

Take care I changed also check on size length.

Anyway, I think I had a change to reproduce the issue, so I changed again and not being able to reproduce the issue again, latest version should be okay :-)

BmdOnline commented 4 years ago

I think you have to make 2 changes, again :

Line 430, replace strlcpy(value, me->value , lgvalue ); by strlcpy(value, me->value , lgvalue + 1);

And, as I suggest before, line 665, replace strlcpy( buff, _recv_buff, len+1); by strlcpy( buff, pline, len + 1);

I'll try your latest commit. Thanks.

hallard commented 4 years ago

Correct for 1st one, 2nd one is cleaner for sure but no issues related, thanks for pointing that out. Released v1.1.2