Help- low level control of mouse device

Andrew Kuchling akuchlin at
Mon Sep 4 16:57:42 CEST 2000

rob <europax at> writes:
> tp=open('/dev/psm0','wb+')  #open device
> tp.write(`0xff`)    #reset touchpad
> print     #read ack

The file objects returned by the open() built-in use the C stdio
library to do I/O; this means that they do buffering, which will mess
up matters for Unix device files, since data you write may still be
sitting and waiting in the buffer.  Solutions:

1) Try opening the file in unbuffered mode: open('/dev/psm0', 'wb+', 0)
2) Use the function which returns a file descriptor, and use / os.write().

Incidentally, line 2 is wrong if you're trying to send byte 255 to the
device; use chr(0xff).  `0xff` returns the repr() of 0xff, so line 2
writes the string '255' to the file.


More information about the Python-list mailing list