InterruptWait in callback

bridged with qdn.public.qnxrtp.photon
Post Reply
Neil Carter

InterruptWait in callback

Post by Neil Carter » Wed Oct 08, 2003 3:53 pm

Hi All,

I can't see anywhere in the docs that say explicitly that calling
InterruptWait is a bad thing to do in a Photon callback, but I suspect it is
(will prevent the GUI from cleaning up etc.).

Essentially, I want a parallel port interrupt to change some PtLabel text,
and re-enable a PtButton.

Can anyone advise on the merits of interrupt handling (without a dedicated
ISR) in Photon callbacks, or alternatives to what I'd like to achieve?

Many thanks.
Neil
--------------------------------------------
Neil Carter Psychology Department
IT Technician University of Wales Swansea
Wales, United Kingdom

http://psy.swansea.ac.uk/staff/Carter/

Chris McKillop

Re: InterruptWait in callback

Post by Chris McKillop » Wed Oct 08, 2003 4:07 pm

Photon apps are basically event pumps that cause callbacks to be invoked.
If you block in a callback you are stopping the event pump from running.
So what you want to do is use InterruptAttachEvent() and setup the sigevent
to be SIGEV_SIGNAL of SIGUSR1. Then do a PtAppAddSignalProc() for SIGUSR1.
Each time the interrupt fires your app will get a SIGUSR1 and your callback
will get called and you can do your label update.

The other route is to fire off another thread to do the InterruptWait()
blocking call and then use PtEnter/PtLeave and update the label.

chris


Neil Carter <pstech@swansea.ac.uk> wrote:
Hi All,

I can't see anywhere in the docs that say explicitly that calling
InterruptWait is a bad thing to do in a Photon callback, but I suspect it is
(will prevent the GUI from cleaning up etc.).

Essentially, I want a parallel port interrupt to change some PtLabel text,
and re-enable a PtButton.

Can anyone advise on the merits of interrupt handling (without a dedicated
ISR) in Photon callbacks, or alternatives to what I'd like to achieve?

Many thanks.
Neil
--------------------------------------------
Neil Carter Psychology Department
IT Technician University of Wales Swansea
Wales, United Kingdom

http://psy.swansea.ac.uk/staff/Carter/

--
Chris McKillop <cdm@qnx.com> "The faster I go, the behinder I get."
Software Engineer, QSSL -- Lewis Carroll --
http://qnx.wox.org/

Wojtek Lerch

Re: InterruptWait in callback

Post by Wojtek Lerch » Fri Oct 10, 2003 6:30 pm

Chris McKillop <cdm@qnx.com> wrote:
Photon apps are basically event pumps that cause callbacks to be invoked.
If you block in a callback you are stopping the event pump from running.
So what you want to do is use InterruptAttachEvent() and setup the sigevent
to be SIGEV_SIGNAL of SIGUSR1. Then do a PtAppAddSignalProc() for SIGUSR1.
Each time the interrupt fires your app will get a SIGUSR1 and your callback
will get called and you can do your label update.
Another way would be to use a pulse instead of a signal -- this way,
you won't have to worry about getting EINTRs everywhere:

pulse = PtAppCreatePulse( NULL, -1 );
PtAppAddInput( NULL, pulse, handler, data );
PtPulseArm( NULL, pulse, &sigevent );
InterruptAttachEvent( intr, &sigevent, flags );

Post Reply

Return to “qdn.public.qnxrtp.photon”