• English
  • Debug with EmbedScope

    EmbedScope provides a desktop Inspector, the escope CLI, and a Rust host SDK for device identity, logs, metrics, UI trees, display capture, and input reproduction. An rs_lvgl application reuses its existing LVGL instance and handles inspection on the UI thread.

    Diagnostics require an explicit application choice. Default rs_lvgl and rs_lvgl_ui builds do not create an Agent, start a server, or enumerate a diagnostic USB interface.

    When to enable and disable diagnostics

    ScenarioRecommended configurationResult
    UI development, layout and interaction diagnosisEnable the application's embedscope featureThe Inspector can access implemented platform capabilities
    Reproduce a problem that needs optimization--release --features embedscopeRelease optimization with diagnostics retained
    Ship firmware or an application--release, without selecting embedscopeAgent, diagnostic transport and associated capture buffers are omitted
    Finish a session while keeping the diagnostic build runningDisconnect the Inspector or CLISession resources are released; the compiled Agent remains

    --release does not disable diagnostics. Cargo features and optimization profiles are independent, and features are unified across dependencies. Avoid --all-features for production. Check whether another dependency, build script, or workspace command enables diagnostics again.

    A device continues running its installed image after a feature-disabled build. Install and boot that new image to remove the running Agent and diagnostic USB interface.

    Run the native integration example

    The rs_lvgl 0.8 and EmbedScope 0.6.0 example renders a counter and a brightness slider into a 320 × 240 LVGL memory display. Inspector shows the RGB888 flush output. Reference application

    Install the CLI and Inspector from EmbedScope 0.6.0. The example builds with Rust, a native C compiler and libclang. Run it from the rs_lvgl repository root.

    cargo run --manifest-path examples/embedscope/Cargo.toml --features embedscope

    The default endpoint is tcp://127.0.0.1:9338. The tree reports the current pixel locations of settings.increment and action:settings.brightness. Choose a new filename for each capture.

    escope -d tcp://127.0.0.1:9338 --json info
    escope -d tcp://127.0.0.1:9338 --json ui tree
    escope -d tcp://127.0.0.1:9338 display capture settings.png

    Connect Inspector 0.6 to the same endpoint after the CLI exits. Enable Send taps and click near the middle of the brightness slider. Last observed action reports the outcome and shows the completed frame number when the preview matches. The example includes presets for rejection and an unconfirmed preview. Reproduction steps

    Give the application one explicit switch

    embedscope is an application feature in the example and Dango OS. It is not a built-in rs_lvgl_ui feature. An application can use:

    [features]
    default = []
    embedscope = [
      "dep:escope-protocol",
      "dep:escope-agent",
      "dep:escope-lvgl",
      "rs_lvgl_ui/diagnostics",
    ]
    
    [dependencies]
    escope-protocol = { version = "0.6.0", optional = true }
    escope-agent = { version = "0.6.0", optional = true }
    escope-lvgl = { version = "0.6.0", default-features = false, optional = true }

    Keep the application's existing rs_lvgl_ui dependency/configuration. Gate the diagnostic modules, initialization, buffers, log fan-out and transport behind #[cfg(feature = "embedscope")]. Selecting dependencies makes APIs available; the application still implements Backend and byte transport.

    Applications using escope-lvgl 0.6/native for NativeTree share the rs_lvgl_sys 0.8 provider, source and configuration.

    These related switches have distinct purposes:

    Feature / APIPurpose
    Application embedscopeSelect Agent, transport, platform Backend and diagnostic buffers
    rs_lvgl_ui/diagnosticsStructured UI events and set_diagnostic_sink; opens no port
    rs_lvgl_ui/strict-propertiesReject modifiers unsupported by their widget; changes error behavior
    rs_lvgl_ui/update-metricsAdditional UI update statistics; no remote connection

    Connect a physical device

    Reuse the application's executor, display and input drivers. Transport tasks exchange frames and queue bounded requests. The UI loop executes Backend operations at a safe point after layout, updates and native callbacks.

    • Keep every LVGL access on the UI thread. Stop reads and drop the tree adapter before deleting its root. Advance revision after native changes; do not reuse node IDs or cursors across session/revision boundaries.
    • Use one native provider, ABI and configuration. The example uses registry dependencies throughout. Unify sources before mixing path and registry providers, or use default escope-lvgl with an application TreeSource that does not link another LVGL.
    • Capture an independently owned fixed frame. State whether it comes from a subtree, final display submission or panel readback. Direct drawing and transitions usually need the platform's final output path.
    • Route injected input through system input arbitration with paired press/release. Disconnect, cancellation and shutdown release input, capture and stale-session queues.
    • Fan out structured records from the existing logger before formatting. Keep unmeasured metrics null and advertise implemented capabilities only.

    See EmbedScope Rust integration and LVGL integration for platform interfaces.

    Dango OS

    Dango OS is a Rust embedded system for ESP-Mosaico with a companion Home screen, native settings and Lua applications. Its adapter uses a second USB CDC for EmbedScope while preserving the console, application installation and OTA.

    In a Dango checkout containing the adapter:

    # Diagnostic firmware: release optimization with EmbedScope
    cargo fw --features embedscope
    
    # Normal shipping firmware: release optimization without EmbedScope
    cargo fw

    cargo fw already includes --release. Install the diagnostic image with Dango tooling, then connect to the enumerated second CDC with --dtr on. Follow the EmbedScope Dango OS guide for integration, port selection, and native/Lua screen diagnosis.

    Verify a production build

    For the native example:

    cargo build --manifest-path examples/embedscope/Cargo.toml --release
    cargo tree --manifest-path examples/embedscope/Cargo.toml --edges normal,build

    The normal/build dependency graph should contain no escope-* when diagnostics are disabled. For firmware, also inspect the final linked artifact, USB descriptors and interfaces after boot. A disconnected Inspector does not establish removal. Switching features reuses Cargo's appropriate cached artifacts; cargo clean is unnecessary.

    Run the native integration acceptance test with:

    cargo test --manifest-path examples/embedscope/Cargo.toml --features embedscope -- --test-threads=1

    It covers real native tree/pixels, input-driven state changes, logs, fixed capture, malformed frames, reconnect cleanup and ordered shutdown. Physical display, touch and device transport acceptance remain target-project checks.