0

I have an init.d script that successfully runs scripts to an LED board from Adafruit using this software: https://github.com/hzeller/rpi-rgb-led-matrix

In addition, I've set up a simple single LED circuit and can operate it using this software: https://projects.drogon.net/raspberry-pi/wiringpi/the-gpio-utility/

When I run my gpio script for the LED it has no problems. When I run the loop to do both at the same time, no issues. All as user pi.

When init.d runs the loop on startup, the gpio script called up inside other scripts doesn't appear to run. It doesn't seem to set the pins to where they can be written to. When the loop is running, it should set

#!/bin/bash
gpio mode 26 out
end=$((SECONDS+20))

while [ $SECONDS -lt $end ]; do 
  gpio write 26 1
  sleep 2
  gpio write 26 0
  sleep 1
done

But it does not appear that the settings are changed when I use the gpio program to check gpio readall

What is likely the culprit here? The script works just fine when run either as user pi or as sudo just not through init.d or root.

  • I can't see how we can help without visibility of the script(s) you are running. – joan Sep 14 '15 at 17:04
  • I can provide the scripts, but I'm not sure they're that relevant since they run when executed normally. But fair point, I just don't have them backed up here at work. – ezgoodnight Sep 14 '15 at 17:06
  • If something runs "normally" but not from a boot script it is usually because the paths aren't identical. Are you using absolute path names for any programs and code you are using, e.g. where is gpio on the filesystem, are you using gpio or /usr/bin/gpio or whatever. – joan Sep 14 '15 at 17:09
  • The most common cause of this is it isn't running at all because of paths or a dud init script. You should incorporate some logging so you can confirm this and report any errors that may occur. – goldilocks Sep 14 '15 at 17:11
  • These are good suggestions. gpio was installed by a friend of mine, I'll have to check where. It makes sense if I can find where it's installed and change the script (now recreated above) to that. – ezgoodnight Sep 14 '15 at 17:12
1

By default wiringPi's gpio utility is installed in /usr/local/bin.

It is unlikely to be in the path of the root user when init scripts are run.

Rather than gpio use /usr/local/bin/gpio.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.