public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] how to use flag O_NDELAY and O_NONBLOCK in eCos serial port programming
@ 2005-07-26  4:00 Indra Antonius Simalango
  2005-07-26  6:22 ` Edgar Grimberg
  0 siblings, 1 reply; 2+ messages in thread
From: Indra Antonius Simalango @ 2005-07-26  4:00 UTC (permalink / raw)
  To: ecos-discuss


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] how to use flag O_NDELAY and O_NONBLOCK in eCos serial port programming
  2005-07-26  4:00 [ECOS] how to use flag O_NDELAY and O_NONBLOCK in eCos serial port programming Indra Antonius Simalango
@ 2005-07-26  6:22 ` Edgar Grimberg
  0 siblings, 0 replies; 2+ messages in thread
From: Edgar Grimberg @ 2005-07-26  6:22 UTC (permalink / raw)
  To: Indra Antonius Simalango; +Cc: ecos-discuss

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-07-26  6:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-26  4:00 [ECOS] how to use flag O_NDELAY and O_NONBLOCK in eCos serial port programming Indra Antonius Simalango
2005-07-26  6:22 ` Edgar Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).