sending bytes to parallel port

Diez B. Roggisch deets at nospam.web.de
Sat Jul 29 02:26:26 EDT 2006


> 
>  >>> fd = open('/dev/ppi0','w')
>  >>> fcntl.ioctl(fd.fileno(),'PPISCTRL',10000000)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
> TypeError: an integer is required
> 
> i guess i'm failing to properly define the int i need for the 8byte 
> value ineed to send the port to set pins high /low

Python doesn't know about PPISCTRL - it has no way of knowing all 
"secret", OS-specific constants for ioctl-calls.

So, you need to figure out the numeric value of that constant .- look it 
up in the appropriate header-file.

Then, you do have the next problem with passing that 10000000 value of 
yours. ioctl expects strings or buffers as parameters which contain a 
byte-representation of the value you want to set. This is an snippet I 
use to read the event device capabilities under linnux:


buf = array.array('c', [' ' for i in xrange(EV_MAX / 8 + 1)])
fcntl.ioctl(self._fd, EVIOCGBIT(0, len(buf)), buf, True)
caps = struct.unpack("I", buf)[0]

HTH,

Diez



More information about the Python-list mailing list