Help- low level control of mouse device
Andrew Kuchling
akuchlin at mems-exchange.org
Mon Sep 4 10:57:42 EDT 2000
rob <europax at home.com> writes:
> tp=open('/dev/psm0','wb+') #open device
> tp.write(`0xff`) #reset touchpad
> print tp.read() #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 os.open() function which returns a file descriptor, and use
os.read() / 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.
--amk
More information about the Python-list
mailing list