Skip to content

Commit 00c47eb

Browse files
authored
Fix sync behavior (#217)
* Fix sync behavior * Fix clippy
1 parent 3c21364 commit 00c47eb

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

espflash/src/connection.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ impl Connection {
8888

8989
fn sync(&mut self) -> Result<(), Error> {
9090
self.with_timeout(CommandType::Sync.timeout(), |connection| {
91-
connection.write_command(Command::Sync)?;
91+
connection.command(Command::Sync)?;
9292
connection.flush()?;
9393
sleep(Duration::from_millis(10));
94-
for _ in 0..100 {
94+
for _ in 0..7 {
9595
match connection.read_response()? {
9696
Some(response) if response.return_op == CommandType::Sync as u8 => {
9797
if response.status == 1 {
@@ -100,24 +100,20 @@ impl Connection {
100100
CommandType::Sync,
101101
RomErrorKind::from(response.error),
102102
)));
103-
} else {
104-
break;
105103
}
106104
}
107-
_ => continue,
105+
_ => {
106+
return Err(Error::RomError(RomError::new(
107+
CommandType::Sync,
108+
RomErrorKind::InvalidMessage,
109+
)))
110+
}
108111
}
109112
}
110113

111114
Ok(())
112115
})?;
113116

114-
for _ in 0..700 {
115-
match self.read_response()? {
116-
Some(_) => break,
117-
_ => continue,
118-
}
119-
}
120-
121117
Ok(())
122118
}
123119

0 commit comments

Comments
 (0)