drtioaux: add default timeout

This commit is contained in:
Sebastien Bourdeauducq 2017-06-21 14:30:41 +08:00
parent 7675dd063b
commit f58f16ccd4
3 changed files with 5 additions and 4 deletions

View File

@ -320,7 +320,8 @@ pub mod hw {
}
}
pub fn recv_timeout(timeout_ms: u64) -> io::Result<Packet> {
pub fn recv_timeout(timeout_ms: Option<u64>) -> io::Result<Packet> {
let timeout_ms = timeout_ms.unwrap_or(10);
let limit = board::clock::get_ms() + timeout_ms;
while board::clock::get_ms() < limit {
match recv() {

View File

@ -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)

View File

@ -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)"),