Solution: Direct access to Printer I/O lines
jkndeja at my-deja.com
jkndeja at my-deja.com
Mon Dec 18 08:44:57 EST 2000
Hi Alex,
OK, without (yet...) going too deep into the more-generalised-and-
interesting patterns discussion developing here:
If I/you/we don't want singleton objects, but _do_ want to avoid having
multiple processes accessing a single port, how about this:
class directlpt:
def __init__(self, LPTNum):
# gives me access to an LPT port
...
def inb(self, offset):
# I'm always allowed to read the port
...
def inw(self, offset):
# likewise
...
def claim(self, timeout = ??):
# I have to claim the resource to be able to write to it
...
def outb(self, offset)
# otherwise I get an exception (IOERrror?) here...
def outb(self, offset)
# and here
def release(self):
# I release it for other processes as soon as I'm done
Thanks
Jon N
Sent via Deja.com
http://www.deja.com/
More information about the Python-list
mailing list