gpt4 book ai didi

c - 如何识别 USB ISO 传输中用于 CRC(校验和)的数据字节?

转载 作者:行者123 更新时间:2023-11-30 14:56:20 26 4
gpt4 key购买 nike

我正在使用 libusb 从 USB 音频设备实时获取数据。我的最大数据包大小为 196 字节。我知道其中 4 个字节是为校验和添加的。我想识别用于校验和的字节,这样我就可以只存储传输的有用数据,但我有一些疑问:

1) 这些字节是添加在数据包的开头还是末尾?

2)这些字节有保留值吗?

3) 如果在传输中丢失一些数据字节。对于用于校验和的字节,我应该考虑哪些因素?

编辑1

我有这些疑问,因为我的特定设备有一个接口(interface)和替代设置,适用于 48 KHz、2 channel 、16 位深度和 196 字节最大数据包大小的采样率。

因此有 48 个样本 * 2 个两个 channel * 2 个字节 = 192 个字节

那么我的数据包应该是 192 字节,但是当我将设备设置为与该接口(interface)和 alt 设置一起使用时,我开始接收 196 字节的数据包。OUT ISO 端点的相应接口(interface)和替代设置工作在 48 KHz、2 channel 、16 位深度的采样率和 192 字节的最大数据包大小。

4) 如果这些字节不是来自校验和,为什么要添加这些字节?

最佳答案

enter image description here

我知道其中的 4 个字节是为校验和添加的

Wrong. CRC is 2 bytes for data packet and 5 bits for token packet. Also CRC is never stored/forwarded in/to the user buffer. It gets stripped by the controller during verification of the CRC. So you are not going to see the CRC at all. But if you still want to see the CRC, attach a USB packet analyzer and have a look at the trace.

1) 这些字节是添加在数据包的开头还是末尾?

2 bytes are added at the end.

2)这些字节有保留值吗?

No. Its calculated based on the content of the data packet

3) 如果在传输中丢失一些数据字节。对于用于校验和的字节,我应该考虑哪些因素?

If you are losing some bytes after CRC is already calculated, you are going to get USB transaction error (CRC mismatch from the host). The same transaction will be retried by the host.

PS - 我假设您使用的是高速设备

关于c - 如何识别 USB ISO 传输中用于 CRC(校验和)的数据字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44787524/

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