Trying to get SIGIO with 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

[code:1:b1c8369a8a]
#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”);
}
[/code:1:b1c8369a8a]

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

What serial driver do you use? If it is one of the ‘embedded’ ones that may
be why…

“darioml40” <darioml@gmail-dot-com.no-spam.invalid> wrote in message
news:dnm5n8$qpf$1@inn.qnx.com

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

[code:1:b1c8369a8a]
#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”);
}
[/code:1:b1c8369a8a]

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

could you please explain about the devctl function of your driver??
means how you are generating the signal!!!