This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
how to use flag O_NDELAY and O_NONBLOCK in eCos serial port programming
- From: Indra Antonius Simalango <indra at vlsi dot itb dot ac dot id>
- To: <ecos-discuss at sourceware dot org>
- Date: Tue, 26 Jul 2005 11:00:14 +0700 (WIT)
- Subject: [ECOS] how to use flag O_NDELAY and O_NONBLOCK in eCos serial port programming
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.
--
regards,
IndrA on 18:49, Jul 20
http://ic.ee.itb.ac.id/~antonius
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss