IOKit notifications
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