pub struct Logger<SEND, RECV>{
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>
impl<RECV, T, BUFSZ> Logger<RealSender<T, BUFSZ>, RECV>
Source§impl<SEND, T, BUFSZ, MSGCT> Logger<SEND, RealReceiver<T, BUFSZ, MSGCT>>
impl<SEND, T, BUFSZ, MSGCT> Logger<SEND, RealReceiver<T, BUFSZ, MSGCT>>
Sourcepub fn start_receive(&mut self) -> Result<(), ()>
pub fn start_receive(&mut self) -> Result<(), ()>
Start the receive process using the internal double-buffers
Sourcepub fn get_pending_manual<'a, 'b>(
&'b mut self,
output: &'a mut [u8],
) -> Result<&'a mut [u8], ()>
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.
Sourcepub fn service_receive(&mut self) -> Result<usize, ()>
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.
Sourcepub fn get_msg(&mut self) -> Option<T>
pub fn get_msg(&mut self) -> Option<T>
Pop a single message off of the decoded/deserialized queue