I'm currently working on a project where I want to control my PC with an AVR, via emulating a PS/2 keyboard. For this reason I currently have all the required hardware and some software libs, such as https://github.com/ndusart/ps2-keyboard for the AVR and http://python-evdev.readthedocs.io/en/latest/index.html for the PC part.
I also read about the PS/2 protocol from http://www.pcbheaven.com/wikipages/The_PS2_protocol/, http://www.computer-engineering.org/ps2protocol/ and http://retired.beyondlogic.org/keyboard/keybrd.htm

Then I've ran the command sudo cat /dev/input/by-path/platform-i8042-serio-0-event-kbd > ./kbrd.hex and connected a keyboard, then pressed and released the backspace.
I would except something like AA 66 F0 66, and maybe some FA's (ACK) in between, but what I've got is very different:

enter image description here

So my question:
Could this be caused by my misunderstanding of the working behavior of /dev/input/, or the problem is in the other parts of my setup? I expect to get the raw input from the buffer from /dev/input/, and this isn't that I think the raw should be.

Another hexdump AFTER plugging in the keyboard: enter image description here

  • 2
    You can also use evtest, which will pretty print the input_event structure, to help you understand what is going on. Note that kernel input events are not the raw PS/2 protocol. If your question is how to access the raw PS/2 protocol, this needs some additional steps.
    – dirkt
    Dec 10, 2017 at 9:31

1 Answer 1


The way you describe the process, you: started capturing output, plugged in the keyboard, pressed a key, then stopped capturing. If that is the case, I would recommend plugging in the keyboard, start capture, press key, stop capture?

EDIT: Adding additional information

I haven't gotten anything in my own quick research to fully line up with your dumps so far, but:

Per kernel.org documentation and source code, output from /dev/input interfaces is in the format:

struct input_event {
    struct timeval time;
    unsigned short type;
    unsigned short code;
    unsigned int value;

Which equates to:

  • timeval: 16 bytes (8 bytes for seconds, 8 bytes for microseconds)
  • type: 2 bytes
  • code: 2 bytes
  • value: 4 bytes 01 for keypress, 00 for release, 02 for autorepeat
  • Edited Question with another dump
    – Sasszem
    Dec 9, 2017 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.