我正在运行armbianlinux,并试图在引导时执行一个shell文件。当我在引导后通过命令行执行该文件时,它运行得非常好。但是,当它在引导期间运行时,它会跳过我的Python命令(应该是将动画发送到OLED屏幕)。但是,它仍然可以打开和关闭LED。你知道吗
shell文件放在/etc/init.d中,我运行了以下命令。你知道吗
sudo update-rc.d startup.sh defaults
sudo update-rc.d startup.sh enable
chmod +x /etc/init.d/startup.sh
这是shell文件。你知道吗
#!/bin/sh
### BEGIN INIT INFO
# Provides: startup
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: display to screen
### END INIT INFO
main() {
#GPIO numbers for the RGB-Led Pins
RGB_GPIO_RED=157
RGB_GPIO_GREEN=156
RGB_GPIO_BLUE=154
#OLED settings
OLED_I2C_PORT=2
OLED_ORIENTATION=2
OLED_DISPLAY_TYPE='sh1106'
# turn on the blue led while configuring and updating
cd /sys/class/gpio
sudo sh -c 'echo '$RGB_GPIO_BLUE' > export'
cd gpio$RGB_GPIO_BLUE
sudo sh -c 'echo out > direction'
sudo sh -c 'echo 1 > value'
cd ~
# display cardano animation
python ~/display/cardano-luma/examples/cardano-animation.py --display $OLED_DISPLAY_TYPE --i2c-port $OLED_I2C_PORT --rotate $OLED_ORIENTATION
# turn off blue led and on the green led
cd /sys/class/gpio
sudo sh -c 'echo '$RGB_GPIO_BLUE' > export'
cd gpio$RGB_GPIO_BLUE
sudo sh -c 'echo out > direction'
sudo sh -c 'echo 0 > value'
cd ..
cd /sys/class/gpio
sudo sh -c 'echo '$RGB_GPIO_GREEN' > export'
cd gpio$RGB_GPIO_GREEN
sudo sh -c 'echo out > direction'
sudo sh -c 'echo 1 > value'
cd ~
# display rock pi information
sudo python ~/display/cardano-luma/examples/cardano.py --display $OLED_DISPLAY_TYPE --i2c-port $OLED_I2C_PORT --rotate $OLED_ORIENTATION
}
main "$@" || exit 1
目前没有回答
相关问题 更多 >
编程相关推荐