Skip to content

Commit 2f55331

Browse files
authored
Allow SimpleClient to yield in case of garbage responses (#218)
1 parent aeb67d5 commit 2f55331

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

atat/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ embedded-io-async = "0.6"
2323
futures = { version = "0.3", default-features = false }
2424
embassy-sync = "0.6"
2525
embassy-time = "0.4"
26+
embassy-futures = "0.1"
2627
heapless = { version = "^0.8", features = ["serde"] }
2728
serde_at = { path = "../serde_at", version = "^0.23.0", optional = true }
2829
atat_derive = { path = "../atat_derive", version = "^0.23.0", optional = true }

atat/src/asynch/simple_client.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ impl<'a, RW: Read + Write, D: Digester> SimpleClient<'a, RW, D> {
5757
_ => return Err(Error::Read),
5858
};
5959

60-
trace!("Buffer contents: '{:?}'", LossyStr(&self.buf[..self.pos]));
60+
trace!(
61+
"Buffer contents: ({:?} bytes) '{:?}'",
62+
self.pos,
63+
LossyStr(&self.buf[..self.pos])
64+
);
6165

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

110114
if swallowed == 0 {
115+
embassy_futures::yield_now().await;
111116
break;
112117
}
113118

0 commit comments

Comments
 (0)