什么是 "zero-length packet"?
What is "zero-length packet"?
USB 标准提到在某些情况下写入 "zero-length" 数据包。
谁能解释一下 USB 术语中 "zero-length" 数据包的含义?
什么是"short packet"? (好像"short packet"和"zero-length packet"一起提到了)
这两个术语都用于事务完成机制。
数据包的最大大小可以从端点描述符中存储的 bMaxPacketSize 导出。当数据包小于该数据包时,称为短数据包。
同样,当您可以发送长度为零的数据包时。
现在的问题是"Why"。让我们讨论一下。
短数据包的原因 -
1 - As per USB specification, When the host or device receives a data
packet with packet length less than maximum packet size, it shall
consider the transfer is complete and no more data packet is left to
receive.
2 - This is always the case for Bulk transfer (Mass storage devices).
You do not always ask data with length multiple of MaxPacketSize. So
the last packet will always be less than max packet size. Consider you
want 1025 bytes of data from bulk endpoint whose max packet size is
1024 bytes.
First Data Packet = 1024 bytes Seconds Data Packet = 1 byte (Short
Packet).
This way the host will know that the data transfer is complete.
零长度数据包的原因 -
1 - Like Short packet, zero length packet is also used for transaction
complete. Consider you want to send 2048 bytes of bulk data.
First data packet = 1024 bytes Second data packet = 1024 bytes.
Now the problem is, both are equal to max packet size. The device will
not understand that the transfer is complete. Then you send a zero
length packet.
Third data packet = 0 bytes
This will make the transfer complete and device can then start
processing the data.
2 - Zero length packet is also used in control transfer during status
stage to notify successful completion.
USB 标准提到在某些情况下写入 "zero-length" 数据包。
谁能解释一下 USB 术语中 "zero-length" 数据包的含义?
什么是"short packet"? (好像"short packet"和"zero-length packet"一起提到了)
这两个术语都用于事务完成机制。 数据包的最大大小可以从端点描述符中存储的 bMaxPacketSize 导出。当数据包小于该数据包时,称为短数据包。 同样,当您可以发送长度为零的数据包时。
现在的问题是"Why"。让我们讨论一下。
短数据包的原因 -
1 - As per USB specification, When the host or device receives a data packet with packet length less than maximum packet size, it shall consider the transfer is complete and no more data packet is left to receive.
2 - This is always the case for Bulk transfer (Mass storage devices). You do not always ask data with length multiple of MaxPacketSize. So the last packet will always be less than max packet size. Consider you want 1025 bytes of data from bulk endpoint whose max packet size is 1024 bytes.
First Data Packet = 1024 bytes Seconds Data Packet = 1 byte (Short Packet).
This way the host will know that the data transfer is complete.
零长度数据包的原因 -
1 - Like Short packet, zero length packet is also used for transaction complete. Consider you want to send 2048 bytes of bulk data.
First data packet = 1024 bytes Second data packet = 1024 bytes.
Now the problem is, both are equal to max packet size. The device will not understand that the transfer is complete. Then you send a zero length packet.
Third data packet = 0 bytes
This will make the transfer complete and device can then start processing the data.
2 - Zero length packet is also used in control transfer during status stage to notify successful completion.