开发者

Programming a USB Device on a Mac

I'm updating some old old code (that works for now, but is using OpenTransport, so um... no) that interfaces with a USB scanner. I THINK I understand how IOUSBDeviceInterface and IOUSBInterfaceInterface are supposed to work, but I can't seem to get information about the pipes.

I have a method which takes: (IOUSBInterfaceInterface **)intf which has two pipes. I believe that it is set up correctly, but I'm not sure how to test that. Inside, I do:

for (i=1; i <= numPipes; i++)
{
    err = (*intf)->GetPipeProperties(intf, i, &direction, &number, &transferType, &maxPacketSize, &interval);
}

But it returns kIOReturnNotOpen. I AM detecting the scanner correctly (When the scanner is off, it doesn't even get to this stage) and I don't think any other programs are trying开发者_运维问答 to access the scanner.

Is there some sensible way of determining what is going wrong? (ie, what other program thinks it has the pipes open, or whatever?)

The code is technically in Objective-C, but as you can see, the above code is pretty vanilla C, hence the tags.


Have you called USBInterfaceOpen on the interace yet?

If you haven't already done so, just take a look at the USBNotification example code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜