RE: close on USB serial port hangs (read pending) on Snow Leopard
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Thread-index: Acqw61Js285xUhjQRR6bhcYUyjOwQQAB7tlQ Thread-topic: close on USB serial port hangs (read pending) on Snow Leopard We do something similar in our app, except we do not put our serial port reading on a different thread, although we would like to at some point. We have a timer checking to see if there are any bytes to read that fires 10 times a second. If there is nothing to read it returns immediately. In your thread, you could have the thread sleep for a bit if there is no data. -----Original Message----- From: Fritz Anderson [mailto:fritza@manoverboard.org] Sent: Thursday, February 18, 2010 2:40 PM To: Matthew Owings Cc: darwin-dev@lists.apple.com Subject: Re: close on USB serial port hangs (read pending) on Snow Leopard On 18 Feb 2010, at 3:36 PM, Matthew Owings wrote:
Might I suggest not doing a blocking read. Then when you need to close the port, set a flag that tells the thread it needs to end. Then when the thread has terminated, close the port.
I'm perplexed. The nature of reading from a serial device is that the data is intermittent, and in single bytes. If I did a non-blocking read, I'd have to poll, would I not? And get nothing back from virtually all the calls? Wait. Should I be using select()? I admit to being very naive. - F _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Matthew Owings