address a port
Erik Heneryd
erik at heneryd.com
Wed Mar 24 04:14:04 EST 2004
John Howard wrote:
> Basic has the inp() statement for accepting data from a port accessed
> from a memory location. Does python have a similar instruction?
No. On Linux, you could either use the ioperm()/inb()/related macros
(see http://www.hare.demon.co.uk/ioport/ioport.html for a simple Python
wrapper) or read from /dev/port if you got that device compiled in -
this function reads a byte (you'll need read access to /dev/port):
def inb(port):
f = file("/dev/port")
f.seek(port)
value = ord(f.read(1))
f.close()
return value
spam = inb(0x378) # get byte from LPT1
More (general) info can be found in the Linux I/O port mini-HOWTO:
http://www.faqs.org/docs/Linux-mini/IO-Port-Programming.html
HTH
Erik Heneryd
More information about the Python-list
mailing list