IONotificationPortCreate on an existing mach port with existing notification port
IONotificationPortCreate on an existing mach port with existing notification port
- Subject: IONotificationPortCreate on an existing mach port with existing notification port
- From: Joel Reymont <email@hidden>
- Date: Fri, 19 Nov 2010 14:03:36 +0800
I'm trying to combine user-space USB code with GCD and I'm finding that my async notification callback is not being triggered. I don't have a CFRunLoop and I'm using this hack instead:
extern "C"
{
// http://lists.apple.com/archives/darwin-dev/2010/Apr/msg00072.html
void IONotificationPortSetDispatchQueue(IONotificationPortRef notify, dispatch_queue_t queue );
};
In absence of a run loop, I can't go the standard route of
(*interface)->CreateInterfaceAsyncEventSource(interface, &runLoopSource);
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode);
I'm trying to work around it like this
IOUSBInterfaceInterface245 **intf_;
mach_port_t async;
IOReturn kr = (*intf_)->CreateInterfaceAsyncPort(intf_, &async);
dispatch_queue_t que_ = dispatch_queue_create("com.agilent.82357b.usb", NULL);
IONotificationPortRef notify = IONotificationPortCreate(async);
IONotificationPortSetDispatchQueue(notify, que_);
(*intf_)->ReadPipeAsync(intf_, pipe, buffer, size, AsyncInterruptCallback, &data);
but AsyncInterruptCallback is never called.
Does IONotificationPortCreate give me a whole new notification port compared to the one used by IOUSBInterfaceClass::CreateInterfaceAsyncPort internally and associated with the mach port that it's returning?
Is there a workaround?
Can I get the IONotificationPortRef associated with an existing mach port somehow?
Thanks, Joel
P.S. This is the relevant chunk of CreateInterfaceAsyncPort
IOReturn
IOUSBInterfaceClass::CreateInterfaceAsyncPort(mach_port_t *port)
{
IOReturn kr;
mach_port_t masterPort;
ATTACHEDCHECK();
// If we already have a port, don't create a new one.
if (fAsyncPort)
{
if (port)
*port = IONotificationPortGetMachPort(fAsyncPort);
return kIOReturnSuccess;
}
// First create a master_port for my task
kr = IOMasterPort(MACH_PORT_NULL, &masterPort);
if (kr || !masterPort)
return kIOReturnError;
fAsyncPort = IONotificationPortCreate(masterPort);
...
---
http://twitter.com/wagerlabs
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden