Skip navigation.
Home
The QNX Community Portal

View topic - Trying to get SIGIO with ioctl

Trying to get SIGIO with ioctl

Read-only archive of qnx.porting (Discuss migrating applications from QNX4, VxWorks, PSOS, or Linux to QNX Neutrino) at inn.qnx.com

Trying to get SIGIO with ioctl

Postby darioml40 » Tue Dec 13, 2005 9:50 am

Hi.

I'm trying to read efficiently from a serial port, using QNX 6.3. Instead of an always polling procedure:
Code: Select all
while (1)
  read(fd, buff, 1)


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

In my program I have
Code: Select all
#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

:( :( 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

:( :(

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 :(

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

Any suggestion??

Thanks!

Dario
darioml40
Active Member
 
Posts: 15
Joined: Tue Oct 11, 2005 8:26 am

Re: Trying to get SIGIO with ioctl

Postby Igor Kovalenko » Wed Jan 04, 2006 3:40 am

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 :(

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

:( :( 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

:( :(

I'm following some examples for qnx that I found in internet:
http://www.pjwstk.edu.pl/~jms/qnx/help/ ... d_tut.html
http://cvs.qnx.com/cgi-bin/cvsweb.cgi/l ... .c?rev=1.1

they use the first solution... but it doesn't work with me :(

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

Any suggestion??

Thanks!

Dario
Igor Kovalenko
 

RE: Re: Trying to get SIGIO with ioctl

Postby Dheerajs » Tue Feb 14, 2006 10:05 am

could you please explain about the devctl function of your driver?? means how you are generating the signal!!!
Dheerajs
Active Member
 
Posts: 91
Joined: Mon Jan 31, 2005 8:50 am
Location: Germany


Return to qnx.porting

Who is online

Users browsing this forum: No registered users and 1 guest