-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modbus input - negative values not supported with FLOAT32 #7317
Comments
It seems to me that there is a need to differentiate between two scenarios regarding the handling of FLOAT32 fields:
Since there are for sure some people relying on the old behaviour, things will break for them when the new behaviour is introduced. But on the other hand, if we do not change anything, there will be people who cannot use this type at all. Maybe we should resolve this conflict by introducing an additional type SFLOAT32, which implements the new behaviour. Old configurations will not be affected, and new configurations could make use of signed values. Btw: FLOAT32 is misnamed, since the field value could be generated from 16, 32 or 64 byte integer values. Instead we should name it FIXED Furthermore, we should think about deprecating FLOAT32, because it is not clear enough what this type should be used for. |
) * Add input float types FIXED/UFIXED (#7317)
) * Add input float types FIXED/UFIXED (#7317)
…fluxdata#7869) * Add input float types FIXED/UFIXED (influxdata#7317)
@kolmodin can you verify that with the change of @sensor-freak and changing the datatype to |
Awesome! I've reviewed the code and it looks like it adresses the issues I was experiencing. When can I expect these changes in a released version of telegraf? I'm using it for thermometer data and it's December - we're having some minus (celcius) degrees here :) |
I upgraded to 1.16.3 and changed to |
…fluxdata#7869) * Add input float types FIXED/UFIXED (influxdata#7317)
Relevant telegraf.conf:
Related issue: #7266.
The register holds a temperature scaled 10x. I want to store the decimals so I use FLOAT32.
When the temperature outdoors is 5.3° the register holds the int 53, and I want to use scaling to store 5.3.
When the temperature is below 0° the register holds a signed integer representing a negative value.
The problem is when the modbus plugin treats negative values.
Expected behavior:
The modbus plugin should handle negative values as well as positive. When the register holds -13 it should be intepreted as -1.3 after scaling.
Actual behavior:
Negative values are treated as unsigned. With a few negative degrees it stores the float 6554.0.
I see no way around this in telegraf except using the type INT16 instead of FLOAT32 and thus throw away the decimals.
Additional info:
FLOAT32 is handled here. It assumes a UINT16 but INT16 values are also possible.
The text was updated successfully, but these errors were encountered: