Skip to content

system/uorb: Show listener data without CONFIG_DEBUG_UORB#3524

Open
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/uorb-listener-no-debug
Open

system/uorb: Show listener data without CONFIG_DEBUG_UORB#3524
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/uorb-listener-no-debug

Conversation

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor

@Zepp-Hanzj Zepp-Hanzj commented Jun 4, 2026

Note: Please adhere to Contributing Guidelines.

Summary

Currently, format strings (o_format), orb_info(), orb_fprintf(), and orb_sscanf() are guarded by #ifdef CONFIG_DEBUG_UORB. This prevents uorb_listener from displaying sensor data when debug output is disabled.

Introduce a new CONFIG_UORB_FORMAT Kconfig option to control whether 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. Users who don't need any of these features get no image size increase.

Fixes apache/nuttx-apps#3201.

Impact

  • Is new feature?: YES (new Kconfig option CONFIG_UORB_FORMAT)
  • Impact on user?: YES (users can now see sensor data with uorb_listener without enabling CONFIG_DEBUG_UORB)
  • Impact on build?: NO (only adds a new Kconfig option, no build system changes)
  • Impact on hardware?: NO
  • Impact on documentation?: NO
  • Impact on security?: NO
  • Impact on compatibility?: NO (existing configs with CONFIG_DEBUG_UORB or CONFIG_UORB_LISTENER continue to work as before)

Testing

Host: Linux x86_64, sim:nsh

Config:

CONFIG_USENSOR=y
CONFIG_UORB=y
CONFIG_UORB_LISTENER=y
CONFIG_UORB_GENERATOR=y
CONFIG_SENSORS=y
CONFIG_SENSORS_FAKESENSOR=y
CONFIG_LINE_MAX=256
CONFIG_NSH_MAXARGUMENTS=16

Steps:

nsh> uorb_generator -n 100000 -r 10 -s -t sensor_accel0 timestamp:1,x:1,y:1,z:1,temperature:1 &
nsh> sleep 3
nsh> uorb_listener -T -l

Before fix (with CONFIG_DEBUG_UORB disabled):

current objects: 1
NAME                           INST #SUB RATE #Q SIZE
sensor_accel                    0    0    0  0   24

After fix:

current objects: 1
NAME                           INST #SUB RATE #Q SIZE
sensor_accel                    0    0    8  1   24

Also verified: with only CONFIG_UORB enabled (no LISTENER/GENERATOR/DEBUG_UORB), CONFIG_UORB_FORMAT is not selected and format strings are excluded from the build.

* Private Functions
****************************************************************************/

#ifdef CONFIG_DEBUG_UORB
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it will increase the image size and no method to remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's a better approach.

@Zepp-Hanzj Zepp-Hanzj force-pushed the fix/uorb-listener-no-debug branch 2 times, most recently from ddec6e9 to 96cf67f Compare June 5, 2026 02:16
@linguini1
Copy link
Copy Markdown
Contributor

Verified on sim:nsh with CONFIG_DEBUG_UORB disabled

How? There is no uORB accelerometer on sim:nsh

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>
@Zepp-Hanzj Zepp-Hanzj force-pushed the fix/uorb-listener-no-debug branch from 96cf67f to 8ccc4f4 Compare June 5, 2026 15:57
@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

Good catch. Fixed by adding select UORB_FORMAT to UORB_GENERATOR in Kconfig. Generator needs format strings to parse input, so it can't work without them.

Also updated the PR to follow the template. Updated code and PR body are now pushed.

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

We use CONFIG_SENSORS_FAKESENSOR=y which provides a fake accelerometer sensor on sim. Then use uorb_generator to publish data to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] uorb_listener doesn't report data unless DEBUG_UORB is true

3 participants