FelipeMdeO opened a new pull request, #3686:
URL: https://github.com/apache/nuttx-apps/pull/3686

   ## Summary
   
   `uorb_listener` never showed data for a sensor whose lower half only
   implements `fetch()` (the usual case for an I2C part with no interrupt
   line wired, e.g. the MPU6050): `orb_subscribe_multi()` opens the
   descriptor blocking, and a fetch()-only sensor never pushes a sample
   into the circular buffer, so `sensor_poll()`/`sensor_read()` wait
   forever. The 5-second timeout was silent and indistinguishable from a
   sensor that genuinely has nothing to report.
   
   Four fixes, one per commit:
   
   * Set `O_NONBLOCK` on the descriptor after subscribing — the core fix,
     makes fetch()-only sensors visible to the listener at all.
   * Honor the requested rate (`-r`) for fetch()-only sensors — the upper
     half only applies `SNIOC_SET_INTERVAL` to pushed samples, so without
     this the loop read as fast as it could run.
   * Select `LIBC_PRINT_EXTENSION` from `UORB_FORMAT` — without it,
     `orb_info()`'s `"%pB"` extension printed the raw buffer address
     instead of the decoded data.
   * Raise the default `UORB_STACKSIZE` to 4096 when `UORB_FORMAT` is
     enabled — the nested `"%pB"` formatting pass peaked at ~2.2KB
     (measured with `STACK_COLORATION`), overflowing the 2048 byte
     default and corrupting memory outside the task rather than failing
     cleanly.
   
   ## Impact
   
   Affects any board using `uorb_listener` on a uORB sensor whose lower
   half only implements `fetch()`. Push-based sensors are unaffected:
   neither `sensor_poll()` nor `sensor_read()` consults `O_NONBLOCK` on
   that path. `UORB_STACKSIZE` default only changes for configs that
   already select `UORB_FORMAT` (i.e. already use the listener).
   
   ## Testing
   
   Target: ESP32-S3-DevKitC (N16R8) with a GY-521 (MPU6050) on I2C0 (SDA
   GPIO5 / SCL GPIO4), `esp32s3-devkit:mpu6050` defconfig
   (`EXAMPLES_SENSOR_FUSION` disabled just for this test, since it needs
   a separate unmerged fix and is unrelated to this bug).
   
   Before (apps master, `5f286fc92`, without this fix):
   
   ```
       nsh> uorb_listener -n 5 sensor_accel0
       Monitor objects num:1
       object_name:sensor_accel, object_instance:0
       Waited for 5 seconds without a message. Giving up. err:0
       Object name:sensor_accel0, received:0
       Total number of received Message:0/5
   ```
   
   The sensor was confirmed alive and publishing via `sensortest` at the
   same time.
   
   After (this branch, `6fe80c8ad`):
   
   ```
       nsh> uorb_listener -n 5 sensor_accel0
       Monitor objects num:1
       object_name:sensor_accel, object_instance:0
       
sensor_accel(now:10940000):timestamp:10940000,x:0.045489,y:-0.435745,z:10.307038,temperature:26.365292
       
sensor_accel(now:10940000):timestamp:10940000,x:-0.043095,y:-0.426168,z:10.268731,temperature:26.506470
       
sensor_accel(now:10950000):timestamp:10950000,x:0.019153,y:-0.418985,z:10.127473,temperature:26.412352
       
sensor_accel(now:10960000):timestamp:10960000,x:-0.014365,y:-0.462081,z:10.129868,temperature:26.412352
       
sensor_accel(now:10970000):timestamp:10970000,x:-0.004788,y:-0.416591,z:10.165780,temperature:26.506470
       Object name:sensor_accel0, received:5
       Total number of received Message:5/5
   
       nsh> uorb_listener -n 3 -r 10 sensor_accel0,sensor_gyro0
       Monitor objects num:2
       object_name:sensor_gyro, object_instance:0
       object_name:sensor_accel, object_instance:0
       
sensor_gyro(now:28020000):timestamp:28020000,x:-0.010791,y:0.031042,z:0.693735,temperature:26.318233
       
sensor_accel(now:28020000):timestamp:28020000,x:-0.043095,y:-0.440533,z:10.170568,temperature:25.847645
       
sensor_gyro(now:28130000):timestamp:28130000,x:-0.015987,y:0.027978,z:-0.013989,temperature:26.035881
       Object name:sensor_gyro0, received:2
       Object name:sensor_accel0, received:1
       Total number of received Message:3/3
   ```
   
   Accelerometer Z reads gravity with the board resting flat, gyroscope
   reads near zero, both topics interleave correctly, and the 10 Hz rate
   requested with `-r` is honored (~110ms between samples).
   


-- 
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]

Reply via email to