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?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
- Null-terminated string, opening file for reading
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.