address a port

John Howard python473 at yahoo.com
Wed Mar 24 23:38:05 EST 2004


This is great. But what about win 98, win 95, xp, 2000?


Erik Heneryd <erik at heneryd.com> wrote in message news:<mailman.327.1080119662.742.python-list at python.org>...
> 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