• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
IOKit notifications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IOKit notifications


  • Subject: IOKit notifications
  • From: ed despard <email@hidden>
  • Date: Fri, 17 Nov 2006 08:52:05 -0500

I apologize for the other two empty body messages with the same title, Im not sure what was happening with my mail client.

Hi, Im trying to receive notifications of usb device connection and termination from within my cocoa apps. Apples CF based example code works fine, but when I converted their code to work in my application, i never receive any notifications. The relevent code is provided below


- (void) awakeFromNib
{
kern_return_t kr;

NSMutableDictionary* matchingDict = IOServiceMatching (kIOUSBDeviceClassName);
NSNumber* usbVendor = [NSNumber numberWithInt:1027];
NSNumber* usbProduct = [NSNumber numberWithInt:24592];
[matchingDict takeValue:usbVendor forKey:@"kUSBVendorID"];
[matchingDict takeValue:usbProduct forKey:@"kUSBProductID"];

notifyPort = IONotificationPortCreate(kIOMasterPortDefault);
CFRunLoopSourceRef runLoopSource;
runLoopSource = IONotificationPortGetRunLoopSource(notifyPort);
NSRunLoop* currentRunLoop = [NSRunLoop currentRunLoop];
CFRunLoopRef CFRunLoop = [currentRunLoop getCFRunLoop];
CFRunLoopAddSource(CFRunLoop, runLoopSource, kCFRunLoopDefaultMode);

kr = IOServiceAddMatchingNotification( notifyPort, // notifyPort
kIOFirstMatchNotification, // notificationType
matchingDict, // matching
DeviceAdded, // callback
NULL, // refCon
&gAddedIter
);
DeviceAdded(NULL,gAddedIter);
}


the usbVendor and USBProduct ids are correct for my device.
notifyport is a member of the class
IOServiceAddMatchingNotification does return KERN_SUCCESS


thanks, Ed Despard _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: IOKit notifications
      • From: Florent Pillet <email@hidden>
  • Prev by Date: Re: CFRunLookFindMode crash - solved
  • Next by Date: Re: CFRunLookFindMode crash - solved
  • Previous by thread: IOKit notifications
  • Next by thread: Re: IOKit notifications
  • Index(es):
    • Date
    • Thread