[][src]Crate probe_rs_rtt

Host side implementation of the RTT (Real-Time Transfer) I/O protocol over probe-rs

RTT implements input and output to/from a microcontroller using in-memory ring buffers and memory polling. This enables debug logging from the microcontroller with minimal delays and no blocking, making it usable even in real-time applications where e.g. semihosting delays cannot be tolerated.

This crate enables you to read and write via RTT channels. It's also used as a building-block for probe-rs debugging tools.

Example

use std::sync::{Arc, Mutex};
use probe_rs::Probe;
use probe_rs_rtt::Rtt;

// First obtain a probe-rs session (see probe-rs documentation for details)
let probe = Probe::list_all()[0].open()?;
let mut session = probe.attach("somechip")?;

// Attach to RTT
let mut rtt = Rtt::attach(Arc::new(Mutex::new(session)))?;

// Read from a channel
if let Some(input) = rtt.up_channels().take(0) {
    let mut buf = [0u8; 1024];
    let count = input.read(&mut buf[..])?;

    println!("Read data: {:?}", &buf[..count]);
}

// Write to a channel
if let Some(output) = rtt.down_channels().take(0) {
    output.write(b"Hello, computer!\n")?;
}

Re-exports

pub use channels::Channels;

Modules

channels

List of RTT channels.

Structs

DownChannel

RTT down (host to target) channel.

Rtt

The RTT interface.

UpChannel

RTT up (target to host) channel.

Enums

ChannelMode

Specifies what to do when a channel doesn't have enough buffer space for a complete write on the target side.

Error

Error type for RTT operations.

ScanRegion

Used to specify which memory regions to scan for the RTT control block.

Traits

RttChannel

Trait for channel information shared between up and down channels.