Programming a USB device on a Mac

I am updating the old old code (which works now, but uses OpenTransport, so um ... no), which interacts with a USB scanner. I think I understand how to have to work IOUSBDeviceInterface, and IOUSBInterfaceInterface, but I can not get information about the pipes.

I have a method that accepts: (IOUSBInterfaceInterface **)intfwhich has two pipes. I believe it is configured correctly, but I'm not sure how to check it. Inside I do:

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

But he returns kIOReturnNotOpen. I correctly identify the scanner (when the scanner is turned off, it does not even reach this stage), and I do not think that other programs are trying to access the scanner.

Is there any reasonable way to determine what is going wrong? (i.e. what other program believes that it has pipes open or something else?)

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

+3
source share
1 answer

Have you already called USBInterfaceOpen?

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

+1
source

Source: https://habr.com/ru/post/1753729/


All Articles