10/18/08

python parallel port on Windows

Tried different ways of controlling parallel port with Python on Windows. The easiest way is with Inpout32.dll.

Just download the dll, put it in system32 folder. Then from python:
from ctypes import windll
p = windll.inpout32
p.Inp32(0x378) #default 255(all high) on my pc
p.Out32(0x378, 0) #put all low on port 2-9


The address 0x378 might be different on your machine, open System->Hardware->Device Manager->Ports->ECP Printer Port->Properties->Resources, use the first number as your address.

16 comments:

Anonymous said...

i've been trying to use inpout32 for i proyect i hace to do, but i'm getting a error whenever i run the line "p = windll.inpout32".
I get the message:

Traceback (most recent call last):
File "pyshell#2", line 1, in module
p = windll.inpout32
File "C:\Python26\lib\ctypes\__init__.py", line 423, in __getattr__
dll = self._dlltype(name)
File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] No se puede encontrar el módulo especificado


could yo help me with that? i'm using python 2.6

Anonymous said...

im sorry i leave that comment, i realized it was a stupid mistake just a second after leaving it (I only had to read the mistake xD). I have two windows instals on my HD, so i copied the dll to the wrong one. The program works perfect with Python 2.6, thanks dude

Unknown said...

Hi,
I am using Python 2.5, if I import ctypes and get an instance of inpout32 i am receiving this error message plz help to solve this.

>>> import ctypes
>>> from ctypes import windll
>>> p = windll.inpout32

Traceback (most recent call last):
File "pyshell#3", line 1, in "module"
p = windll.inpout32
File "C:\Python25\lib\ctypes\__init__.py", line 423, in __getattr__
dll = self._dlltype(name)
File "C:\Python25\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

smaffeis said...

thamk you, i put the DLL in is place and work perfecly.
regards

VikWiz said...

Thanks a lot, Works like a charm , easier than winioport/Dlportio.dll

Anonymous said...

I´m from Brazil. Thank you... You help me a lot.

Unknown said...

is there a way to target a single pin with this method

Unknown said...

Dont worry i figured it out
e.g
Pin 2 is port.Out32(0x378, 4)

Anonymous said...

In case you are using the State ports of your parallel port (pins 10 through 13 and 15), and you're wondering how to read those out: They are one byte 'behind' the Data address, so try:

p.Inp32(0x379)

instead of using 0x378 as address. Note that, since there are only five Control ports, the maximum value is 248 for all high (usually the default).

See for example these sites for further explanations:
http://www.bbastrodesigns.com/parallel.html
http://www.machinegrid.com/2008/12/parallel-port-tutorial-part-1/

imseakin said...

Does this dll work if you want to use a USB to parallel port converter on a newer laptop that doesn't have a parallel port? I've got some great projects for high school students and being able to use usb-parallel converter would mean a cheap way to do them.
thanks for your advice.

Anonymous said...

Hello. Need help. I've got 2 different versions of inpout (I use windows 7 64-bit).
One folder is called InpOutBinaries and contains hwinterfacex64.sys, inpoutx64.dll and inpoutx64.lib.
Do I need to copy all of these files?
And where should I copy them ? C:\Windows\System32 or C:\Windows\System32\drivers ?

The second folder is called InpOutBinaries_1500 and contains inpoutx64.dll, inpoutx64.lib and vssver2.scc. And in the Win32 folder it has a InstallDriver.exe which when executed creates a inpoutx64.sys in C:\Windows\System32\drivers
But I cannot use this inpoutx64.sys with ctypes.windll

So which one is the proper version?
Thanks for helping a noob out

Wensheng Wang said...

Sorry I can't help on windows 7 issue. This post is 4 years old. Most current generation computers that run win7 don't even have parallel port. So it not likely anyone will debug the problem.

Anonymous said...

no problem I already fixed it by switching to winring0
But I also got winpoutx64 working by running the installer as admin and I also copied the files to my python project directory.

And then I just did ctypes.windll.inpoutx64.Out32
and that worked.

Do you know how to perform a CLI (Clear Interrupts) or STI (Set Interrupts) in windows x64 ? I'm not sure if this works with either inpout or winring0

PBC Sweep Program said...

I double checked that inpout32.dll is in C:\Windows\System32. I am also getting the same error when I try

p = windll.inpout32

Traceback (most recent call last):
File "", line 1, in
p = windll.inpout32
File "C:\Python27\Lib\ctypes\__init__.py", line 435, in __getattr__
dll = self._dlltype(name)
File "C:\Python27\Lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

I made sure that PYTHONPATH had C:\Windows\System32 included.

Looking at other posts, this seems to possibly be a stupid question, but could you please give me some advice?

I am using Windows 7, 64 bit and I need to be able to control my parallel port. I have a program called "Parallel Port Tester.exe" that successfully flips all the pins on and off, so I have the right port address and it is functioning. I am not sure what is wrong here, but this is definitely not working for me.

Unknown said...

Thank you for your tips. I found what, I had been searching for so long If you will lost your files, try to download it here https://fix4dll.com/vcruntime140_dll vcruntime140.dll missing for your PC. It is totally fast way for installing of losted file.

Anonymous said...

Gambling in the Casino 888: No deposit bonus casino - Air
Gambling in air jordan 18 retro red from my site the Casino 파라오 바카라 888: No deposit bonus casino. Gambling in the Casino air jordan 18 retro red online site 888: best air jordan 18 retro racer blue No deposit bonus casino. Gambling air jordan 18 stockx shop in the Casino 888: No deposit bonus casino. Gambling in the Casino 888: No