none
Writing to LPT Port RRS feed

  • Question

  • I'm creating an XP Embedded image for a project, and I need to control a couple of LEDs through the LPT port.  I've verified that the hardware works because when the unit is powered on, all of the LEDs come on.  Then while Windows is initializing and (I'm guessing) the Parport driver loads, the LEDs all turn off.

    I have a Visual C++ program that opens LPT1 with the following function call:
    CreateFile("LPT1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

    Now, this program will successfully open the LPT port (LPT1) on a standard XP install on a PC, but when I run the same application on my XP Embedded target (an Intel 915GM chipset board... nothing fancy or exotic) I get an INVALID_HANDLE_VALUE returned, and GetLastError( ) returns ERROR_ACCESS_DENIED.

    Since the program runs on a regular XP PC, I'm guessing that I'm missing some important yet obscure component in my Target Designer project.  I looked in the Device Manager on the running target, and the Parallel Port device is listed as in good working order.  No errors, standard Microsoft driver installed (same driver, in fact, as my desktop machine... from 2000). 

    I checked the BIOS on the board, and the printer port is set to Basic/Legacy mode.  No ECP turned on.

    Here's a list of the included components that I think are relavent:
    -Printer Port
    -Printer Common #1
    -Printing
    -Local Printing


    Components not included yet but willing to try:
    -ECP Printer Port - and enable ECP printer port in the BIOS
    -Local Printing Support (in BOLD)


    Does anyone have any experience with the LPT port on an XPe-powered target?  Any suggestions on components to add or remove to get this to work??

    Thanks in advance!!
    -Russell
    Sunday, August 19, 2007 5:28 AM

Answers

  •  

    Hi,

     

    I often use the parallel port on XPe but I rather use the WinIO.dll or inp32.dll to access the port directly than using the CreateFile call... If you access the port directly then you don't need the operating system LPT driver?

     

    Rudi Grobler

    http://dotnet.org.za/rudi

     

    Sunday, August 19, 2007 10:01 AM

All replies

  •  

    Hi,

     

    I often use the parallel port on XPe but I rather use the WinIO.dll or inp32.dll to access the port directly than using the CreateFile call... If you access the port directly then you don't need the operating system LPT driver?

     

    Rudi Grobler

    http://dotnet.org.za/rudi

     

    Sunday, August 19, 2007 10:01 AM
  • I've never used either of those DLLs.  How do I go about adding or using them?
    Sunday, August 19, 2007 1:42 PM
  •  

    It's very easy... thy have sample code for using it in C#, C++ and VB...

     

    Have a look at this codeproject article on how to use it using c# and inp32.dll

     

    http://www.codeproject.com/csharp/csppleds.asp

     

    Rudi Grobler

    http://dotnet.org.za/rudi

     

    Sunday, August 19, 2007 4:29 PM
  • Examples are good.  I'll give it a shot and report back.  Thanks!
    Sunday, August 19, 2007 5:04 PM
  • I finally got the error in my original code to go away by moving the Open command to my class' constructor instead of from the Initialize function that was called later.  I don't understand why that made a difference, but it did.  However, when I tried writing to the port, the program would hang. 

    So I gave WinIo a try, and it works!  I'm tossing out the old code I had and am switching over to this now.  Thanks for the suggestion!


    Sunday, August 19, 2007 6:24 PM