[−][src]Crate nrf52_bin_logger
nrf52-bin-logger
This is a handy way to change the nRF52 UART from a byte-stream oriented interface to a "Rust Struct" focused interface. Users can decide if they want to send, receive, or do both over the serial port.
Messages are serialized and deserialized using postcard
+ serde
, and
all messages are COBS encoded for framing. This can be used to quickly set
up a uni- or bi-directional communications protocol over a serial port
for the nRF52.
use serde::{Serialize, Deserialize}; use heapless::consts::*; use nrf52_bin_logger::{Logger, senders::RealSender, receivers::RealReceiver}; #[derive(Serialize, Deserialize)] enum MyProtocol { MsgA(u32), MsgB(f32), MsgC(bool), } type ModemLogger = Logger< // `MyProtocol` outgoing messages, 16 bytes used as a serialization buffer RealSender<MyProtocol, U16>, // `MyProtocol` incoming messages, 16 bytes used as a deserialization buffer, // a max of 8 `MyProtocol` messages can be enqueued RealReceiver<MyProtocol, U16, U8>, >;
Don't need a sender or a receiver? Just replace the type with a NullSender/NullReceiver. No code will be generated for this half of the interface.
use serde::{Serialize, Deserialize}; use heapless::consts::*; use nrf52_bin_logger::{Logger, senders::RealSender, receivers::NullReceiver}; #[derive(Serialize, Deserialize)] enum MyProtocol { MsgA(u32), MsgB(f32), MsgC(bool), } type ModemLogger = Logger< // `MyProtocol` outgoing messages, 16 bytes used as a serialization buffer RealSender<MyProtocol, U16>, // Nothing will be received NullReceiver, >;
Modules
receivers | These items are used to obtain data from an external device to the nRF52, such as an incoming command. |
senders | These items are used for sending data to another device, such as logging to a PC. |
Structs
BinMessage | A binary payload with UTF-8 Description |
Logger | A binary logging interface, using UARTE0. |
Enums
LogOnLine | This is the primary type sent via the Sender |