You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "acassis (via GitHub)" <gi...@apache.org> on 2025/11/22 23:04:27 UTC

[I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

acassis opened a new issue, #17365:
URL: https://github.com/apache/nuttx/issues/17365

   ### Is your feature request related to a problem? Please describe.
   
   As discussed here: https://github.com/apache/nuttx/pull/17363 adding support to character device sensor and uORB sensor is non ideal. Although there are "natural" pressure in favor on uORB sensor, they are not the best option for small microcontrollers with few KBs of RAM.
   
   ### Describe the solution you'd like
   
   I truly believe it is possible to solve this issue creating uORB drivers as a wrapper around character device sensors. It could avoid duplication of driver development and simplify the development.
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
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: commits-unsubscribe@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "Brijesh-Thakkar (via GitHub) via commits" <co...@nuttx.apache.org>.
Brijesh-Thakkar commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-6688579281

   opened #21521  to add the #error guard to ccs811, lis3dsh_uorb, qmi8658 and nau7802. correction to my last comment: msa301 is a legacy driver, not affected.
   one more thing i would love to share is system/uorb’s sensor formatters are all %hf, so with SENSORS_USE_B16 uorb_listener prints wrong values and there’s no way to check b16 data on sim. would a PR adding b16 printing to the listener (nuttx-apps) be welcome?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3568201556

   > > [@raiden00pl](https://github.com/raiden00pl) [@xiaoxiang781216](https://github.com/xiaoxiang781216) [@linguini1](https://github.com/linguini1) what is we define the type of sensor data to be float when !DEFAULT_SMALL and int when DEFAULT_SMALL (assuming that uORB will not be used on DEFAULT_SMALL) ?
   > 
   > I think unfortunately it will require more work than that. There a few gotchas:
   > 
   >     1. We immediately lose floating point values, so it's no longer possible for, say, an accelerometer to measure in m/s^2 unless you only want 1 m/s^2 resolution. So, all the fields will have to change from SI units to maybe something like 0.001 of an SI unit? And we'll need a large enough field, like an i32, to represent enough values.
   > 
   >     2. Application level code must now handle two cases: when uORB uses floating point and when uORB uses integers.
   > 
   > 
   > You could maybe duplicate structure definitions for the uORB types and have one with float and one with int, but the user still needs to handle two distinct cases.
   
   1. True, it is an issue to be fixed.
   2. No, the idea is not to use it with uORB when CONFIG_DEFAULT_SMALL is selected, so the driver will be used as a char device sensor


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "Brijesh-Thakkar (via GitHub) via commits" <co...@nuttx.apache.org>.
Brijesh-Thakkar commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-6543305289

   sorry, I missed that b16 support from #17408 is already in. I checked current master with SENSORS_USE_B16: 22 framework drivers still #error on fixed-point, and ccs811, lis3dsh_uorb, qmi8658, msa301 and nau7802 compile without a guard but assign float to sensor_data_t (e.g. qmi8658_uorb.c:1286), so they silently return garbage.
   
   is the remaining work here converting those drivers to sensor_data_t (and later dropping the deprecated legacy twins)? I’d like to raise send a small PR adding the #error guard to the 5 silent ones, then convert bmp180_uorb, bmi160_uorb and ds18b20


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3568326590

   > But that is still a problem? Now we have two different sensor driver frameworks to maintain on NuttX. Like [@raiden00pl](https://github.com/raiden00pl) mentioned, "uORB" devices can still be interacted with as character drivers. I guess the confusion here is that I am referring to the new sensor framework as uORB, even though it is technically not dependent on that (mentioned in [#10644](https://github.com/apache/nuttx/issues/10644)). I think if users want a character driver, they should interact with the sensor framework devices as character devices instead of through uORB. That way there is still only one framework. The only problem is float dependency. I am firmly against maintaining two different types of frameworks, I would rather solve the float problem.
   > 
   > I guess we should stop referring to the framework as uORB, since uORB is an optional extension. In fact, there at least a few drivers I've contributed where I added `depends on UORB` where really it doesn't they can be used as char drivers.
   
   True, I think the idea of using the sensor driver that works for uORB as a char device will meet the goal of this Feature Request, we just need to fix the float issue and organize the driver to not include UORB features/functions, could depends on CONFIG_SENSORS_UORB or similar


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3568313218

   But that is still a problem? Now we have two different sensor driver frameworks to maintain on NuttX. Like @raiden00pl mentioned, "uORB" devices can still be interacted with as character drivers. I guess the confusion here is that I am referring to the new sensor framework as uORB, even though it is technically not dependent on that (mentioned in #10644). I think if users want a character driver, they should interact with the sensor framework devices as character devices instead of through uORB. That way there is still only one framework. The only problem is float dependency. I am firmly against maintaining two different types of frameworks, I would rather solve the float problem.
   
   I guess we should stop referring to the framework as uORB, since uORB is an optional extension. In fact, there at least a few drivers I've contributed where I added `depends on UORB` where really it doesn't they can be used as char drivers.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3567803356

   @raiden00pl @xiaoxiang781216 @linguini1 what is we defined the type of sensor data to be float when !DEFAULT_SMALL and int when DEFAULT_SMALL ?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3570518237

   > We immediately lose floating point values, so it's no longer possible for, say, an accelerometer to measure in m/s^2 unless you only want 1 m/s^2 resolution. So, all the fields will have to change from SI units to maybe something like 0.001 of an SI unit? And we'll need a large enough field, like an i32, to represent enough values.
   
   @linguini1  that's why I proposed that we should use fixedpoint math already present in NuttX (include/fixedmath.h). In this way, by using a macro to define mathematical operations we should be able to create portable code: https://github.com/apache/nuttx/issues/10644#issuecomment-2592061754
   
   If any unit already used with float implementation doesn't fit for fixedmath, we should change the unit used in float so that both versions of the framework use the same one.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3568035199

   > @raiden00pl @xiaoxiang781216 @linguini1 what is we define the type of sensor data to be float when !DEFAULT_SMALL and int when DEFAULT_SMALL (assuming that uORB will not be used on DEFAULT_SMALL) ?
   
   I think unfortunately it will require more work than that. There a few gotchas:
   
   1. We immediately lose floating point values, so it's no longer possible for, say, an accelerometer to measure in m/s^2 unless you only want 1 m/s^2 resolution. So, all the fields will have to change from SI units to maybe something like 0.001 of an SI unit? And we'll need a large enough field, like an i32, to represent enough values.
   
   2. Application level code must now handle two cases: when uORB uses floating point and when uORB uses integers.
   
   You could maybe duplicate structure definitions for the uORB types and have one with float and one with int, but the user still needs to handle two distinct cases.
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3567137182

   the new sensor framework is a character driver and can be used without urob. You can even use fetch interface without polling thread. So I think this issue is already solved :) the only problem I see for small systems is the use of float to represent sensor data, which I mention in https://github.com/apache/nuttx/issues/10644


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "Brijesh-Thakkar (via GitHub) via commits" <co...@nuttx.apache.org>.
Brijesh-Thakkar commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-6703910551

   Follow-up on the listener idea: the issue is actually in libc, not the apps. `%hf` in binary format strings is always treated as a float, so under `SENSORS_USE_B16`, uorb_generator ends up storing float bits in `b16_t` fields.
   
   For example, `999.12` becomes `0x4479c7ae`, which is read as `17529.78` in b16.
   
   The listener only looks correct because it's making the same mistake while reading it.
   
   I've opened #21537 to fix this at the libc level. `%hf` now follows the `LIBC_BFORMAT_B16` option, which is selected by `SENSORS_USE_B16`. I've also tested it at runtime on `sim:baromonitor`.
   
   If you'd prefer to keep `%hf` as float and introduce a separate specifier, I'm happy to change it.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-3570729847

   > @linguini1  that's why I proposed that we should use fixedpoint math already present in NuttX (include/fixedmath.h). In this way, by using a macro to define mathematical operations we should be able to create portable code: https://github.com/apache/nuttx/issues/10644#issuecomment-2592061754
   > 
   > If any unit already used with float implementation doesn't fit for fixedmath, we should change the unit used in float so that both versions of the framework use the same one.
   
   This would be a breaking change that in my opinion is very worth it! Good idea!


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "Brijesh-Thakkar (via GitHub) via commits" <co...@nuttx.apache.org>.
Brijesh-Thakkar commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-6542532459

   Hi, following the direction agreed above (single sensor framework, fixed-point via include/fixedmath.h as proposed in #10644), I’d like to work on this. I don’t see anyone on it in open PRs.
   
   Add a Kconfig option (e.g. SENSORS_FIXEDPOINT, default off, maybe default y with DEFAULT_SMALL) and a sensor value type plus conversion macros, with no behavior change for float builds.
   Convert the sensor_* structs to that type, adjusting units where b16_t range or resolution doesn’t fit, so float and fixed builds share units.
   Convert the core (drivers/sensors/sensor.c) and a fake/sim sensor so it’s testable on sim, then migrate drivers in small batches.
   Decouple drivers that depends on UORB but only need the char interface.
   
   Questions:
   
   Is b16_t enough, or should some quantities (e.g. pressure, timestamps-adjacent values) use a wider type?
   Should the unit changes land as one breaking PR, or behind the Kconfig first?
   
   cc @raiden00pl @linguini1 @acassis


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [FEATURE] Create a way to integrate uORB sensors as wrapper around character device sensor to avoid duplication [nuttx]

Posted by "raiden00pl (via GitHub) via commits" <co...@nuttx.apache.org>.
raiden00pl commented on issue #17365:
URL: https://github.com/apache/nuttx/issues/17365#issuecomment-6542601290

   @Brijesh-Thakkar I don't get what you're asking. b16_t support is already done. Did you even look at the code?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org