How to identify the data bytes used for CRC(checksum) in an USB ISO-Transfer?
我正在使用libusb从USB音频设备实时获取数据。我的最大数据包大小为196字节。我知道该字节中的4个被添加为校验和。我想确定用于校验和的字节,因此我只能存储传输的有用数据,但是我有一些疑问:
1)这些字节是在数据包的开头还是结尾添加的?
2)这些字节是否有保留值?
3)如果在传输中丢失一些数据字节。对于用于校验和的字节,应该使用哪些注意事项?
编辑1
我有这些疑问,因为我的特定设备具有一个接口和alt设置,可以以48 KHz的采样率,2个通道,16位深度和196字节的最大数据包大小工作。
因此有48个样本* 2个通道中的2个* 2字节= 192字节
因此,我的数据包应该为192字节,但是当我将设备设置为与该接口一起使用并进行alt设置时,我开始接收196字节的数据包。
OUT ISO端点的相应接口和替代设置以48 KHz的采样率,2个通道,16位深度,最大包大小为192字节工作。
4)如果这些字节不是来自校验和,为什么要添加这些字节?
我知道为校验和添加了其中的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.blockquote>
1)这些字节是在数据包的开头还是结尾添加的?
2 bytes are added at the end.
blockquote>
2)这些字节是否有保留值?
No. Its calculated based on the content of the data packet
blockquote>
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.
blockquote>
PS-我以为您正在使用高速设备