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
Villy Kruse

2005-08-01, 2:55 am

On 30 Jul 2005 10:17:30 GMT,
Simon Elliott <> wrote:


> In a lot of serial port code examples, there are calls to both open and
> fcntl to set/clear flags, for example:
>
> fd = open(devicename, O_RDWR | O_NOCTTY | O_NDELAY);
> fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY));
>
> If you want nonblocking I/O with the O_NDELAY option, is it necessary
> to specify it twice, once in the open() call and once in the fcntl()
> call?
>


You open a tty port with O_NDELAY if you want to open it before Data
Carrier Detect is asserted. Without O_NDELAY the open will block
until carrier is present. That is, unless CLOCAL is set on the device.


Villy
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com