Struct rtt_target::UpChannel
source · pub struct UpChannel(/* private fields */);
Expand description
RTT up (target to host) channel
Supports writing binary data directly, or writing strings via core::fmt
macros such as
write
as well as the ufmt crate’s uwrite
macros (use the u
method).
Note that the formatted writing implementations diverge slightly from the trait definitions in that if the channel is in non-blocking mode, writing will not block.
Implementations§
source§impl UpChannel
impl UpChannel
sourcepub fn write(&mut self, buf: &[u8]) -> usize
pub fn write(&mut self, buf: &[u8]) -> usize
Writes buf
to the channel and returns the number of bytes written. Behavior when the
buffer is full is subject to the channel blocking mode.
sourcepub fn u(&mut self) -> uWriter<'_>
pub fn u(&mut self) -> uWriter<'_>
Creates a writer for formatted writing with ufmt.
The correct way to use this method is to call it once for each write operation. This is so that non blocking modes will work correctly.
let mut output = channels.up.0;
uwriteln!(output.u(), "Hello, ufmt!");
sourcepub fn mode(&self) -> ChannelMode
pub fn mode(&self) -> ChannelMode
Gets the current blocking mode of the channel. The default is NoBlockSkip
.
sourcepub fn set_mode(&mut self, mode: ChannelMode)
pub fn set_mode(&mut self, mode: ChannelMode)
Sets the blocking mode of the channel
sourcepub fn into_terminal(self) -> TerminalChannel
pub fn into_terminal(self) -> TerminalChannel
Converts the channel into a virtual terminal that can be used for writing into multiple virtual terminals.
sourcepub unsafe fn conjure(number: usize) -> Option<UpChannel>
pub unsafe fn conjure(number: usize) -> Option<UpChannel>
Magically creates a channel out of thin air. Return None
if the channel number is too
high, or if the channel has not been initialized.
Calling this function will cause a linking error if rtt_init
has not been called.
Safety
It’s undefined behavior for something else to access the channel through anything else besides the returned object during or after calling this function. Essentially this function is only safe to use in panic handlers and the like that permanently disable interrupts.