阅读:1654回复:7
相关usb中iso通信方式读写的问题,高手请进~
我现在已经可以枚举我的usb设备端口,我有一个iso断口,可是我读不到数据,readfile返回为0,驱动用的是ddk中iso的例子程序,相关端口已经更改,并检测到。更奇怪的是我可以用抓报工具发现我要读写的数据,可是就是不再readfile上返回,请问这是为什么?
|
|
沙发#
发布于:2005-07-27 07:32
自顶!
怎么没有人回答啊.... |
|
板凳#
发布于:2005-07-27 10:32
下面是引用heflying于2005-07-26 20:02发表的相关usb中iso通信方式读写的问题,高手请进~: 很明显,是你的驱动与上层软件readfile()的交互有问题,可以调用Getlasterror()看看返回什么错误,或者给出两者代码来看看。 |
|
地板#
发布于:2005-07-27 11:00
ReadFile 返回成功,我认为是分包的问题,iso分包上有什么特殊的限制吗?
lSuccess = ReadFile(m_hReadHandle, m_pStrReadData, nLen , (unsigned long*) &nBytesRead, NULL); 如果读取得数量为4096则可以成功,该设备的maxsize是512,还是高速的,ddk上说高速的设备分8个微帧,所以我认为是不是我的分包的问题?不解~~ |
|
地下室#
发布于:2005-07-27 11:01
调试驱动的时候,包状态为
NTSTATUS)0xC0000012L)以下是从ddk中茶道的 // // MessageId: STATUS_WRONG_VOLUME // // MessageText: // // {Wrong Volume} // The wrong volume is in the drive. // Please insert volume %hs into drive %hs. // #define STATUS_WRONG_VOLUME ((NTSTATUS)0xC0000012L) |
|
5楼#
发布于:2005-07-27 13:51
包状态怎么会这样呢?
能不能看看你的iso读是怎么处理的? |
|
6楼#
发布于:2005-07-27 18:17
Step 1:
ASSERT(TotalLength >= 8) Step 2: Find the exact number of packets required to transfer all of this data numberOfPackets = (TotalLength + packetSize - 1) / packetSize Step 3: Number of packets in multiples of 8. if(0 == (numberOfPackets % 8)) { actualPackets = numberOfPackets; } else { actualPackets = numberOfPackets + (8 - (numberOfPackets % 8)); } Step 4: Determine the min. data in each packet. minDataInEachPacket = TotalLength / actualPackets; Step 5: After placing min data in each packet, determine how much data is left to be distributed. dataLeftToBeDistributed = TotalLength - (minDataInEachPacket * actualPackets); Step 6: Start placing the left over data in the packets (above the min data already placed) numberOfPacketsFilledToBrim = dataLeftToBeDistributed / (packetSize - minDataInEachPacket); Step 7: determine if there is any more data left. dataLeftToBeDistributed -= (numberOfPacketsFilledToBrim * (packetSize - minDataInEachPacket)); Step 8: The "dataLeftToBeDistributed" is placed in the packet at index "numberOfPacketsFilledToBrim" Algorithm at play: TotalLength = 8193 packetSize = 8 Step 1 Step 2 numberOfPackets = (8193 + 8 - 1) / 8 = 1025 Step 3 actualPackets = 1025 + 7 = 1032 Step 4 minDataInEachPacket = 8193 / 1032 = 7 bytes Step 5 dataLeftToBeDistributed = 8193 - (7 * 1032) = 969. Step 6 numberOfPacketsFilledToBrim = 969 / (8 - 7) = 969. Step 7 dataLeftToBeDistributed = 969 - (969 * 1) = 0. Step 8 Done :) Another algorithm Completely fill up (as far as possible) the early packets. Place 1 byte each in the rest of them. Ensure that the total number of packets is multiple of 8. This routine then 1. creates a ISOUSB_RW_CONTEXT for each read/write to be performed. 2. creates SUB_CONTEXT for each irp/urb pair. (Each irp/urb pair can transfer a max of 1024 packets.) 3. All the irp/urb pairs are initialized 4. The subsidiary irps (of the irp/urb pair) are passed down the stack at once. 5. The main Read/Write irp is pending |
|
7楼#
发布于:2005-07-27 20:22
还有一个问题,谁知道高速设备和全速设备的区别啊?
|
|