drtio: make sure receive buffer is drained after ping reply

This commit is contained in:
Sebastien Bourdeauducq 2020-04-06 22:33:15 +08:00
parent 8839101085
commit 5168b83158
1 changed files with 11 additions and 1 deletions

View File

@ -68,7 +68,17 @@ pub mod drtio {
} }
let reply = aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::EchoRequest); let reply = aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::EchoRequest);
match reply { match reply {
Ok(drtioaux::Packet::EchoReply) => return count, Ok(drtioaux::Packet::EchoReply) => {
// make sure receive buffer is drained
let max_time = clock::get_ms() + 200;
loop {
if clock::get_ms() > max_time {
return count;
}
let _ = drtioaux::recv(linkno);
io.relinquish().unwrap();
}
}
_ => {} _ => {}
} }
io.relinquish().unwrap(); io.relinquish().unwrap();