Getting Interrupt from Parrallel Port using ACK

Hi,

I’m working on QNX 6.2.1

I would like to trigger my parrallel port using the ack line.
I have written a little Interrupt handler.
Basically it does this :


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <sys/siginfo.h>
#include <sys/neutrino.h>
#include <hw/inout.h>

#define IRQ 7

struct sigevent event;
int d=0;

const struct sigevent *handler(void *area, int id)
{
d++;
return(&event);
}

int main()
{
int id;

ThreadCtl(_NTO_TCTL_IO, NULL);

id = InterruptAttach(IRQ, &handler, NULL, 0, 0);
while (d<100) {
InterruptWait(NULL, NULL);
InterruptUnmask(IRQ, id);
printf("%0x\n",d);
}
InterruptDetach(id);
return 0;
}

I works well with irq 1 (keyboard) or irq 12 (mouse), but with the parrallel port it does not work.
I perhaps need to enable interrupt on the parralel port ?

Any help will be welcome.

Y.LEROUX <A_ENLEVER_y.leroux@actris.com> wrote:

Hi,

I’m working on QNX 6.2.1

I would like to trigger my parrallel port using the ack line.
I have written a little Interrupt handler.
Basically it does this :

Do you have devc-par running already? If so, you probably need to
slay it off. You may, also, have to (re-)configure the parallel port
to generate an interrupt – I’m pretty sure our driver does not use
interrupts for the parallel port, so probably disables them (in the
parallel port hardware.)

-David


#include <stdio.h
#include <stdlib.h
#include <time.h
#include <signal.h
#include <errno.h
#include <unistd.h
#include <time.h
#include <sys/siginfo.h
#include <sys/neutrino.h
#include <hw/inout.h

#define IRQ 7

struct sigevent event;
int d=0;

const struct sigevent *handler(void *area, int id)
{
d++;
return(&event);
}

int main()
{
int id;

ThreadCtl(_NTO_TCTL_IO, NULL);

id = InterruptAttach(IRQ, &handler, NULL, 0, 0);
while (d<100) {
InterruptWait(NULL, NULL);
InterruptUnmask(IRQ, id);
printf("%0x\n",d);
}
InterruptDetach(id);
return 0;
}

I works well with irq 1 (keyboard) or irq 12 (mouse), but with the parrallel port it does not work.
I perhaps need to enable interrupt on the parralel port ?

Any help will be welcome.


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Do you have devc-par running already? If so, you probably need to
slay it off. You may, also, have to (re-)configure the parallel port
to generate an interrupt – I’m pretty sure our driver does not use
interrupts for the parallel port, so probably disables them (in the
parallel port hardware.)

I tryed to slay devc-par but nothing better.
How to configure the parallel port for generating an interrupt ?

Thanks for you reply.

By reading this :
http://www.lvr.com/files/ibmlpt.txt

I found that i have to set BASE+2 bit 4 to 1 :

out8(BASE+2, in8(BASE+2) | 0x10);

Thanks for your help.

It now works correctly

For information, it seems to work with devc-par running but after a little time
it stop working (perhaps devc-par reset the bit 4 in the control register)
When slaying devc-par it works well.

Y.LEROUX <A_ENLEVER_y.leroux@actris.com> wrote:

For information, it seems to work with devc-par running but after a little time
it stop working (perhaps devc-par reset the bit 4 in the control register)

Could be. In general it is a BAD idea to have two different (and non
coordinating) pieces of software controlling the same hardware.

When slaying devc-par it works well.

Yes, this is a good idea. (Or, don’t run it in the first place.)

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.