2

I have run the code below but I don't understand the result.

Python code:

f = open('/dev/input/event4', 'r')
while True:
    print f.read(8)

and the result is very weird:

>>> 5Q�
>>> 
>>> 5Q
>>> 
>>> 5Q

When I press a key, it adds an incomprehensible code. Thank you for help!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
newuser
  • 67
  • 3
  • 8
  • 3
    Did you study what the Linux event subsystem *does* at all? Did you try printing the `repr()` instead to visualize the binary byte stream? – Martijn Pieters Mar 04 '13 at 21:22
  • What were you expecting to happen? – Burhan Khalid Mar 04 '13 at 21:22
  • http://lxr.linux.no/linux+v3.8.2/Documentation/input/input.txt and http://lxr.linux.no/linux+v3.8.2/Documentation/input/event-codes.txt – Robᵩ Mar 04 '13 at 21:23
  • If this is a sensible question, it's probably a dup of [python - format of /dev/input/event*](http://stackoverflow.com/questions/5060710/format-of-dev-input-event). – abarnert Mar 04 '13 at 21:24

0 Answers0