Skip to content

Commit

Permalink
feat: introduce feature to disable blocking mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrssv committed Dec 16, 2024
1 parent a34dbcb commit bb1b1ce
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ Initial release

* [#902] Use `core::ptr::addr_of_mut!` instead of `&mut` on mutable statics. No observable change.
* [#901] `defmt-rtt`: Update to critical-section 1.2
* [#915] Introduced `disable-blocking-mode` feature

### [defmt-rtt-v0.4.1] (2024-05-13)

Expand Down
3 changes: 3 additions & 0 deletions firmware/defmt-rtt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ readme = "README.md"
repository = "https://github.com/knurling-rs/defmt"
version = "0.4.1"

[features]
disable-blocking-mode = []

[dependencies]
defmt = { version = "0.3", path = "../../defmt" }
critical-section = "1.2"
4 changes: 2 additions & 2 deletions firmware/defmt-rtt/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ impl Channel {
// the host-connection-status is only modified after RAM initialization while the device is
// halted, so we only need to check it once before the write-loop
let write = match self.host_is_connected() {
true => Self::blocking_write,
false => Self::nonblocking_write,
true if cfg!(not(feature = "disable-blocking-mode")) => Self::blocking_write,
_ => Self::nonblocking_write,
};

while !bytes.is_empty() {
Expand Down
3 changes: 3 additions & 0 deletions firmware/defmt-rtt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
//!
//! `defmt::flush` would also block forever in that case.
//!
//! If losing data is not an concern you can disable blocking mode by enabling the feature
//! `disable-blocking-mode`
//!
//! # Critical section implementation
//!
//! This crate uses [`critical-section`](https://github.com/rust-embedded/critical-section) to ensure only one thread
Expand Down

0 comments on commit bb1b1ce

Please sign in to comment.