Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trouble talking to USB2 printer



I have USB software that we use to talk to various USB/USB2 printers that has worked fine for many different printers. We need to work with a new printer - a Kodak 9810 - and are running into an odd problem. We get the notification that the device was added, the problem is once we get the IOUSBDeviceInterface and call CreateInterfaceIterator on that, we get back an empty iterator (i.e. the first call to IOIteratorNext returns NULL), thus cannot get the IOUSBInterfaceInterface - from testing we've done, we clearly get the correct IOUSBDeviceInterface. Our code fragment is below and works for all of the other printers we've used - what could be going wrong with this printer?

Alan

void USBDeviceAdded(void *refCon, io_iterator_t iterator)
{
while (io_service_t usbService = IOIteratorNext(iterator))
{
SInt32 score;
IOCFPlugInInterface** plugInInterface = NULL;
kern_return_t kr = IOCreatePlugInInterfaceForService (usbService, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score);


        if (plugInInterface == NULL) // error
            continue;

IOUSBDeviceInterface** device = NULL;
HRESULT res = (*plugInInterface)->QueryInterface (plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*)&device);
(*plugInInterface)->Release(plugInInterface);


        if (device == NULL) // error
            continue;

        USBDevice* usbDevice = USBFindInterfaces(usbService, device);
        if (usbDevice)
            PrinterList::GetPrinterList()->DeviceAdded(usbDevice);
        else
            (*device)->Release(device);
        kr = IOObjectRelease(usbService);
    }
}

USBDevice* USBFindInterfaces(io_service_t usbService, IOUSBDeviceInterface **device)
{
USBDevice* result = NULL;


    IOUSBFindInterfaceRequest request;
    request.bInterfaceClass = kIOUSBFindInterfaceDontCare;
    request.bInterfaceSubClass = kIOUSBFindInterfaceDontCare;
    request.bInterfaceProtocol = kIOUSBFindInterfaceDontCare;
    request.bAlternateSetting = kIOUSBFindInterfaceDontCare;

io_iterator_t iterator;
IOReturn kr = (*device)->CreateInterfaceIterator(device, &request, &iterator);


while (io_service_t usbInterface = IOIteratorNext(iterator))
{
SInt32 score;
IOCFPlugInInterface** plugInInterface = NULL;
kr = IOCreatePlugInInterfaceForService(usbInterface, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score);
kr = IOObjectRelease(usbInterface);


        if (plugInInterface == NULL) // error
            continue;

// I have the interface plugin. I need the interface interface
IOUSBInterfaceInterface **interface = NULL;
HRESULT res = (*plugInInterface)->QueryInterface (plugInInterface, CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID), (LPVOID*) &interface);
(*plugInInterface)->Release(plugInInterface); // done with this


        if (interface == NULL) // error
            continue;

        UInt8 intfClass;
        kr = (*interface)->GetInterfaceClass(interface, &intfClass);

        if (intfClass == kUSBPrintingClass)
            result = new USBDevice(usbService, device, interface);
        else
            (*interface)->Release(interface);
    }
    return result;
}


_______________________________________________ Do not post admin requests to the list. They will be ignored. Usb mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.