pythonstartupeofeoferror

EOFerror on startup


after loading script on startup I got a error EOFerror: Script is running in CLI mode. EOF when reading a line.

Barcode: Trace back (most recent call last): File "/home/pi/BCKHL.py", line 48, in compare() File "/home/pi/BCKHL.py", line 20, in compare barcode=input("barcode:")

Script is working when is running manually.

here is code for script:

import RPi.GPIO as GPIO
    ###setup###
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(18, GPIO.OUT) #Ventil 1#
GPIO.output(18, GPIO.LOW)
GPIO.setup(21, GPIO.OUT) #Ventil 2#
GPIO.output(21, GPIO.LOW)
GPIO.setup(38, GPIO.OUT) #Ventil 1 crvena led#
GPIO.output(38, GPIO.HIGH)
GPIO.setup(40, GPIO.OUT) #Ventil 1 zelena led#
GPIO.output(40, GPIO.LOW)
GPIO.setup(35, GPIO.OUT) #Ventil 2 crvenaled#
GPIO.output(35, GPIO.HIGH)
GPIO.setup(37, GPIO.OUT) #Ventil 2 zelena led lampa#
GPIO.output(37, GPIO.LOW)

def compare():
    while True:
        barcode=input("Barcode:")
        if barcode=="S5000070931":
            GPIO.output(18, GPIO.HIGH)            
            GPIO.output(21, GPIO.LOW)
            GPIO.output(38, GPIO.LOW)
            GPIO.output(40, GPIO.HIGH)
            GPIO.output(35, GPIO.HIGH)
            GPIO.output(37, GPIO.LOW)

            continue
        elif barcode=="S5000057670":
            GPIO.output(18, GPIO.LOW)
            GPIO.output(21, GPIO.HIGH)
            GPIO.output(40, GPIO.LOW)
            GPIO.output(38, GPIO.HIGH)
            GPIO.output(35, GPIO.LOW)
            GPIO.output(37, GPIO.HIGH)
            continue
        else:
            print("Molim Vas da skenirate ispravan barkod")
            GPIO.output(18, GPIO.LOW)
            GPIO.output(21, GPIO.LOW)
            GPIO.output(38, GPIO.HIGH)
            GPIO.output(35, GPIO.HIGH)
            GPIO.output(40, GPIO.LOW)
            GPIO.output(37, GPIO.LOW)
            continue

compare()

Does anyone know how to fix this issue?

Thank you.


Solution

  • Try running it from .bashrc

    sudo nano /home/pi/.bashrc
    

    on last line write:

    echo Running at boot 
    sudo python3 /home/pi/BCKHL.py
    

    And dont forget to remove it from rc.local if u still have it there.