sending bytes to parallel port

Timothy Smith timothy at open-networks.net
Sat Jul 29 02:39:21 EDT 2006


Diez B. Roggisch wrote:
>>  >>> 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
>   
*sigh*
if only pyparallel would install




More information about the Python-list mailing list