SIGIO and ioctl

Hi.

I’m trying to read efficiently from a serial port, using QNX 6.3. Instead of an always polling procedure:

while (1)
  read(fd, buff, 1)

I’m trying to use the SIGIO signal. The problem is that I cannot generate it :frowning:

In my program I have

#include <sys/wait.h>
#include <ioctl.h>

main
{
  ....
  signal(SIGIO, sigio_handler);
  ....
  pid_t pgrp = getpid();
  int on = 1;
  memset(&gData, 0, sizeof(gyro_data_t));
	
  /* Open Serial port for reading GYRO */
  gData.gfd = open(SERIAL_PORT_GYRO, O_RDONLY | O_NOCTTY | O_NONBLOCK);
  DBGP("Serial " SERIAL_PORT_GYRO " opened: %d\n", gData.gfd);
  if(gData.gfd < 0)
	errexit("open " SERIAL_PORT_GYRO);

  /* set the process receiving SIGIO signals */
  if(ioctl(gData.gfd, SIOCSPGRP, &pgrp) < 0)
	errexit("ioctl SIOCSPGRP");
  /* allow receipt of asynchronous I/O signals */
  if(ioctl(gData.gfd, FIOASYNC, &on) < 0)
	errexit("ioctl FIOASYNC");
}

It opens the serial port in non-blocking mode. Later I try to set which process should receive the SIGIO and SIGURG signals. And, finally, I set the anynchronous mode too.

The problem is that ioctl(gData.gfd, SIOCSPGRP, &pgrp) returns:

ioctl SIOCSPGRP: Function not implemented

:frowning: :frowning: The SIGCSPGRP label is not even declared in /usr/include/sys/ioctl.h but it seems to recognize it…

If I try ioctl(gData.gfd, TIOCSPGRP, &pgrp), since TIOCSPGRP is defined in ioctl.h, it says:

ioctl TIOCSPGRP: Inappropiate I/O control operation

If I try fcntl(gData.gfd, F_SETOWN, &pgrp), since F_SETOWN is declared in fcntl.h, it says:

fcntl F_SETOWN: Function not implemented

:frowning: :frowning:

I’m following some examples for qnx that I found in internet:
http://www.pjwstk.edu.pl/~jms/qnx/help/tcpip_4.25_en/prog_guide/sock_advanced_tut.html
http://cvs.qnx.com/cgi-bin/cvsweb.cgi/lib/socket/rcmd.c?rev=1.1

they use the first solution… but it doesn’t work with me :frowning:

The SIGIO doesn’t come. And if I generate it with raise(SIGIO), it comes then, but doesn’t appear any more :frowning:

Any suggestion??

Thanks!

Dario

Look at io_notify or select(). I’m not sure the serial driver support SIGIO.

Probably you can check the devctl function implementation. My first suggestion is to check the data structure you are using for registering the device with the io-net. The order of the function in the structure , _io_net_registrant_funcs , for the devctl function