OpenQNX :: The QNX Community Portal

Jul 25, 2008 - 04:47 PM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 23 unlogged users and 4 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
darioml40
9 Post subject: Trying to get SIGIO with ioctl  PostPosted: Dec 13, 2005 - 09:50 AM
Active Member


Joined: Oct 11, 2005
Posts: 15

Hi.

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

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


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

In my program I have
Code:

#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

Sad Sad 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

Sad Sad

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 Sad

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

Any suggestion??

Thanks!

Dario
 
 View user's profile Send private message  
Reply with quote Back to top
Igor Kovalenko
Post subject: Re: Trying to get SIGIO with ioctl  PostPosted: Jan 04, 2006 - 03:40 AM
Guest





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...
Quote:
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

:( Sad 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
 
   
Reply with quote Back to top
Dheerajs
Post subject: RE: Re: Trying to get SIGIO with ioctl  PostPosted: Feb 14, 2006 - 10:05 AM
Active Member


Joined: Jan 31, 2005
Posts: 91
Location: Germany
could you please explain about the devctl function of your driver?? means how you are generating the signal!!!
 
 View user's profile Send private message Yahoo Messenger  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.