Tony Cappellini wrote:
>
> We are using PCI &PCIe Parallel Port plugin cards to control some
> external hardware because newer motherboards no longer have built-in
> parallel ports.

It would be a much better long term strategy to move to USB for this. 
There are a large number of very simple USB cards with 16 or 24 fully
programmable I/O pins.  The hacked up I/O port driver you're using is a
huge security risk.

> These plugin cards can get mapped into various address spaces when the
> driver loads.

Right -- in most BIOSes, the port number is derived from the PCI slot
number.

> In order to  minimize hard-coding these addresses on each system, I
> would like to find out if there is a way to get this address via
> Pythonwin or Ctypes.

Not easily.  You can use the SetupDi APIs to enumerate through the set
of parallel port devices, then use SetupDiGetDeviceInfoListDetail and
CM_Get_First_Log_Conf_Ex to fetch the resource list, then a couple other
CM_ APIs to crack that format and find the port number, but in my
opinion it's a lot easier to ask the user to check the Device Manager
resources page and type in the port number to use.

If you insist, the "devcon" sample in the WDK has code that shows how to
do this.

> To turn the port on & off, I use this call:
> ctypes.windll.inpout32.Out32(parallelPortAddress, onOff) via ctypes,
> and this DLL
> http://logix4u.net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html

That's dangerous.  Any application can use that driver to gain access to
any arbitrary I/O port.  There's a reason why port access is not allowed
from user mode.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to