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.