Brijesh-Thakkar opened a new pull request, #21537: URL: https://github.com/apache/nuttx/pull/21537
## Summary With `CONFIG_SENSORS_USE_B16` the uORB listener and generator still print and parse `%hf` as a float, while the sensor data is `b16_t`. Add `LIBC_BFORMAT_B16`: `%hf` in lib_bsprintf()/lib_bscanf() is a `b16_t` (16.16 fixed-point), selected by `SENSORS_USE_B16`. Printing uses `b16tod()` (integer.fraction without `LIBC_FLOATINGPOINT`); scanning rounds to the nearest `b16_t`. Related: #17365. Alternative: keep %hf as float and add a separate specifier; happy to switch if preferred. First commit is nxstyle-only (identical object code) so the functional change stays reviewable. ## Impact Only builds with `LIBC_BFORMAT_B16` (so `SENSORS_USE_B16`) change: out-of-tree code that uses `%hf` for a real float in a binary format string now gets `b16_t`. Regular `sscanf()` and builds without the option are unchanged. `%hf` has no other in-tree users than uORB. Docs updated (stream.rst, sensors_uorb.rst). Scanning `%hf` still needs `LIBC_FLOATINGPOINT`; without it it is not supported, as for float. ## Testing Runtime-tested on sim (no hardware involved; libc change). Host sim, `sim:baromonitor` + `UORB_FORMAT`; for B16 `SENSORS_USE_B16=y` with fakesensor and the baromonitor example disabled. Commands: `uorb_generator -n 20 -r 5 -s -t sensor_baro0 timestamp:1,pressure:999.12,temperature:26.34 &`, `uorb_listener sensor_baro0 -n 5`, then `dd if=/dev/uorb/sensor_baro0 of=/data/baro.bin bs=16 count=1; hexdump /data/baro.bin`. Raw bytes stored by `uorb_generator` (pressure 999.12 / temperature 26.34), B16 build: | | stored pressure | stored temperature | read as b16_t | listener prints | |---|---|---|---|---| | upstream | `0x4479c7ae` (float) | float bits | 17529.78 (wrong) | 999.119995 / 26.340000 | | this branch | `0x03e71eb8` | `0x001a570a` | 999.12 / 26.34 | 999.119995 / 26.339996 | 26.339996 is the nearest b16_t to 26.34. Float build diff: with `SENSORS_USE_B16` unset, output is identical to upstream (timestamps aside), 16/16 listener lines `999.119995 / 26.340000` in both. No-FP printing path (`LIBC_FLOATINGPOINT` unset): built only, not run (exit 0, no warnings). All runs repeated on the final tip, rebased on upstream/master. `checkpatch.sh -c -u -m -g upstream/master..HEAD` passes. The nxstyle commit compiles to identical object code (objdump -d identical; byte-identical after `objcopy --strip-debug`). Logs: `logs-libc-bformat-b16/` (to attach). -- 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]
