-
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
Fix/extend support of fixed point values on input (modbus plugin) #7869
Conversation
Two main thoughts:
|
No, this change should not break anything for now. It just adds new types FIXED and UFIXED. The behaviour for all existing types, especially for FLOAT32 is (supposed to be) unchanged and therefore all existing configurations should work as they do currently.
The FLOAT32 reads an integer value from modbus registers, converts this integer value to a float value, applies the given scale (by multiplication of the float value with the configured scale value), and stores the result as a floating point type. When the sign bit of the input value from modbus registers is set, the result of the conversion from int to float will be different depending on the type of the input: for signed integers, the conversion must result in negative values, while for unsigned integers, the sign bit is the MSB of a positive value and thus the result must be a (large) positive value. Therefore we must be able to specify in configuration, which of these cases should be applied (it cannot be determined automatically, since there is no indication from modbus which one is the right one.) Example:
(Please note that this is something else than FLOAT32-IEEE, which directly reads the bits from modbus registers into a float32 variable, without interpreting the bits as integer in the first place.) And the need for both convertions is reality. I'm currently working with a modbus device, which uses both variants (signed and unsigned) with different scaling values in many combinations:
Here S32/U32 specifies INT32 and UINT32 resp., and FIX3, FIX2,... specifies the number of decimal digits contained in the integer value. |
I've just re-checked again, it seems that I made a mistake in handling of FLOAT32 data type. Please assume this PR on hold until I've verified and probably corrected this. (The current state might be a breaking change for other users.) |
The last commit fixes the break that I've introduced. With this commit the type FLOAT32 is handled identical to UFIXED, which is how it is handled in the current main branch. I have verified this by running the new unit tests with the code from the main branch. (The confusion came from PR #7488, which tried to introduced a breaking change. And after that I didn't realize that I had incorporated the idea of that change into my brain.) |
Failing checks are not related to modbus plugin, and (seem to) do not fail in main branch. Can I force a re-run of the checks somehow? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the typo it looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
) * Add input float types FIXED/UFIXED (#7317)
…fluxdata#7869) * Add input float types FIXED/UFIXED (influxdata#7317)
…fluxdata#7869) * Add input float types FIXED/UFIXED (influxdata#7317)
Required for all PRs:
This is a fix/extension for #7317, and it presumably superseedes PR #7488 (except for range validation)
The change introduces new input type FIXED and UNFIXED, and deprecates usage of the type FIXED32 (in docs only)