Fishwaldo opened a new pull request, #20203: URL: https://github.com/apache/nuttx/pull/20203
## Summary Five messages in `include/nuttx/uorb.h` declare their measurement as `float`: voltage, current, power, resistance and conductivity. Every other message declares `sensor_data_t`, which is `b16_t` under `CONFIG_SENSORS_USE_B16` and `float` otherwise. A driver that computes in `sensor_data_t`, as the helpers in `fixedmath.h` encourage, then assigns a `b16_t` into a `float` field. The raw fixed point integer is stored as a float, so the reading is wrong by a factor of 65536 and nothing diagnoses it. `sensor_energy` and `sensor_charge` keep `int64_t`. Energy in uJ and charge in uC are counts of micro units rather than measurements, so the fixed point option does not apply to them. ## Impact Header only. No change to structure size in either configuration, since `b16_t` is `int32_t` and both are 4 bytes, so there is no ABI break. No in-tree consumer changes behaviour: the only references to these five structures outside `uorb.h` are the `sizeof` entries in the metadata table in `drivers/sensors/sensor.c`. With `CONFIG_SENSORS_USE_B16=n`, the default, `sensor_data_t` is `float` and the structures are byte for byte what they were. Out-of-tree drivers that assign a raw `float` to these fields on a fixed point configuration need the same conversion helpers every other sensor type already uses. ## Testing Built and booted on an ESWIN EIC7700 EVB (kernel build, `CONFIG_SENSORS_USE_B16=n`). Voltage, current and power read through `sensortest` from an MPQ8785 regulator and four INA226 rails; readings are self consistent, with P = V x I holding on each rail that reports current (0.80 V x 0.41 A = 0.33 W, 12.03 V x 0.73 A = 8.78 W). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
