Re: [python-win32] Getting address for Parallel port

2011-05-18 Thread Tony Cappellini

 The hacked up I/O port driver you're using is a huge security risk.

Our test machines are not connected to a network, and we don't ship systems
or software.
The test machines are strictly for use in an engineering testing
environment.

USB drivers have proven to be too flaky. Some work well, some don't. You
never know what you're going to end up with until weeks
into a testing period when a driver hangs the machine.
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Getting address for Parallel port

2011-05-17 Thread Tim Roberts
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