Ioport is a Python 'C' extension that allows you to address hardware I/O ports from a Python script. It will only work on Linux x86 hardware. Its a simple wrapper around the standard Linux ioperm/outb/inb macros.
I wrote this because a friend asked me for help test some hardware he designed that is driven by the printer port. 'Python' I thought, but I was surprised to find that a Python extension for this didn't seem to exist. So I wrote one.
CAVEAT: Messing around with your hardware ports can be bad for your PC's health. Use ioport with caution.
Here's some sample code to set bit 0 on the first printer port.
import ioport ioport.ioperm(0x3bc, 1, 1) ioport.outb(0x01, 0x3bc)
If Python segfaults while using ioport, its most likely that you haven't called ioperm, or your trying to input/output to a port you haven't ioperm'd.
ioport - A Python extension for input/output to hardware ports. Ioport is a simple wrapper for the Linux ioperm/outb/inb calls, and it shares many of their characteristics & limitations. In particular, Python will segfault if you attempt i/o without calling ioperm first. See the Linux IO-Port-Programming Mini-HOWTO by Riku Saikkonen (Riku.Saikkonen@hut.fi) for more details. The following calls are supported: ioperm(port, len, onoff) outb(value, port) inb(port)
ioperm(port, len, onoff) Turn onoff ioperm for calling process for port block at 'port', length 'len'.
outb(value, port) Output the byte 'value' to io port 'port'.
inb(port) Return a byte with the input read from 'port'.