Asynchronous IO for serial port on Linux

Asynchronous IO for serial port on Linux

Post by Yoong Hor Men » Wed, 12 Feb 2003 15:35:39

*** post for FREE via your newsreader at ***


I would like the signal SIGPOLL (or SIGIO) to be sent to the application
when something is available on the serial port.   So I tried to use
asynchronous IO for serial port on Linux, but the function ioctl always
returns the error "invalid argument".  Here is the code:

 /* ... */

  /* open the serial port and obtain the file descriptor */
  fd = open("/dev/ttyS0", O_RDWR | O_NONBLOCK | O_NDELAY | O_NOCTTY, 0)
  if (fd == -1)
    if (ioctl(fd, I_SETSIG, S_RDNORM) == -1)
      (void) perror("Error ioctl: ");

 /* setting up the poll events, etc */

 /* ... */

 Could someone help me on this? Does linux 2.4.10 support asynchronous
IO on serial port (a stream device)

Hor Meng

 -----= Posted via Newsfeed.Com, Uncensored Usenet News =----- - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----


1. Asynchronous IO (porting to Solaris)

I'm porting an application from SunOS 4.1.3 to Solaris 5.5 (on a
Sparc 5) that uses fcntl to receive asynchronous, non blocking input
stdin.  The exact call on SunOS is:

  char c[1];
  fcntl (0, F_SETFL, O_NDELAY | FASYNC);
  read (0,&c,1);

Since FASYNC does not exist on Solaris I replaced it

  int   one=1;
  char c[1];

  ioctl (0, FIONBIO, &one);     /* Just like p.322 in UNIX Network */
  ioctl (0, FIOASYNC, &one);    /* Programming by W. Richard Stevens */
  read (0,&c,1);

The next time I do a read it blocks waiting for input.  It works
fine on SunOS with fcntl but does not work with ioctl on SunOS
or Solars. For some reason the fcntl is able to turn off the blocking,
but ioctl does not stop the blocking.

Any ideas?  Please send e-mail.

thanks in advance,

2. Printer as console output?

3. asynchronous serial port programming

4. Recruiter: US-CA-LA--Senior Internet Security Specialist sought!

5. TRIVIAL: remove space in cache names

6. is asynchronous IO available on SuSE Linux 7.2

7. gateway address

8. Asynchronous serial port input

9. how does Linux enable Asynchronous IO on a file descriptor?

10. asynchronous io in linux?

11. serial search reserves IO ports...

12. Serial port io too slow!