mysensors / NodeManager

Plugin for a rapid development of battery-powered sensors
130 stars 82 forks source link

Debug prints wrong floating point numbers #542

Closed j54n1n closed 2 years ago

j54n1n commented 2 years ago

Hello there,

I noticed when NODEMANAGER_DEBUG and NODEMANAGER_DEBUG_VERBOSE are enabled that floating point numbers get printed in a wrong fashion probably due to some overflow.

For example if I set the value of a sensor to 32767.6789 I get following log:

5313 NM:LOOP:TEST(202):SET t=48 v=32767.-32
5317 NM:MSG:SEND(202) t=48 p=32767.04
5330 TSF:MSG:SEND,84-84-0-0,s=202,c=1,t=48,pt=7,l=5,sg=0,ft=0,st=OK:32767.68

This happens both with DOUBLE and FLOAT formats. But as you can see the line from MySensors is showing correctly the truncated and rounded value. So at the end it is only a cosmetic error.

I will try to fix it with an pull request shortly.

Kind regards.

user2684 commented 2 years ago

Thanks, my understanding is that the right value is sent over the network BUT the way it is printed is wrong. Thanks a lot for the PR, will merge straight away!