aboutsummaryrefslogtreecommitdiffstats
path: root/usbh
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-07-28 16:44:35 -0400
committerBrian Cully <bjc@kublai.com>2019-07-28 16:44:35 -0400
commit0d2471fef27c6abe5cb34f59f80c5c53ba07da19 (patch)
treeeb58580e9a7a9bb23d3b9b1aba5ba83aa9d9bba1 /usbh
parentd13c53906ffba1495f49fcf90f1f3260bb17703f (diff)
downloadsamd21-demo-0d2471fef27c6abe5cb34f59f80c5c53ba07da19.tar.gz
samd21-demo-0d2471fef27c6abe5cb34f59f80c5c53ba07da19.zip
Update notes on short packets.
Diffstat (limited to 'usbh')
-rw-r--r--usbh/src/pipe.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/usbh/src/pipe.rs b/usbh/src/pipe.rs
index 388b518..835ba86 100644
--- a/usbh/src/pipe.rs
+++ b/usbh/src/pipe.rs
@@ -202,7 +202,7 @@ impl Pipe<'_, '_> {
buf: &mut T,
nak_limit: usize,
millis: &dyn Fn() -> usize,
- ) -> Result<(usize), PipeErr> {
+ ) -> Result<usize, PipeErr> {
// TODO: pull this from pipe descriptor for this addr/ep.
let packet_size = 8;
@@ -217,6 +217,10 @@ impl Pipe<'_, '_> {
// Read until we get a short packet (indicating that there's
// nothing left for us in this transaction) or the buffer is
// full.
+ //
+ // TODO: It is sometimes valid to get a short packet when
+ // variable length data is desired by the driver. cf ยง5.3.2 of
+ // USB 2.0.
let mut bytes_received = 0;
while bytes_received < db.len {
// Move the buffer pointer forward as we get data.
@@ -231,11 +235,6 @@ impl Pipe<'_, '_> {
bytes_received += recvd;
trace!("!! read {} of {}", bytes_received, db.len);
if recvd < packet_size {
- // If we receive a short packet, we should be done
- // here. It /may/ be possible to get a short packet
- // and continue, but only if recvd is a word-sized
- // multiple. I'm going to assume, for simplicity's
- // sake, that that's not possible.
break;
}