Parsing scan code event data received from a character device in Linux

  Kiến thức lập trình

I need some guidance regarding the parsing and de-serialization of binary data received from a character device in Linux. I’m working on writing a program in rust that monitors keyboard input used for various functions on my device. From the research I’ve done, the data should be parsed out into an input_event struct.

struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};

The problem I’m currently facing is that this doesn’t describe the entire block of data I receive from the character device which looks like the following:

[C, F5, 8F, 66, 0, 0, 0, 0, 33, 1A, 1, 0, 0, 0, 0, 0, 1, 0, 1D, 0, 1, 0, 0, 0, C, F5, 8F, 66, 0, 0, 0, 0, 33, 1A, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

I can easily assume that the last 64 bits make up type, code, and value, but I can’t seem to calculate the time stamp accurately.

Could someone lend me some guidance on how this data is parsed correctly?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT