Problem to read on a serial port

Mar 30, 2005 3 Replies

hi



i need to read from a serial port (c programming)



we use a sixnet Mini-VersaTRAK mIPm

formatting link



under bash: ~ # stty -a


O_NDELAY is on my man page for open(2):

O_NONBLOCK or O_NDELAY When possible, the file is opened in non-blocking mode. Neither the open nor any subsequent operations on the file descriptor which is returned will cause the calling process to wait. For the handling of FIFOs (named pipes), see also fifo(4). This mode need not have any effect on files other than FIFOs.

It's the commonly accepted way to open a serial port when you don't want the open() to block waiting for carrier detect.

Setting the FNDELAY flag is then the way you set the file descripter back to blocking mode after you've set the CLOCAL bit in the termios struct to tell it to ignore carrier detect.

Grant Edwards grante Yow! World War III? No at thanks! visi.com

ledisplay);

^^^^^^^ That should be O_NDELAY-------------------------^^^^^^^

ledisplay);

If you're not going to set CLOCAL before setting FNDELAY, then you might as well just do the open without O_NDELAY and skip the fcntl() call. The same comment applies to the writeopen() function above.

descriptor\n",fd1);

Grant Edwards grante Yow! Clear the at laundromat!! This visi.com whirl-o-matic just had a nuclear meltdown!!

I am not familiar with the FNDELAY and O_NDELAY options to open. They are not standard Linux.

Ian

Ian Bell

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required