LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-17-2017, 05:01 AM   #1
Snaidy1
LQ Newbie
 
Registered: Sep 2012
Posts: 8

Rep: Reputation: Disabled
GPIO Btn read from Linux userspacce application


Hi Guyz,
I want to read the gpio status from my Linux application (user space) where an push button is connected.I want to know what are the method (Interrupt/ polling/ file read) I can make use to do it.

how I can get the interrupter from Linux GPIO driver to userspace ? is there a way ?

which is the best method to recognize & handle GPIO btn press in linux

Thanks,
Snaidy
 
Old 01-25-2017, 03:58 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
In user space you can use sysfs interface, for example in shell:
Code:
# for using gpio no. 5
echo 5 > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio5/direction
cat /sys/class/gpio/gpio5/value
# and when you end
echo 5 > /sys/class/gpio/unexport
Most embedded devices uses device tree to describe its hardware, then you can use kernel modules for handling buttons: gpio-keys-polled or gpio-keys. More info at GPIO kernel documentation
 
  


Reply

Tags
button, gpio, read


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read GPS Serial data from GPIO kinglizard86 Linux - Hardware 2 08-25-2014 02:50 AM
Read/Write Gpio using direct access registers PayalG Linux - Embedded & Single-board computer 1 07-24-2014 06:40 PM
write & read data serially to one GPIO pin answerme Programming 2 10-01-2013 04:51 PM
[SOLVED] How to interact with the processor from within linux, read a GPIO port, use timers... nickboarder27 Linux - Embedded & Single-board computer 2 07-27-2012 11:01 AM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration