Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ping_client, ping_server): wait major frame after sampling port error #104

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/ping_client/src/main.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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;
}
};
Expand Down
8 changes: 5 additions & 3 deletions examples/ping_server/src/main.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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;
}

Expand All @@ -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();
Expand Down
Loading