RE: close on USB serial port hangs (read pending) on Snow Leopard
RE: close on USB serial port hangs (read pending) on Snow Leopard
- Subject: RE: close on USB serial port hangs (read pending) on Snow Leopard
- From: "Matthew Owings" <email@hidden>
- Date: Thu, 18 Feb 2010 15:41:09 -0800
- 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:email@hidden]
Sent: Thursday, February 18, 2010 2:40 PM
To: Matthew Owings
Cc: email@hidden
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden