forked from M-Labs/artiq
1
0
Fork 0

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 ffd3172e02
commit facc0357d8
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);
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();