2015-10-17 138 views
1

挂我已经从苹果的例子中使用的代码:ReadPipe在Mac OS X 10.11

// 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探针测试台一倍选中)。 我也尝试了异步版本,结果相同:写入工作(似乎),读取挂起。 我也试过一些调试usbtrace:发射一次后退出,现在总是返回The trace facility is currently in use。 USB器件是Microchip USB入门工具包II。 有什么想法? 谢谢,

米歇尔

+0

可能不是问题,但是你的'bulkInRef'是什么? – Dorad

+0

这是一个Uint 8,对输入管道的引用。在我的情况下,值为2. –

+0

也许检查它是否是一个输入管道: (* usbInterface) - > GetPipeProperties(usbInterface,1,&directionOut,&number,&transferType,&maxPacketSize,&interval); (* usbInterface) - > GetPipeProperties(usbInterface,2,&direction2,&number,&transferType,&maxPacketSize,&interval); if(directionOut!= direction2){ } – Dorad

回答

0

问题是,我不得不发送一个请求到所述OUT管使用WritePipe该设备,然后读取在IN管使用ReadPipe的响应。我没有得到它,这是我的错。