Mailing Lists: Apple Mailing Lists

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

RE: CFRunLoopRun() hangs up after ReadPipeAsync() called in Mac O S X



Hi, 
Actually I tried to use ReadPipe() first but we got error -536870168. Then
the printer refused to accept/receive any data.

-----Original Message-----
From: Paul Nicholson [mailto:email@hidden]
Sent: Friday, March 22, 2002 3:01 PM
To: Kane Zheng; 'email@hidden'
Subject: Re: CFRunLoopRun() hangs up after ReadPipeAsync() called in Mac
OS X


Hi,

Rather than use WritePipeAsync and mess with CFRunLoop, I just call
WritePipe. Put the synchronous WritePipe call in a function and call that
function with pthread_create. Why bother to set up an AsyncCompletion
routine, and mess with CFRunLoop. You can put your completion code after the
call write to WritePipe in the function that gets called by pthread_create.

My guess it is more efficient as I suspect the CFRunLoop stuff is built on
top of pthreads. Anybody know for sure?

Paul


At 5:59 PM -0500 3/21/02, Kane Zheng wrote:
>Hello all,
>
>We are trying to communicate with a printer through USB on MAC OS X.
>Basically we did followings:
>
>1. OpenUSBPort(). Here we make: IOUSBInterfaceInterce, inPipe, and outPipe,
>etc ready.  CreateInterfaceAsyncEventSource(), and CFRunLoopAddSource() are
>called here.
>
>2. WriteToPort(). Here we called WritePipeAsync(intfIntf, outPipe, outBuf,
>nSize, WriteCompletion, dummy), then call CFRunLoopRun(). WriteCompletion
>function is called as expected. Inside WriteCompletion function, we called
>CFRunLoopStop(CFRunLoopGetCurrent(). Everything goes fine.
>
>3. ReadFromPort(). We called ReadPipeAsync(intfIntf, inPipe, inBuf, nSize,
>ReadCompletion, dummy). The programming returns with noErr here. Then we
>called CFRunLoopRun( ), which leads the application hangs there forever.
>This results that the ReadCompletion function never got called. Inside
>ReadCompletion function, we called CFRunLoopStop(CFRunLoopGetCurrent(). If
>we remove the CFRunLoopRun() inside ReadFromPort(), sometimes we can get
>data back, but not everytime. There is no such problem for this printer on
>other OS.
>
>4. CloseUSBPort() just does the cleanup.
>
>Could someone help me out from the hanging up problem?
>
>Thanks in advance.
>
>Kane Zheng
>
>Scanvec Amiable.
>_______________________________________________
>usb mailing list | email@hidden
>Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
>Do not post admin requests to the list. They will be ignored.
_______________________________________________
usb mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
Do not post admin requests to the list. They will be ignored.



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.