5 releases

0.2.0 Nov 21, 2024
0.1.3 Jan 4, 2024
0.1.2 Apr 27, 2021
0.1.1 Aug 21, 2020
0.1.0 Apr 19, 2020

#547 in Embedded development

Download history 1396/week @ 2024-08-19 1224/week @ 2024-08-26 1710/week @ 2024-09-02 1342/week @ 2024-09-09 1334/week @ 2024-09-16 1415/week @ 2024-09-23 965/week @ 2024-09-30 575/week @ 2024-10-07 1122/week @ 2024-10-14 1188/week @ 2024-10-21 1039/week @ 2024-10-28 784/week @ 2024-11-04 772/week @ 2024-11-11 1013/week @ 2024-11-18 1005/week @ 2024-11-25 1484/week @ 2024-12-02

4,319 downloads per month
Used in 30 crates

MIT license

57KB
794 lines

panic-rtt-target

crates.io documentation

Logs panic messages over RTT. A companion crate for rtt-target.

Documentation

RTT must have been initialized by using one of the rtt_init macros. Otherwise you will get a linker error at compile time.

Panics are always logged to the print channel. Upon panicking the channel mode is also automatically set to BlockIfFull, so that the full message will always be logged. If the code somehow manages to panic at runtime before RTT is initialized (quite unlikely), or if the print channel doesn't exist, nothing is logged.

The panic handler runs in a non-returning critical_section which implementation should be provided by the user.

Usage

Cargo.toml:

[dependencies]
rtt-target = "x.y.z"
panic-rtt-target = "x.y.z"

main.rs:

#![no_std]

use panic_rtt_target as _;
use rtt_target::rtt_init_default;

fn main() -> ! {
    // you can use `rtt_init_print` or you can call `set_print_channel` after initialization.
    rtt_init_default!();

    panic!("Something has gone terribly wrong");
}

Defmt support

You can enable the defmt feature so that panics are printed to the defmt channel. If you do this and have configured both a print and a defmt channel, the panic message will be printed to both. The defmt feature doesn't automatically enable rtt-target/defmt. This allows you to use a different defmt backend if needed.

Dependencies

~1MB
~23K SLoC