From e7d21253d8d783535b3e2e0b144d6ce91c23452f Mon Sep 17 00:00:00 2001 From: G2-Games Date: Wed, 31 Jan 2024 21:20:01 -0600 Subject: [PATCH] Fixed issue with `_read_reply()` in `base.rs` --- minidisc-rs/src/netmd/base.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/minidisc-rs/src/netmd/base.rs b/minidisc-rs/src/netmd/base.rs index d78ae31..df8c37b 100644 --- a/minidisc-rs/src/netmd/base.rs +++ b/minidisc-rs/src/netmd/base.rs @@ -243,12 +243,19 @@ impl NetMD { use_factory_command: bool, override_length: Option, ) -> Result, Box> { - let mut length = self.poll().await?.0; + let mut length = 0; - for attempt in 0..75 { - if attempt == 75 { + for attempt in 0..40 { + if attempt == 39 { return Err("Failed to get response length".into()); } + + length = self.poll().await?.0; + + if length > 0 { + break + } + // Back off while trying again let sleep_time = Self::READ_REPLY_RETRY_INTERVAL as u64 * (u64::pow(2, attempt as u32 / 10) - 1); @@ -259,10 +266,7 @@ impl NetMD { #[cfg(target_family = "wasm")] TimeoutFuture::new(sleep_time as u32).await; - length = self.poll().await?.0; - if length > 0 { - break - } + println!("{}", attempt); } if let Some(value) = override_length {