Python脚本无法在启动时启动

时间:2017-03-03 08:23:04

标签: python raspberry-pi boot

目标:

  • 启动一个没有连接到PC的RaspberryPi-3B的python脚本

做了什么:

问题:

  1. 启动时,python脚本无法正常启动

  2. 插入LAN线后, python脚本完全启动。就我而言,这不是一种选择。 python脚本需要从“lan cable initiated system”

  3. 开始

    其他信息:

    这是python脚本:

    #!/usr/bin/python
    # OS modules #########################################################
    import time
    # GPIO Pin settings ##################################################
    import RPi.GPIO
    RPi.GPIO.setmode(RPi.GPIO.BCM)
    
    iLED1 = 21
    RPi.GPIO.setup(iLED1,RPi.GPIO.OUT)
    #######################################################################
    def LED(iPin,bStatus):
        RPi.GPIO.output(iPin,bStatus)
    
    bProgramLoop = True
    bLEDState = False
    while (bProgramLoop == True):
    
        if (bLEDState == False):
            LED(iLED1,True)
            time.sleep(0.5)
            bLEDState = True
    
        if (bLEDState == True):
            LED(iLED1,False)
            time.sleep(0.3)
            bLEDState = False
    

    这是添加到“sudo crontab -e”

    的行
    @reboot sh /home/pi/Misha/DataLogger/V1/launcher.sh >/home/pi/Misha/DataLogger/V1/logs/cronlog 2>&1 
    

    'launcher.sh'有以下条目

    #!/bin/sh
    # launcher.sh
    
    cd /
    cd home/pi/Misha/DataLogger/V1
    sudo python Test.py
    cd /
    

    “launcher.sh”脚本添加了以下属性:

    sudo chmod 777 launcher.sh
    

    并使用“sh launcher.sh”进行检查可以正常启动Test.py脚本。

0 个答案:

没有答案
相关问题