FROM : ed despard
DATE : Fri Nov 17 14:52:05 2006
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
DATE : Fri Nov 17 14:52:05 2006
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
| Related mails | Author | Date |
|---|---|---|
| ed despard | Nov 17, 14:52 | |
| Florent Pillet | Nov 24, 09:39 |






Cocoa mail archive

