When ever i press the button it need to run a shell command

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

When ever i press the button it need to run a shell command

ソリューションへジャンプ
1,295件の閲覧回数
aravinthkumarja
Senior Contributor II

Hi All,

I'm using iMX6 sabresd board and Android 6 platform. Any one of gpio i configured as button.

When ever the user press the button, i need to run a shell command(or shell script) on board.

How can i do this .?

Regards,

Aravinth

ラベル(4)
0 件の賞賛
1 解決策
962件の閲覧回数
aravinthkumarja
Senior Contributor II

Thanks for your response Carlos. I have used call_usermodehelper function to call shell command in kernel.

Regards,

Aravinth

元の投稿で解決策を見る

0 件の賞賛
6 返答(返信)
961件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi,

in the following link you will find the code for a .ko module which handles a GPIO interrupt and the device tree configuration required for this.

Issue with configuring GPIO as an interrupt - i.MX6Q 

For the shell command you can just use a system call E.g. sytem("command");


Regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
961件の閲覧回数
aravinthkumarja
Senior Contributor II

Hi Carlos,

Thanks for your response.  For system function what library i have to use in imx6 kernel.?

Regards,

Aravinth

0 件の賞賛
962件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

it is stdio.h, this is a general C question, you can find a lot of information if you Google "linux shell command in c program" or "linux c system function".

0 件の賞賛
962件の閲覧回数
aravinthkumarja
Senior Contributor II

Hi carlos,

I have used system function in normal c application. But in kernel code we can't add stdio.h. So i'm not able to use system function in kernel.!

Regards,

Aravinth

0 件の賞賛
962件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

You can make an application that communicates with the kernel module. So the module will use copy_to_user function to tell the applications that a button was pressed and the application will execute the shell command.

0 件の賞賛
963件の閲覧回数
aravinthkumarja
Senior Contributor II

Thanks for your response Carlos. I have used call_usermodehelper function to call shell command in kernel.

Regards,

Aravinth

0 件の賞賛