Skip to content

system/uorb: fix listener_top not showing topic data#3527

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/uorb-listener-top-no-output
Jun 6, 2026
Merged

system/uorb: fix listener_top not showing topic data#3527
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/uorb-listener-top-no-output

Conversation

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor

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

Note: Please adhere to Contributing Guidelines.

Summary

uorb_listener -T (top mode) only displays the header row but no topic data. This is because listener_update() only prints topic data when delta_generation && delta_time is true (new data arrived since the last check). On the first iteration, objects are added to the list but no data is printed. On subsequent iterations, if no new data has been published between calls, delta_generation == 0 and the topic row is silently skipped.

Fix by moving the uorbinfo_raw() call and timestamp/generation update outside the conditional block, and initializing frequency = 0 before the check. This ensures the topic row is always printed, with frequency showing 0 when no new data is available.

Fixes apache/nuttx-apps#3202.

Impact

  • Is new feature?: NO (bug fix)
  • Impact on user?: YES (users can now see topic data in uorb_listener -T top mode)
  • Impact on build?: NO
  • Impact on hardware?: NO
  • Impact on documentation?: NO
  • Impact on security?: NO
  • Impact on compatibility?: NO

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_DEBUG_UORB=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:

current objects: 1
NAME                           INST #SUB RATE #Q SIZE

After fix:

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

Comment thread system/nxinit/parser.c
@linguini1
Copy link
Copy Markdown
Contributor

When I try to compile your configuration I get this error:

CP:  /home/linguini/coding/nuttx-space/nuttx/include/nuttx/config.h
CC:  grp/lib_getgrbuf.c generator.c: In function ‘replay_worker’:
generator.c:205:44: error: ‘const struct orb_metadata’ has no member named ‘o_format’
  205 |                        sensor_gen->obj.meta->o_format, data);
      |                                            ^~
generator.c: In function ‘fake_worker’:
generator.c:287:38: error: ‘const struct orb_metadata’ has no member named ‘o_format’
  287 |                  sensor_gen->obj.meta->o_format, data) < 0)
      |                                      ^~
make[2]: *** [/home/linguini/coding/nuttx-space/apps/Application.mk:330: generator.c.home.linguini.coding.nuttx-space.apps.system.uorb.o] Error 1
make[2]: *** Waiting for unfinished jobs....
IN: mm/libmm.a -> staging/libmm.a make[1]: *** [Makefile:54: /home/linguini/coding/nuttx-space/apps/system/uorb_all] Error 2
make[1]: *** Waiting for unfinished jobs....
CC:  pthread/pthread_mutexattr_setpshared.c make: *** [tools/LibTargets.mk:248: /home/linguini/coding/nuttx-space/apps/libapps.a] Error 2
make: *** Waiting for unfinished jobs....

@Zepp-Hanzj Zepp-Hanzj force-pushed the fix/uorb-listener-top-no-output branch from c092120 to 3b2a53a Compare June 5, 2026 15:50
listener_update() only prints topic data when delta_generation is
non-zero (i.e., new data arrived since last check). In listener_top,
the first call adds objects to the list, and subsequent calls only
print if new data was published between iterations. This results in
listener_top -T showing only the header with no topic rows.

Fix by always printing the current topic state in listener_update,
setting frequency to 0 when no new data arrives. This ensures
listener_top displays all topics every iteration.

Fixes apache#3202

Signed-off-by: hanzj <hanzhijian@zepp.com>
@Zepp-Hanzj Zepp-Hanzj force-pushed the fix/uorb-listener-top-no-output branch from 3b2a53a to 6b10fab Compare June 5, 2026 15:51
@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

When I try to compile your configuration I get this error:

CP:  /home/linguini/coding/nuttx-space/nuttx/include/nuttx/config.h
CC:  grp/lib_getgrbuf.c generator.c: In function ‘replay_worker’:
generator.c:205:44: error: ‘const struct orb_metadata’ has no member named ‘o_format’
  205 |                        sensor_gen->obj.meta->o_format, data);
      |                                            ^~
generator.c: In function ‘fake_worker’:
generator.c:287:38: error: ‘const struct orb_metadata’ has no member named ‘o_format’
  287 |                  sensor_gen->obj.meta->o_format, data) < 0)
      |                                      ^~
make[2]: *** [/home/linguini/coding/nuttx-space/apps/Application.mk:330: generator.c.home.linguini.coding.nuttx-space.apps.system.uorb.o] Error 1
make[2]: *** Waiting for unfinished jobs....
IN: mm/libmm.a -> staging/libmm.a make[1]: *** [Makefile:54: /home/linguini/coding/nuttx-space/apps/system/uorb_all] Error 2
make[1]: *** Waiting for unfinished jobs....
CC:  pthread/pthread_mutexattr_setpshared.c make: *** [tools/LibTargets.mk:248: /home/linguini/coding/nuttx-space/apps/libapps.a] Error 2
make: *** Waiting for unfinished jobs....

Sorry for the oversight. The compilation error occurs because generator.c uses o_format to parse sensor data from stdin, but CONFIG_UORB_FORMAT wasn't being selected when only UORB_GENERATOR was enabled.
Fixed by adding select UORB_FORMAT to UORB_GENERATOR in Kconfig. Verified locally:
Only UORB enabled → UORB_FORMAT not selected (no overhead)
UORB_GENERATOR enabled → UORB_FORMAT auto-selected, build passes
Thanks for catching this!

@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

I must sleep. It's 0:11 now in my zone.

@linguini1
Copy link
Copy Markdown
Contributor

linguini1 commented Jun 6, 2026

Do you mean UORB_DEBUG instead of UORB_FORMAT? I don't think UORB_FORMAT exists. We should probably fix the compilation error by default, that seems confusing.

Anyways, with your updated config option list I was able to reproduce your results!

@linguini1 linguini1 requested a review from xiaoxiang781216 June 6, 2026 03:20
@Zepp-Hanzj
Copy link
Copy Markdown
Contributor Author

image By the way, I wrote a tool — a WinDirStat-style treemap UI combined with MAP/ELF symbol and memory layout analysis for Windows. Not sure if it'd be useful for analyzing space usage in the NuttX project. https://github.com/Zepp-Hanzj/MemMapExplorer

@xiaoxiang781216 xiaoxiang781216 merged commit 8b4d20e into apache:master Jun 6, 2026
41 checks passed
@Zepp-Hanzj Zepp-Hanzj deleted the fix/uorb-listener-top-no-output branch June 6, 2026 10:49
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 top flag doesn't show any output

3 participants