Currently I have an objective-C program that detects when a Fujitsu scanner is added and removed from the computer. I'm trying to add the ability to ask the scanner information about itself. I know the command for this, however, something is going wrong. I'm doing a bit of cargo-cult programming, from two different cargo cults (How do you make the magic coke bottle work with the magic pen?) so, I think I'm merging things wrong, but I can't see where.
There's too much code to start out with it all, so here the broad outline of what I'm doing:
I get an io_iterator from IOServiceAddMatchingNotification which I use to give me an io_service_t. I use that to get a pluginInterface with IOCreatePlugInInterfaceForService.
I call QueryInterface on the pluginInterface to get a IOUSBDeviceInterface**.
I then create a IOUSBFindInterfaceRequest with all "don'tcare"s in it, and use that and the deviceinterface to make another io_iterator_t. That gives me another io_service_t, that I again use with IOCreatePlugInInterfaceForService to get another pluginInterface.
This time QueryInterface on the pluginInterface gives me a IOUSBInterfaceInterface, which I open.
I grab the in and out pipes for the interface, which look correct.
Eventually , I use the interfaceinterface to call WritePipeTO, with the SCSI command that I'm pretty sure works on that scanner to get the information about the scanner. That returns kIOReturnSuccess.
Finally, I try to read the result with ReadPipeTO on the interfaceinterface. And here's where things go wrong.
On ONE scanner, I get a result of 0x4051: kIOUSBTransactionTimeout. On another scanner (Different model, same make) I get 0xe000404f: kIOUSBPipeStalled.
Sorry for the length, and I can add code chunks as people tell me which ones are likely to be interesting....