Solution: Direct access to Printer I/O lines

jkndeja at my-deja.com jkndeja at my-deja.com
Fri Dec 15 04:20:38 EST 2000


OK, fired by my own enthusiasm I have started work on a 'directlpt'
class extension for Python under Linux, to allow one to get easy access
to the actual data lines.

I have the following thoughts about the interface, and would be
interested in any comments:

Since (in the general case) I want to restrict port access to only the
LPT ports, and since I will need to know when to use ioperms to
allow/disallow port access, I suggest:

- The module implements a class, say directlpt
- The module only allows three 'Singleton' instances of the class,
corresponding to LPT1--3. This is set up in the constructor:

import directlpt

l1 = directlpt.directlpt(1) # gives access to LPT1:

anotherl1 = directlpt.directlpt(1) # will raise an exception - only one
instance allowed

l2 = directlpt.directlpt(2) # gives access to LPT2:

l_bad = directlpt.directlpt(15) # raises an exception - out of range

and then you can write simething like

l2.inb(directlpt.STATUS) # to read the status port.


Comments?

    Thanks
    Jon N



Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list