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.