InterruptWait in callback

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/

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/

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 );