Skip to content

Commit

Permalink
COBS wire encoding (#1)
Browse files Browse the repository at this point in the history
* using COBS encoding over the wire
* separation of serialization/deserialization from writing/reading, added ser/de tests
* added trace logs in reading and writing
Signed-off-by: gabrik <[email protected]>
  • Loading branch information
gabrik authored Jul 18, 2022
1 parent 7e4954b commit 01042e9
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 106 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ readme = "README.md"
tokio = {version = "1.17.0", features = ["io-util"] }
tokio-serial = "5.4.1"
futures = "0.3.21"
cobs = "0.2"
log = "0.4"

[dev-dependencies]
clap = { version = "3.1", features = ["derive"] }
env_logger = "0.9.0"
tokio = {version = "1.17.0", features = ["full"] }
rand = "0.8"
5 changes: 4 additions & 1 deletion examples/serial-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct Args {

#[tokio::main]
async fn main() -> tokio_serial::Result<()> {
// initiate logging
env_logger::init();

let args = Args::parse();
let mut buff = [0u8; 65535];

Expand Down Expand Up @@ -78,7 +81,7 @@ async fn main() -> tokio_serial::Result<()> {
tokio::time::sleep(Duration::from_secs_f64(timeout_duration)).await;
};

let _out = tokio::select! {
tokio::select! {
res = port.read_msg(&mut buff) => {
let read = res?;
if read > 0 {
Expand Down
Loading

0 comments on commit 01042e9

Please sign in to comment.