gwaag
Posts: 89
Joined: Tue Apr 08, 2014 5:06 pm

script not starting

Sun Dec 18, 2016 4:03 pm

Hello,
when a run below script "start" from comand line it works, but when Input 0 changes from 1 to 0 or 0 to 1 it is not working.
in /etc/rc.local I put /usr/bin/python /bin/start &
If I put

Code: Select all

while(True):  
    sleep(0.1)
    listener=..................................
myscript is executed allways. Why is it not reacting just once when the rising/falling edge it triggered??

What could be the problem??
regads
gwaag

Code: Select all

#!/usr/bin/python

import time
import subprocess
from subprocess import Popen
import pifacedigitalio
from time import sleep
pfd = pifacedigitalio.PiFaceDigital()  # creates a PiFace Digital object


listener = pifacedigitalio.InputEventListener(chip=pfd)
listener.register(0, pifacedigitalio.IODIR_RISING_EDGE,  subprocess.Popen(["/bin/myscript"]))  
listener.register(0, pifacedigitalio.IODIR_FALLING_EDGE,  subprocess.Popen(["/bin/myscript"]))
listener.activate()
#  listener(0 is input 0

klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

Re: script not starting

Tue Dec 20, 2016 6:38 pm

Hello,
What version of Jessie?
but when Input 0 changes from 1 to 0 or 0 to 1 it is not working.
in /etc/rc.local I put /usr/bin/python /bin/start

May not work as well in the rc.local.
Try http://www.raspberrypi-spy.co.uk/2015/1 ... g-systemd/
that is what I have found any way.
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

gwaag
Posts: 89
Joined: Tue Apr 08, 2014 5:06 pm

Re: script not starting

Wed Dec 21, 2016 3:58 pm

changed the script as below, now working ok.

Code: Select all

#!/usr/bin/python

import time
from time import sleep
import subprocess
from subprocess import Popen
import pifacedigitalio
pfd = pifacedigitalio.PiFaceDigital()  # creates a PiFace Digital object

while(True):
    sleep(0.1)

def mycallback(event):                 
    subprocess.Popen(["/bin/aus"])

listener = pifacedigitalio.InputEventListener(chip=pfd)
listener.register(0, pifacedigitalio.IODIR_BOTH,  mycallback)
listener.activate()

Return to “Python”