system/uorb: Show listener data without CONFIG_DEBUG_UORB#3524
system/uorb: Show listener data without CONFIG_DEBUG_UORB#3524Zepp-Hanzj wants to merge 1 commit into
Conversation
| * Private Functions | ||
| ****************************************************************************/ | ||
|
|
||
| #ifdef CONFIG_DEBUG_UORB |
There was a problem hiding this comment.
but it will increase the image size and no method to remove it.
There was a problem hiding this comment.
You're right, I didn't think this through carefully. Removing all #ifdef CONFIG_DEBUG_UORB guards unconditionally will indeed increase the image size with no way to opt out.
Here's a revised approach I'd like to propose:
Introduce a new CONFIG_UORB_FORMAT option to control whether format strings are compiled in:
1.Add config UORB_FORMAT in system/uorb/Kconfig
2.CONFIG_DEBUG_UORB will select UORB_FORMAT (so debug output still works as before)
3.CONFIG_UORB_LISTENER will also select UORB_FORMAT (so listener can display data)
4.All #ifdef CONFIG_DEBUG_UORB guards around format strings, o_format field, orb_info()/orb_fprintf()/orb_sscanf() will be changed to #ifdef CONFIG_UORB_FORMAT
This way:
1.Debug + listener users: format strings are automatically included (same as before)
2.Neither debug nor listener users: format strings are excluded, no image size increase
3.Users can also manually disable UORB_FORMAT even with listener enabled, if they prefer smaller images and don't need formatted output
The changes would be ~6 locations in uORB.h, uORB.c, listener.c, Kconfig, plus 43 sensor files (simple CONFIG_DEBUG_UORB → CONFIG_UORB_FORMAT replacement).
Would this approach be acceptable?
There was a problem hiding this comment.
yes, it's a better approach.
ddec6e9 to
96cf67f
Compare
How? There is no uORB accelerometer on |
Introduce a new CONFIG_UORB_FORMAT Kconfig option to control whether uORB format strings are compiled in. UORB_LISTENER, UORB_GENERATOR, and DEBUG_UORB all select UORB_FORMAT automatically, so format strings are included when any of these features are enabled. This replaces the previous approach of guarding format strings with CONFIG_DEBUG_UORB, which prevented uorb_listener from displaying sensor data when debug output was disabled. Signed-off-by: hanzj <hanzjian@zepp.com>
96cf67f to
8ccc4f4
Compare
|
Good catch. Fixed by adding Also updated the PR to follow the template. Updated code and PR body are now pushed. |
|
We use |
Note: Please adhere to Contributing Guidelines.
Summary
Currently, format strings (
o_format),orb_info(),orb_fprintf(), andorb_sscanf()are guarded by#ifdef CONFIG_DEBUG_UORB. This preventsuorb_listenerfrom displaying sensor data when debug output is disabled.Introduce a new
CONFIG_UORB_FORMATKconfig option to control whether format strings are compiled in.UORB_LISTENER,UORB_GENERATOR, andDEBUG_UORBallselect UORB_FORMATautomatically, so format strings are included when any of these features are enabled. Users who don't need any of these features get no image size increase.Fixes apache/nuttx-apps#3201.
Impact
uorb_listenerwithout enablingCONFIG_DEBUG_UORB)CONFIG_DEBUG_UORBorCONFIG_UORB_LISTENERcontinue to work as before)Testing
Host: Linux x86_64, sim:nsh
Config:
Steps:
Before fix (with CONFIG_DEBUG_UORB disabled):
After fix:
Also verified: with only
CONFIG_UORBenabled (no LISTENER/GENERATOR/DEBUG_UORB),CONFIG_UORB_FORMATis not selected and format strings are excluded from the build.