Struct Logger

Source
pub struct Logger<SEND, RECV>
where SEND: Sender, RECV: Receiver,
{ pub good_msgs: usize, pub good_bytes: usize, pub dropped_bytes: usize, pub dropped_msgs: usize, pub bad_cobs: usize, pub full_buf: usize, pub full_msg: usize, pub ttl_got: usize, /* private fields */ }
Expand description

A binary logging interface, using UARTE0. target In the future other serial interfaces might be supported

Fields§

§good_msgs: usize§good_bytes: usize§dropped_bytes: usize§dropped_msgs: usize§bad_cobs: usize§full_buf: usize§full_msg: usize§ttl_got: usize

Implementations§

Source§

impl<RECV, T, BUFSZ> Logger<RealSender<T, BUFSZ>, RECV>
where T: Serialize, BUFSZ: ArrayLength<u8>, RECV: Receiver + Default,

Source

pub fn log(&mut self, data: &str) -> Result<(), ()>

Send a log level &str message

Source

pub fn warn(&mut self, data: &str) -> Result<(), ()>

Send a warn level &str message

Source

pub fn error(&mut self, data: &str) -> Result<(), ()>

Send an error level &str message

Source

pub fn raw_bin(&mut self, description: &str, data: &[u8]) -> Result<(), ()>

Send a byte slice message

Source

pub fn data(&mut self, data: T) -> Result<(), ()>

Send a log level &str message

Source§

impl<SEND, RECV> Logger<SEND, RECV>
where SEND: Sender + Default, RECV: Receiver + Default,

Source

pub fn new(uart: Uarte<UARTE0>) -> Self

Source§

impl<SEND, T, BUFSZ, MSGCT> Logger<SEND, RealReceiver<T, BUFSZ, MSGCT>>
where T: DeserializeOwned, BUFSZ: ArrayLength<u8>, MSGCT: ArrayLength<T>, SEND: Sender + Default,

Source

pub fn start_receive(&mut self) -> Result<(), ()>

Start the receive process using the internal double-buffers

Source

pub fn get_pending_manual<'a, 'b>( &'b mut self, output: &'a mut [u8], ) -> Result<&'a mut [u8], ()>

Obtain any pending bytes in the active buffer. This also causes the internal double buffers to flip. When this function is successful, a sub-slice of output is returned, containing the read bytes.

Bytes are obtained as they are received on the line, so decoding and deserialization must be performed manually.

NOTE: Either this function or service_receive() must be polled periodically, or there will be data loss! In general, the calculation for “how often do I need to poll this” is 1 / (BAUDRATE / LINE_BITS_PER_DATA_BYTE / 255).

For example, at 230400 Baud, and 8N1 settings (8 data bits per 10 line bits), it is necessary to poll this function once per ~11ms.

Source

pub fn service_receive(&mut self) -> Result<usize, ()>

This is an automatic handler, that will clear any pending bytes, and attempt to parse any pending messages. If successful, the return value is the number messages ready to be cleared with get_msg().

NOTE: Either this function or get_pending_manual() must be polled periodically, or there will be data loss! In general, the calculation for “how often do I need to poll this” is 1 / (BAUDRATE / LINE_BITS_PER_DATA_BYTE / 255).

For example, at 230400 Baud, and 8N1 settings (8 data bits per 10 line bits), it is necessary to poll this function once per ~11ms.

Care must also be taken to ensure that MSGCT has a deep enough queue.

Source

pub fn get_msg(&mut self) -> Option<T>

Pop a single message off of the decoded/deserialized queue

Source

pub fn get_stats(&self) -> (usize, usize)

Auto Trait Implementations§

§

impl<SEND, RECV> Freeze for Logger<SEND, RECV>
where SEND: Freeze, RECV: Freeze,

§

impl<SEND, RECV> RefUnwindSafe for Logger<SEND, RECV>
where SEND: RefUnwindSafe, RECV: RefUnwindSafe,

§

impl<SEND, RECV> Send for Logger<SEND, RECV>
where SEND: Send, RECV: Send,

§

impl<SEND, RECV> !Sync for Logger<SEND, RECV>

§

impl<SEND, RECV> Unpin for Logger<SEND, RECV>
where SEND: Unpin, RECV: Unpin,

§

impl<SEND, RECV> UnwindSafe for Logger<SEND, RECV>
where SEND: UnwindSafe, RECV: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.