From 276ae617835b0b6028bd9cb9e9ac2a1a3ca46477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Proch=C3=A1zka?= Date: Thu, 25 Sep 2025 12:06:30 +0200 Subject: [PATCH] Improved chances for successful sync --- src/target.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/target.rs b/src/target.rs index 0d469ab..e195b9d 100644 --- a/src/target.rs +++ b/src/target.rs @@ -37,7 +37,6 @@ impl PhysicalTarget { } pub fn resync_target(&mut self) -> Result<(), Error> { - self.port.discard_buffers()?; self.port.set_dtr(true)?; self.port.set_rts(true)?; std::thread::sleep(Duration::from_millis(10)); @@ -45,6 +44,8 @@ impl PhysicalTarget { std::thread::sleep(Duration::from_millis(100)); for i in (0..5).rev() { + self.port.discard_buffers()?; + std::thread::sleep(Duration::from_millis(10)); self.port.write(b"U")?; let mut buf = [0u8; 1];