CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    2

    parallel port interrupt handler

    Hello,

    I've got a question about timing incoming IR signals and decoding them
    in Windows.

    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.

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

  2. #2
    Join Date
    Mar 2007
    Posts
    157

    Re: parallel port interrupt handler

    First of all tell me. Do you have any problem to switch on com port? Printer port has its limitation’s. Please read Printer port mode details and select as desired mode in bios. May be you can feel some relief. If you are interested in doing same thing through serial port so I can help you fully.

    Thanx

  3. #3
    Join Date
    Jul 2011
    Posts
    1

    Re: parallel port interrupt handler

    Hello Mystret, I'm doing something similar. Did you ever resolve your issue? Can you share your source and/or object code?

    Thanks,
    Brian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured