Skip to content

refactor(cli): unify wire path through TelepathClient via RttTransport#6

Merged
tarotene merged 2 commits into
mainfrom
feat/cli-rtt-transport
May 20, 2026
Merged

refactor(cli): unify wire path through TelepathClient via RttTransport#6
tarotene merged 2 commits into
mainfrom
feat/cli-rtt-transport

Conversation

@tarotene

Copy link
Copy Markdown
Owner

Summary

  • Add tools/telepath-cli/src/rtt_transport.rs: RttTransport struct that owns Session + Rtt and implements std::io::Read + std::io::Write, bridging probe-rs's &mut Core-per-call API to the trait interface expected by TelepathClient
  • Remove inline COBS encode/decode, postcard serialize/deserialize, and 5-second read loop from cmd_ping; replace with TelepathClient::call_raw
  • Read::read busy-loops with 1ms sleep until data arrives, preventing read_exact from seeing Ok(0) as EOF; respects a configurable read_deadline (default: 5 seconds)
  • drain_debug_logs (RTT ch0 passthrough) moved into RttTransport and called from cmd_ping and the REPL loop via the new TelepathClient::transport_mut() accessor
  • Drop direct cobs, telepath-wire deps from telepath-cli/Cargo.toml; add telepath-host path dep

Test plan

  • cd tools/telepath-cli && cargo build — clean
  • cd tools/telepath-cli && cargo clippy -- -D warnings — clean
  • cd tools/telepath-cli && cargo fmt --check — clean
  • cargo build --workspace (root) — workspace unaffected; telepath-host re-compiles with transport_mut()
  • Hardware: cd examples/nrf52840-dk && cargo run --release then cd tools/telepath-cli && cargo run -- pingping -> 0xDEADBEEF

Hardware verification requires nRF52840-DK + J-Link.

Closes #2
References Stage A (A2) in #3

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 20, 2026 16:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors telepath-cli to route all RPC traffic through telepath-host::TelepathClient by introducing an RTT Read/Write adapter, eliminating duplicated framing/serde logic in the CLI.

Changes:

  • Added RttTransport (owning Session + Rtt) that implements std::io::Read + Write for probe-rs RTT I/O.
  • Updated telepath-cli ping and REPL to use TelepathClient::call_raw, plus a transport_mut() accessor to drain RTT debug logs.
  • Simplified CLI dependencies by removing direct telepath-wire and cobs usage in favor of telepath-host.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tools/telepath-cli/src/rtt_transport.rs Adds RTT adapter implementing Read/Write, deadline handling, and debug log draining.
tools/telepath-cli/src/main.rs Switches ping + REPL to use TelepathClient over RttTransport; removes inline wire/framing logic.
tools/telepath-cli/Cargo.toml Drops direct wire/framing deps; adds telepath-host dependency.
crates/telepath-host/src/lib.rs Adds TelepathClient::transport_mut() for side-channel transport access.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/telepath-cli/src/rtt_transport.rs
Comment thread tools/telepath-cli/src/rtt_transport.rs Outdated
Comment thread tools/telepath-cli/src/rtt_transport.rs Outdated
tarotene and others added 2 commits May 21, 2026 01:45
Replace inline COBS/postcard/RTT logic in cmd_ping with TelepathClient::call_raw.
Add RttTransport (tools/telepath-cli/src/rtt_transport.rs) that owns Session+Rtt
and implements std::io::Read+Write, bridging probe-rs's &mut Core per-call API to
the trait interface. Add transport_mut() to TelepathClient for side-channel access
(debug log draining). Remove direct cobs and telepath-wire deps from telepath-cli.

Closes #2
References Stage A (A2) in #3

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Read::read returns Ok(0) immediately when buf.is_empty() (std::io contract)
- TimedOut error message changed to "RTT read deadline exceeded"; no longer
  claims a fixed 5s value that the caller may have configured differently
- set_read_deadline doc clarified: deadline persists across all subsequent
  reads (correct for TelepathClient::call_raw's whole-RPC semantics);
  added clear_read_deadline() as the symmetric inverse

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(cli): unify telepath-cli with TelepathClient via RTT adapter

2 participants