Skip to content

Conversation

@Otpvondoiats
Copy link
Contributor

@Otpvondoiats Otpvondoiats commented Jan 29, 2026

Summary

This patch series adds a comprehensive sensor monitoring and debug logging framework to improve observability and troubleshooting capabilities for sensor drivers in multi-core RPMSG scenarios.

Motivation
Debugging sensor issues in production systems, especially in multi-core environments with RPMSG communication, is challenging due to:

Limited visibility into sensor state transitions
Difficulty tracking data flow between cores
Lack of per-topic logging granularity
Hard to diagnose timing and synchronization issues
This patch introduces a flexible, topic-specific logging framework that allows runtime monitoring of sensor operations without requiring recompilation.

Impact

  • Users

Enhanced Debugging: Runtime visibility into sensor operations without code changes
Selective Monitoring: Enable logging only for specific topics of interest
Performance Diagnosis: Identify bottlenecks and timing issues
Production Support: Debug issues in deployed systems with minimal overhead

  • Development

Faster Troubleshooting: Quickly identify root causes of sensor issues
Better Testing: Comprehensive logs help verify correct behavior
RPMSG Debug: Clear visibility into multi-core communication
Code Quality: Standardized logging approach across sensor framework

  • Build Process

Optional Feature: Controlled by CONFIG_SENSORS_MONITOR config option
Zero Overhead: When disabled, macros compile to nothing (no runtime cost)
Minimal Size: Small code size increase when enabled (~2KB)

  • Performance

Negligible Impact: Logging only active for monitored topics
Efficient Macros: Compile-time conditionals eliminate runtime checks when disabled
Controlled Output: Per-topic log levels prevent log spam

  • Compatibility

Backward Compatible: No API changes, purely additive
Configurable: Can be completely disabled for production if needed
Flexible: Log levels adjustable per topic at runtime

Testing

uorb_listener -n 10 algo_off_body0
[22/01/26 05:46:11.422119] [185] [ap] sensor_open: [topic: algo_off_body0] user address: 0x19bee650, role type: 2, user generation: 0, upper generation: 1, nsubscribers: 4, nadvertisers: 0, persist: 1
[22/01/26 05:46:11.424378] [185] [ap] sensor_close: [topic: algo_off_body0] user address: 0x19bee650, close subscriber: 3, close advertiser:0
[22/01/26 05:46:11.425965] [185] [ap] sensor_open: [topic: algo_off_body0] user address: 0x19e32dd0, role type: 0, user generation: 0, upper generation: 1, nsubscribers: 3, nadvertisers: 0, persist: 1
[22/01/26 05:46:11.428101] [185] [ap] sensor_close: [topic: algo_off_body0] user address: 0x19e32dd0, close subscriber: 3, close advertiser:0
Mointor objects num:1
object_name:algo_off_body, object_instance:0
[22/01/26 05:46:11.429871] [185] [ap] sensor_open: [topic: algo_off_body0] user address: 0x19e32e10, role type: 2, user generation: 0, upper generation: 1, nsubscribers: 4, nadvertisers: 0, persist: 1
[22/01/26 05:46:11.432739] [185] [ap] sensor_do_samples: [topic: algo_off_body0] do sample interval:1, user.generation:1, ret:16
[22/01/26 05:46:11.434143] [185] [ap] sensor_read: [topic: algo_off_body0] the number of read event is:1
algo_off_body(now:6532014587):timestamp:1769054261561,is_wrist:1
Waited for 5 seconds without a message. Giving up. err:2
[22/01/26 05:46:16.441528] [185] [ap] sensor_close: [topic: algo_off_body0] user address: 0x19e32e10, close subscriber: 3, close advertiser:0
Object name:algo_off_body0, recieved:1
Total number of received Message:1/10

debug patch to monitor some sensor topic.

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
add flush sensor monitor log

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
@github-actions github-actions bot added Area: Sensors Sensors issues Size: S The size of the change in this PR is small labels Jan 29, 2026
@Otpvondoiats Otpvondoiats changed the title Lk m drivers/sensors: add sensor monitor debug log. part 7 Jan 29, 2026
@Donny9 Donny9 merged commit 54cdd8c into apache:master Jan 29, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Sensors Sensors issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants