|
From: Floris v. N. <flo...@gm...> - 2007-04-16 14:14:15
|
Hello,
I've got a question about timing incoming IR signals and decoding them
in Windows. I know this might not be the best place, because you're
probably all Linux guys, but still you might be able to help me, at
least I hope so.
Here's my story. I've built a device which detects IR signals at 38KhZ
and sends interrupts to the parallel port. Then I created (well, I
didn't write it entirely, but I edited one I found on the internet) a
driver to catch those interrupts and I created a usermode program to
interact with the driver. So far so good, everything seemed to work
fine. I receive interrupts when I press a button on my remote control
or when I just connect a wire between pin 2-9 and 10 of the parallel
port.
But there's also a problem. For some reason, I receive way too few
interrupts when I press a button on my remote control, and the time
between the interrupts always is nearly identical. My only guess is
that for some reason processing an interrupt hasn't finished yet when
the next interrupt arrives and that therefore that interrupt doesn't
get handled. That should also explain why the time between logged
interrupts is nearly identical; it always takes the same time to
complete one interrupt and after that it can handle another. But I
don't get why handling the interrupt would take that long. My pc
should be fast enough to handle it.
Here's my isr and dpc routine and after that the part in DriverEntry
where I connect the interrupt to my driver. When an interrupt occurs,
first the isr gets called and then the dpcroutine.
I hope any of you have an idea why it doesn't handle all interrupts or
what the problem is and how it can be fixed. I'd really like it if we
can get this working. Or maybe you could give me a quick explanation
how the timing is done in LIRC.
Thanks in advance,
Floris van Nee
BOOLEAN hwinterfaceIsr(IN PKINTERRUPT Interrupt, IN OUT PVOID Context)
{
PDEVICE_OBJECT DeviceObject = Context;
KdPrint( ("hwinterface.sys: Interrupt Service Routine\n") );
/* We should check if the interrupt comes from us and return */
IoRequestDpc(DeviceObject,
DeviceObject->CurrentIrp,
NULL);
return TRUE;
}
VOID hwinterfaceDpcRoutine(IN PKDPC Dpc, PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PVOID Context)
{
PLOCAL_DEVICE_INFO DeviceExtension;
PIRP pIrp;
pIrp = DeviceObject->CurrentIrp;
DeviceExtension = DeviceObject->DeviceExtension;
//Get the current 'time' and print it to kernel debug
KeQueryTickCount((PLARGE_INTEGER)&TickCount);
KdPrint(("Interrupt: %d", TickCount));
return;
}
DeviceExtension = DeviceObject->DeviceExtension;
DeviceExtension->Level = 7;
DeviceExtension->Vector = DeviceExtension->Level;
MappedVector = HalGetInterruptVector(Isa,
0,
DeviceExtension->Level,
DeviceExtension->Vector,
&Irql,
&DeviceExtension->Affinity);
if (MappedVector == 0) DbgPrint("hwinterface.sys:
HalGetInterruptVector failed\n");
IoInitializeDpcRequest(DeviceObject,hwinterfaceDpcRoutine);
KdPrint(("%d", &DeviceExtension->InterruptObject));
status = IoConnectInterrupt(&DeviceExtension->InterruptObject, //
InterruptObject
hwinterfaceIsr, // ServiceRoutine
DeviceObject, // ServiceContext
NULL, // SpinLock
MappedVector, // Vector
Irql, // Irql
Irql, // SynchronizeIrql
Latched, // InterruptMode
FALSE, // ShareVector
DeviceExtension->Affinity, // ProcessorEnableMask
FALSE); // FloatingSave
if (!NT_SUCCESS (status)) DbgPrint("hwinterface.sys:
IoConnectInterrupt Failed\n");
|