From f58f16ccd4b506282990d78a91510d3fafd76695 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 21 Jun 2017 14:30:41 +0800 Subject: [PATCH] drtioaux: add default timeout --- artiq/firmware/libdrtioaux/lib.rs | 3 ++- artiq/firmware/runtime/moninj.rs | 4 ++-- artiq/firmware/runtime/rtio_mgt.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/artiq/firmware/libdrtioaux/lib.rs b/artiq/firmware/libdrtioaux/lib.rs index 84c9215f3..6ac21fe36 100644 --- a/artiq/firmware/libdrtioaux/lib.rs +++ b/artiq/firmware/libdrtioaux/lib.rs @@ -320,7 +320,8 @@ pub mod hw { } } - pub fn recv_timeout(timeout_ms: u64) -> io::Result { + pub fn recv_timeout(timeout_ms: Option) -> io::Result { + let timeout_ms = timeout_ms.unwrap_or(10); let limit = board::clock::get_ms() + timeout_ms; while board::clock::get_ms() < limit { match recv() { diff --git a/artiq/firmware/runtime/moninj.rs b/artiq/firmware/runtime/moninj.rs index b2fa5369c..2bce8da1a 100644 --- a/artiq/firmware/runtime/moninj.rs +++ b/artiq/firmware/runtime/moninj.rs @@ -39,7 +39,7 @@ fn read_probe_drtio(channel: u16, probe: u8) -> u32 { if rtio_mgt::drtio::link_is_running() { let request = drtioaux::Packet::MonitorRequest { channel: channel, probe: probe }; drtioaux::hw::send(&request).unwrap(); - match drtioaux::hw::recv_timeout(10) { + match drtioaux::hw::recv_timeout(None) { Ok(drtioaux::Packet::MonitorReply { value }) => return value, Ok(_) => error!("received unexpected aux packet"), Err(e) => error!("aux packet error ({})", e) @@ -123,7 +123,7 @@ fn read_injection_status_drtio(channel: u16, overrd: u8) -> u8 { overrd: overrd }; drtioaux::hw::send(&request).unwrap(); - match drtioaux::hw::recv_timeout(10) { + match drtioaux::hw::recv_timeout(None) { Ok(drtioaux::Packet::InjectionStatusReply { value }) => return value, Ok(_) => error!("received unexpected aux packet"), Err(e) => error!("aux packet error ({})", e) diff --git a/artiq/firmware/runtime/rtio_mgt.rs b/artiq/firmware/runtime/rtio_mgt.rs index 76e88e080..62de87468 100644 --- a/artiq/firmware/runtime/rtio_mgt.rs +++ b/artiq/firmware/runtime/rtio_mgt.rs @@ -169,7 +169,7 @@ pub mod drtio { io.sleep(200).unwrap(); if link_is_running() { drtioaux::hw::send(&drtioaux::Packet::RtioErrorRequest).unwrap(); - match drtioaux::hw::recv_timeout(10) { + match drtioaux::hw::recv_timeout(None) { Ok(drtioaux::Packet::RtioNoErrorReply) => (), Ok(drtioaux::Packet::RtioErrorCollisionReply) => error!("RTIO collision (in satellite)"), Ok(drtioaux::Packet::RtioErrorBusyReply) => error!("RTIO busy (in satellite)"),