事件按钮作为模块或用户程序? [英] Event button as a module or as user program?

查看:183
本文介绍了事件按钮作为模块或用户程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编程一个按钮来启动基于Linux的板上的软件。
在基于Linux的嵌入式板上的按钮。 GPIO没有使用该Linux内核,所以我使用了事件接口。该按钮基本上是按按钮来激活所有的硬件,并在按下两次时停止硬件。我想知道写作内核模块还是用户程序?或作为deamon?

解决方案

如果可以在用户空间(即守护进程)中执行此操作,那么应该在那里进行。 / p>

在这种情况下,两者都可能需要。你需要以某种方式访问​​按钮,这取决于硬件的外观。那么你需要回应一个事件,然后根据这个进行一些操作。



遵循策略不属于内核的口头禅,这意味着您可以(并且可能需要)从内核处理按钮本身,您需要从用户空间启动应用程序部分。内核不应该在开始新的用户空间进程的业务。相反,它应该通过例如netlink套接字传递给用户空间。然后,您需要一个用户空间守护程序,该守护程序在netlink套接字上侦听并响应某些事件启动应用程序。


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?

解决方案

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.

这篇关于事件按钮作为模块或用户程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆