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

source

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.

source

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!");
source

pub fn mode(&self) -> ChannelMode

Gets the current blocking mode of the channel. The default is NoBlockSkip.

source

pub fn set_mode(&mut self, mode: ChannelMode)

Sets the blocking mode of the channel

source

pub fn into_terminal(self) -> TerminalChannel

Converts the channel into a virtual terminal that can be used for writing into multiple virtual terminals.

source

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.

Trait Implementations§

source§

impl Write for UpChannel

source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
1.1.0 · source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
source§

impl Send for UpChannel

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.