【发布时间】:2015-10-17 18:57:48
【问题描述】:
我使用了 Apple 示例中的代码:
// Send data through out pipe
ret = (*usbInterface)->WritePipe(usbInterface, bulkOutRef, (void *)kTestMessage, 4);
if (ret != kIOReturnSuccess)
{
NSLog(@"Write failed (error: %x)\n", ret);
}
// Read data through in pipe
numBytes = 64;
inp = malloc(numBytes);
ret = (*usbInterface)->ReadPipe(usbInterface, bulkInRef, inp, &numBytes);
使用GetPipeProperties 检查管道引用(并使用USB Prober 进行双重检查)。
我也尝试过异步版本,结果相同:写入工作(似乎可以),读取挂起。
我还尝试了使用usbtrace 进行一些调试:启动一次并退出后,它现在总是返回The trace facility is currently in use。
USB 设备是 Microchip USB 入门工具包 II。
任何的想法?
谢谢,
米歇尔
【问题讨论】:
-
可能不是问题,但您的“bulkInRef”是什么?
-
这是一个 Uint 8,对输入管道的引用。在我的例子中,值为 2。
-
也许检查它是否是一个输入管道: (*usbInterface)->GetPipeProperties(usbInterface, 1, &directionOut, &number, &transferType, &maxPacketSize, &interval); (*usbInterface)->GetPipeProperties(usbInterface, 2, &direction2, &number, &transferType, &maxPacketSize, &interval);如果(方向输出!=方向2){}
-
是的,谢谢,我已经检查过了,请看我的问题。
-
您确定设备已正确编程以响应相关读取请求吗?如果没有,IOKit 就会挂在那里。使用允许指定超时的读取和写入管道方法变体通常是一个好主意。