Re: Serial device open(2) hang.
Re: Serial device open(2) hang.
- Subject: Re: Serial device open(2) hang.
- From: David Elliott <email@hidden>
- Date: Sun, 28 Jun 2009 17:22:58 -0400
Hi Steve,
On Jun 28, 2009, at 2:03 PM, Steve Checkoway wrote:
On Jun 27, 2009, at 9:14 PM, David Elliott wrote:
Change your open call to O_RDWR | O_NONBLOCK. This will cause
open not to block thus allowing you to get a working file
descriptor and keeping a handle open to the device (this is
important).
Once you have that you need to run stty against it or I suppose you
can use termios functions but honestly I am not all that familiar
with serial programming, I just happened to be doing it the other
week on another project.
What I came up with was this:
This worked perfectly! I now have my computer talking to itself via
a null modem cable with both ends plugged into the usb to serial
adapter. Time to see if I can talk to this microcontroller.
Glad to hear it. If you look over on darwin-kernel I've just posted a
message about SerialKDPProxy which is where that code comes from.
That is the project I referred to that I happened to be working on the
other week.
The file that the code snippet comes from can be found in SVN here:
http://tgwbd.org/svn/Darwin/SerialKDPProxy/trunk/src/SerialKDPProxy.c
Probably of no interest to you but there you have it.
And Kevin (kvv) is right. I could have and probably should have used
posix_spawn rather than fork/dup2/exec except I completely forgot that
it existed in relatively modern POSIX.
-Dave
_______________________________________________
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