In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to set up the startup of raspberry pie in service mode. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
First, write a simple python script
The script is very simple, just send a light flashing program to the raspberry. If you need to learn gpio, you can read my previous blog.
The file is saved in / home/pi/script/ledblink.py
#! / usr/bin/env python
Import RPi.GPIO as GPIO
Import time
GPIO.setmode (GPIO.BCM)
GPIO.setup (21m GPIO. Out)
While True:
Try:
GPIO.output (21Jing True)
Time.sleep (1)
GPIO.output (21Jing false)
Time.sleep (1)
Except (KeyboardInterrupt, SystemExit):
GPIO.close ()
Print "exit"
The startup script can be python, shell, or an executable file compiled by the C language C++.
Second, boot startup script
Save the script as / etc/init.d/ledblink file
#! / bin/bash
# / etc/init.d/ledblink
# BEGIN INIT INFO
# Provides: embbnux
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ledblink initscript
# Description: This service is used to manage a led
# END INIT INFO
Case "$1" in
Start)
Echo "Starting LED Blink"
/ home/pi/script/ledblink.py &
Stop)
Echo "Stopping ledblink"
# killall ledblink.py
Kill $(ps aux | grep-m 1 'python / home/pi/script/ledblink.py' | awk' {print $2}')
*)
Echo "Usage: service ledblink start | stop"
Exit 1
Esac
Exit 0
3. Set the python script to boot
Sudo chmod + x / etc/init.d/ledblink
In this way, you can start the script and use the service command.
Sudo service ledblink start# start
Sudo service ledblink stop# stop
Finally, just set it up and start it.
Sudo update-rc.d ledblink defaults
When you're done, restart the raspberry pie and you'll find led flashing itself. Just stop using sudo service ledblink stop.
About how to use the service mode to set up and start raspberry pie to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.