Unix Programming - Re: Serial port: open vs fcntl

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > August 2005 > Re: Serial port: open vs fcntl





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Serial port: open vs fcntl
Floyd L. Davidson

2005-08-01, 8:30 am

"Simon Elliott" <Simon at ctsn.co.uk> wrote:
>On 01/08/2005, Villy Kruse wrote:
>
>
>Thanks, this is useful info. Would the same be true for O_NONBLOCK?


Yes, and in that particular way they are always identical.

However, O_NONBLOCK is defined by POSIX and will be the same on
all platforms while O_NDELAY has slight variations between some
platforms. Hence O_NONBLOCK is preferred for portability.

>
>I was under the impression that I could only set CLOCAL via termios(2).
>Can I achieve the same thing with open(2)?


In a C program the way to set or clear the CLOCAL flag is with
termios. However, you cannot guarantee the state of the serial
port before you open it; therefore the *only* correct way to do
so is with the O_NONBLOCK flag set in open(). After it is open
the CLOCAL flag can be set as desired, and blocking can be set
as desired with fcntl().

--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com