Event button as a module or as user program?

无人久伴 提交于 2020-01-25 17:52:30

问题


I am programming a push button to start the software in a linux based board. A push button on Linux based embedded board. GPIO didn't work with that Linux kernel, so instead, I used the event interface. The button is basically listening for button press to activate all the hardware and stops the hardware when it's pressed twice. I would like to know whether write as a kernel module or as a user program? Or as a deamon?


回答1:


If it's possible to do it in user space (i.e. daemon) you should do it there.

In this case both might be required. You'll need to access the button somehow, which will depend on what the hardware looks like. Then you'll need to respond to an event and perform an action based on that.

Following the 'policy does not belong in the kernel' mantra, this means that while you can (and probably need to) handle the button itself from the kernel you need to do the starting the application part from user space. The kernel should not be in the business of starting new user space processes. Instead it should pass the even to user space, through a netlink socket for example. You then need a user space daemon which listens on the netlink socket and starts the application in response to certain events.



来源:https://stackoverflow.com/questions/10572608/event-button-as-a-module-or-as-user-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!