[ECOS] how to use flag O_NDELAY and O_NONBLOCK in eCos serial port programming
Edgar Grimberg
edgar.grimberg@rms.ro
Tue Jul 26 06:22:00 GMT 2005
Indra Antonius Simalango wrote:
>dear all,
>
>Below are my quote snippet. It would open a serial fax device as a file.
>It returns the file descriptor on success or -1 on error.
>-------------------------------------------------------------------------
>
>#include <stdio.h>
>#include <string.h>
>#include <unistd.h>
>#include <fcntl.h>
>#include <errno.h>
>#include <termios.h>
>
>int main(void)
>{
> int fd;
> fd = open("/dev/ser1", O_RDWR | O_NOCTTY | O_NDELAY);
> if (fd == -1) {
> perror("open_port: Unable to open /dev/ser1 - ");
> }
> else fcntl(fd, F_SETFL, 0);
> return (fd);
>}
>------------------------------------------------------------------------
>
>I've got an error message while compiling and linking it :
>
> testserial.c:11: 'O_NDELAY' undeclared (first use in this function)
> testserial.c:11: (Each undeclared identifier is reported only once
> testserial.c:11: for each function it appears in.)
>
>I've read some "Posix Serial Communication", and then try to replace
>O_NDELAY by O_NONBLOCK. There's no error message after compile and link.
>But when executing on my target pci386, it got an error message :
>
> open_port : Unable to open /dev/ser1 - Invalid argument
>
>Is flag O_NONBLOCK really an invalid argument to open a serial port on
>eCos? Or maybe there's another way to do this.
>
>Thank you.
>
>
Hi,
Try reading this:
http://ecos.sourceware.org/docs-latest/ref/io-user-api.html
and press next a couple of times.
Edgar
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list