LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 05: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, 05:50 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,636

Rep: Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705
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, 08: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, 08: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


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


All times are GMT -5. The time now is 03: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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration