LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 09-17-2013, 04:04 PM   #1
henryyao
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Rep: Reputation: 0
can I access /sys/class/gpio/gpioxx in the rc3.d?


I have the following test.sh script in the /etc/init.d and a link of it in the rc3.d as S90test. And my run level is 3.

So my purpose is to read the gpio and choose which program to run.
But when I reboot, it will always run test2. However, if I type "sh ./test.sh" in the terminal after the booting, it will gives me test1. And I did not change the hardware input.

So I wonder is this /sys/class/gpio/gpio94/value file exists before the test.sh is invoked during rebooting?

#! /bin/bash
source /etc/profile

value=`cat /sys/class/gpio/gpio94/value`
echo $value
if [ $value -eq 0 ]
then
./test1
else
./test2
fi
 
Old 09-17-2013, 04:50 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,160

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
If you look at some of the entries in /etc/init.d you will see that they do modprobe to load the modules that they need. Loading the gpio module will most likely create those sysfs files.
 
Old 09-17-2013, 07:41 PM   #3
henryyao
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: 0
I've checked the init.d directory and the rc3.d directory. I'm assuming my script to have S90, and there is only a S99rmnologin which runs after my script.

So if it was like what you mentioned, this gpio module must be loaded in somewhere else, not in the rc3.d. Is there a way to find it out?

And btw, there is no rc.local in my system.

Quote:
Originally Posted by smallpond View Post
If you look at some of the entries in /etc/init.d you will see that they do modprobe to load the modules that they need. Loading the gpio module will most likely create those sysfs files.
 
Old 09-18-2013, 07:36 AM   #4
henryyao
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: 0
I dont know why but after a day this is working...I did not modify anything.
 
  


Reply



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
what's the difference bewteen using /sys/class/gpio and gpio_key driver henryyao Linux - Newbie 2 08-23-2013 08:27 AM
[SOLVED] writing to /sys/class/gpio/export sharan013 Linux - Embedded & Single-board computer 5 02-22-2012 11:08 AM
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 03:57 PM
/sys/class/hwmon Question Aztral Linux - General 1 08-11-2009 02:00 PM
Giving user access to files in /sys/class/ subdirectory and /dev/video0 DiBosco Programming 1 12-01-2008 03:11 AM

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

All times are GMT -5. The time now is 05:33 PM.

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