Skip to content

Commit 6128141

Browse files
authored
Merge pull request #968 from knurling-rs/add-rtt-is-blocking
Add `in_blocking_mode` method to defmt-rtt.
2 parents 6f575b7 + 177c219 commit 6128141

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ Initial release
712712

713713
### [defmt-rtt-next]
714714

715-
* No changes
715+
* [#968] Add `in_blocking_mode` public method
716716

717717
### [defmt-rtt-v1.0.0] (2025-04-01)
718718

@@ -947,6 +947,7 @@ Initial release
947947

948948
---
949949

950+
[#968]: https://github.com/knurling-rs/defmt/pull/968
950951
[#965]: https://github.com/knurling-rs/defmt/pull/965
951952
[#960]: https://github.com/knurling-rs/defmt/pull/960
952953
[#959]: https://github.com/knurling-rs/defmt/pull/959

firmware/defmt-rtt/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ static _SEGGER_RTT: Header = Header {
9393
},
9494
};
9595

96+
/// Report whether the SEGGER RTT up channel is in blocking mode.
97+
///
98+
/// Returns true if the mode bitfield within the flags value has been set to
99+
/// `SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL`.
100+
///
101+
/// Currently we start-up in non-blocking mode, so if it's been set to blocking
102+
/// mode then the connected client (e.g. probe-rs) must have done it.
103+
pub fn in_blocking_mode() -> bool {
104+
(_SEGGER_RTT.up_channel.flags.load(Ordering::Relaxed) & MODE_MASK) == MODE_BLOCK_IF_FULL
105+
}
106+
96107
/// Our shared buffer
97108
#[cfg_attr(target_os = "macos", link_section = ".uninit,defmt-rtt.BUFFER")]
98109
#[cfg_attr(not(target_os = "macos"), link_section = ".uninit.defmt-rtt.BUFFER")]

0 commit comments

Comments
 (0)