This is my personal blog. I also have a professional blog at http://siliconsparrow.com/

10 August 2009

Parallel port control in Python

Filed under: Nerd Notes — adam @ 11:11 am

Controlling the parallel port has always been a pain in Windows 2000, XP and later. In DOS or older versions of Windows you could just write a byte directly to port 0×378 and that was it.

Now you can get the same level of simplicity using inpout32.dll and Python. Go here to download the DLL and you can access it from Python just as easily as it used to be under DOS. The following example writes the number 5 to the parallel port:

import ctypes

ctypes.windll.inpout32.Out32(0x378, 5)


UPDATE: I have made a simple demo app using this technique. You can download it from my commercial website at http://siliconsparrow.com/parallel-port-tester-in-python/.

5 Comments »

  1. Comment by Gil — 25 October 2009 @ 11:42 pm

    Will this hold the port to 5 or will it revert instantly to 0?

  2. Comment by adam — 27 October 2009 @ 9:16 pm

    It will hold it until you write a different value to the port.

  3. Comment by Gil — 28 October 2009 @ 6:20 pm

    Thanks for the info

  4. Comment by David — 7 December 2009 @ 3:25 pm

    Hey – thanks Adam.

    Much appreciated – I’ve been pulling my hair out trying to solve this for hours.

  5. Comment by ebswift — 8 September 2010 @ 6:16 am

    Hi Adam, I made a sprinkler control system using inpout32 and a parallel relay controller here:

    http://www.ezsprinkle.com

    I started using the app on a Win7x64 box and discovered my little program wouldn’t work. To fix it I’ve moved on to WinRing0 and found it to be a simple, reliable solution. My controller waters 6 stations around my yard all controlled from the HTPC.

RSS feed for comments on this post.

Leave a comment

COMMENTS ARE DISABLED DUE TO EXCESSIVE SPAM. I'm sorry about this, I really love to read your comments but the amount of time I spend deleting spam is too much.


Powered by WordPress