Skip to content

Commit

Permalink
Allow SimpleClient to yield in case of garbage responses
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKoch committed Feb 4, 2025
1 parent aeb67d5 commit 8c159ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions atat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ embedded-io-async = "0.6"
futures = { version = "0.3", default-features = false }
embassy-sync = "0.6"
embassy-time = "0.4"
embassy-futures = "0.1"
heapless = { version = "^0.8", features = ["serde"] }
serde_at = { path = "../serde_at", version = "^0.23.0", optional = true }
atat_derive = { path = "../atat_derive", version = "^0.23.0", optional = true }
Expand Down
7 changes: 6 additions & 1 deletion atat/src/asynch/simple_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ impl<'a, RW: Read + Write, D: Digester> SimpleClient<'a, RW, D> {
_ => return Err(Error::Read),
};

trace!("Buffer contents: '{:?}'", LossyStr(&self.buf[..self.pos]));
trace!(
"Buffer contents: ({:?} bytes) '{:?}'",
self.pos,
LossyStr(&self.buf[..self.pos])
);

while self.pos > 0 {
let (res, swallowed) = match self.digester.digest(&self.buf[..self.pos]) {
Expand Down Expand Up @@ -108,6 +112,7 @@ impl<'a, RW: Read + Write, D: Digester> SimpleClient<'a, RW, D> {
};

if swallowed == 0 {
embassy_futures::yield_now().await;
break;
}

Expand Down

0 comments on commit 8c159ec

Please sign in to comment.