From 1950f9283531a5db1bc1ba7031c15c963358a336 Mon Sep 17 00:00:00 2001 From: Florian Hartung Date: Mon, 19 Feb 2024 18:01:43 +0100 Subject: [PATCH] fix(ping_client, ping_server): wait major frame after sampling port error --- examples/ping_client/src/main.rs | 4 +++- examples/ping_server/src/main.rs | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/ping_client/src/main.rs b/examples/ping_client/src/main.rs index b626456..61413a5 100644 --- a/examples/ping_client/src/main.rs +++ b/examples/ping_client/src/main.rs @@ -1,8 +1,9 @@ use a653rs::partition; use a653rs::prelude::PartitionExt; -use a653rs_linux::partition::ApexLogger; use log::LevelFilter; +use a653rs_linux::partition::ApexLogger; + fn main() { ApexLogger::install_panic_hook(); ApexLogger::install_logger(LevelFilter::Trace).unwrap(); @@ -84,6 +85,7 @@ mod ping_client { Ok((validity, bytes)) => (validity, bytes), Err(e) => { warn!("Failed to receive ping response: {e:?}"); + ctx.periodic_wait().unwrap(); continue; } }; diff --git a/examples/ping_server/src/main.rs b/examples/ping_server/src/main.rs index d144da6..ba1e0c6 100644 --- a/examples/ping_server/src/main.rs +++ b/examples/ping_server/src/main.rs @@ -1,8 +1,9 @@ use a653rs::partition; use a653rs::prelude::PartitionExt; -use a653rs_linux::partition::ApexLogger; use log::LevelFilter; +use a653rs_linux::partition::ApexLogger; + fn main() { ApexLogger::install_panic_hook(); ApexLogger::install_logger(LevelFilter::Trace).unwrap(); @@ -49,14 +50,13 @@ mod ping_server { fn periodic_ping_server(ctx: periodic_ping_server::Context) { info!("started ping_server process"); loop { - info!("forwarding request as response "); - // allocate a buffer to receive into let mut buf = [0u8; 32]; // receive a request, storing it to `buf` if let Err(e) = ctx.ping_request.unwrap().receive(&mut buf) { warn!("Failed to receive ping request: {e:?}"); + ctx.periodic_wait().unwrap(); continue; } @@ -66,6 +66,8 @@ mod ping_server { panic!("could not read time"); }; + info!("forwarding request as response"); + // convert the current time to an u128 integer representing nanoseconds, and // serialize the integer to a byte array let time_in_nanoseconds = time.as_nanos();