Skip to content

Commit 6c9d17c

Browse files
authored
fix endflash write would-block error (#84)
1 parent 2b5936f commit 6c9d17c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

kic-lib/src/model/versatest.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,20 @@ impl Flash for Instrument {
244244

245245
self.write_all(image)?;
246246

247-
self.write_all(b"endflash\n")?;
247+
let mut loop_count = 0;
248+
loop {
249+
loop_count += 1;
250+
match self.write_all(b"endflash\n") {
251+
Ok(_) => break,
252+
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => {
253+
std::thread::sleep(Duration::from_millis(10));
254+
continue;
255+
}
256+
Err(e) => return Err(e.into()),
257+
}
258+
}
259+
260+
trace!("Wrote 'endflash' after {loop_count} attempts");
248261

249262
if spinner.is_none() {
250263
let pb = ProgressBar::new(1);

0 commit comments

Comments
 (0)