Re: use of c select() style events with the objc run loop
Re: use of c select() style events with the objc run loop
- Subject: Re: use of c select() style events with the objc run loop
- From: Nicko van Someren <email@hidden>
- Date: Mon, 10 May 2004 17:43:20 +0100
On 10 May 2004, at 16:57, Robert Goldsmith wrote:
I want to monitor input on a raw serial port - something I would use
select for under c. However, has anyone any suggestions on how I can do
it using the event system in a gui objc app? This is a raw serial port,
not a tcp port, being controlled using the standard posix/c read and
write commands.
I would like to be able to catch and display serial port input and
transmit typed content from an NSTextView without the serial port
routines blocking. An event sounds the most sensible and, if I have to,
I suppose I could use a timer and poll, but that seems wrong somehow :)
As far as I can tell there is neither any generic way to bridge kernel
events into the run-loop event system nor any good way to perform
select type operations in a run loop. I think that there must be some
way to do this which is used in the implementation of the NSTCPPort
objects but I've no idea (a) how it works or (b) if it's applicable to
serial ports.
Given the above my suggestion would be for you to spawn a separate
thread which makes blocking class to read and then passes the data back
to the main run loop by calling
performSelector:target:argument:order:modes: on the main run loop
object.
Nicko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.