全志V853芯片 如何解决getevent运行出错,报错为“could not add watch for /dev/input”的问题?

时间:2022-10-18 12:54:41

一、问题背景

如果系统已经注册了input设备,想要使用getevent命令去获取input事件时,发现getevent运行会报错,不能正常运行。

报错信息为:could not add watch for /dev/input, Function not implemented

如下图所示:

全志V853芯片 如何解决getevent运行出错,报错为“could not add watch for /dev/input”的问题?

二、问题分析

通过小机端目录/dev/input/下,发现是有event*的,证明是已经注册有input设备了,有input设备getevent就可以正常运行。

通过getevent源码得知,"could not add watch"的错误是由于运行函数inotify_add_watch(),获取不到所对应的inotify的watch而产生的。

全志V853芯片 如何解决getevent运行出错,报错为“could not add watch for /dev/input”的问题?

inotify是一个内核用于通知用户空间程序文件系统变化的机制,现在获取不到inotify可以判断为内核空间没有给到用户空间权限或者是接口。

内核空间是有对应的配置使能用户空间的接口的,选上该配置,即可解决问题。

全志V853芯片 如何解决getevent运行出错,报错为“could not add watch for /dev/input”的问题?

PS:另外,使用cat /dev/input/event* | hexdump -C 也可以获取input事件。