gpt4 book ai didi

c - 当传输大小大于最大数据包大小时,WinUSB Bulk IN 传输失败

转载 作者:行者123 更新时间:2023-11-30 17:34:43 31 4
gpt4 key购买 nike

我在 Windows 主机端使用 WinUSB 与我的 WINUSB USB 设备进行通信。我的 USB 设备是全速设备。我能够获取设备句柄并执行 OUT 和 IN 数据传输。

我在 FS WinUSB 设备上遇到批量输入传输问题。当我将数据从 PC 循环到设备并返回 PC 时,从 1 到 64 的大小工作正常。当我传输 65 个字节时,前 64 个字节能够在 PC 中读回。但最后一个字节丢失了。

任何人都可以面临同样的问题或可以提出一些解决方案吗?

问候,尼希德

最佳答案

首先你应该读出MAXIMUM_TRANSFER_SIZE 。对于发送,WinUSB“如有必要,将缓冲区划分为适当大小的 block ”(source)。

另请查看 WinUsb_ReadPipe 的备注:

If the data returned by the device is greater than a maximum transfer length, WinUSB divides the request into smaller requests of maximum transfer length and submits them serially. If the transfer length is not a multiple of the endpoint's maximum packet size (retrievable through the WINUSB_PIPE_INFORMATION structure's MaximumPacketSize member), WinUSB increases the size of the transfer to the next multiple of MaximumPacketSize.

USB packet size does not factor into the transfer for a read request. If the device responds with a packet that is too large for the client buffer, the behavior of the read request corresponds to the type of policy set on the pipe. If policy type for the pipe is ALLOW_PARTIAL_READS, WinUSB adds the remaining data to the beginning of the next transfer. If ALLOW_PARTIAL_READS is not set, the read request fails. For more information about policy types, see WinUSB Functions for Pipe Policy Modification.

检查您的设置以及最后一个字节是否通过第二次传输发送。您还应该测试实际写入/读取了多少字节。

关于c - 当传输大小大于最大数据包大小时,WinUSB Bulk IN 传输失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23218667/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com