M_Cremer
Posts: 2
Joined: Wed Jan 03, 2018 3:24 am

Set the BCM2835_wdt to check if python script is running.

Wed Jan 03, 2018 4:07 am

Hi,

I'm not an advanced user but I guess the wachtdog is more for advanced users so here my Q.

I have a script that logs every 30 secs if 3 things are running or not and thats working nice.
but some time it hangs I dont know why but a simple restart is ok.

some hints to improve the IF...ELSE are also appreciated

the code is for a Buderus Diesel heater I want to know how manny diesel it consumes
i need that for mij DIY thermostat

Code: Select all

print("load..") #just for debug remove later
import logging
import RPi.GPIO as GPIO
import datetime
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)      # set up BCM GPIO numbering
GPIO.setup(14, GPIO.IN)     # burner
GPIO.setup(15, GPIO.IN)     # pump heater
GPIO.setup(16, GPIO.IN)     # pump boiler
GPIO.setup(27, GPIO.OUT)    # led....data written
x=1
logging.basicConfig(filename='buderus3.log',level=logging.DEBUG,format='%(message)s')
print ("start..") #just for debug remove later
while x == 1:
    date= (datetime.datetime.now().strftime("%d-%m-%Y"))
    time = (datetime.datetime.now().strftime("%H:%M:%S"))
    GPIO.output(27, True) # led....write data
 
    if GPIO.input(16):
        boiler = 1
    else: boiler = 0

    if GPIO.input(15):
      warm = 1
    else:
      warm = 0
 
    if GPIO.input(14):
      brander = 1
    else:
      brander = 0
    print('geschreven in buderus3.log',datum,tijd,boiler,warm,brander)
    logging.info('{},{},{},{},{}'.format(datum,tijd,boiler,warm,brander))
    sleep(1) # to see te led on for a second.
    GPIO.output(27, False) # led....data writen
    sleep(3)
 
If i (re)start the rasp it will run this script automaticly and when the rasp hangs it also restart and runs the script but when the script hangs it just hangs

my idea was as they say "feed the dog" in the while loop so if it hangs it reboots

I saw a discription for the BCM2708_wdog but that not working.
there are a whole lot of "how to" I saw only 1 where the dog was fed in the python script.

so any help would be nice.

User avatar
thagrol
Posts: 931
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Set the BCM2835_wdt to check if python script is running.

Wed Jan 03, 2018 1:58 pm

You could try using the linux software watchdog instead? https://linux.die.net/man/8/watchdog
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

sparkie777
Posts: 118
Joined: Tue Nov 27, 2012 4:37 am

Re: Set the BCM2835_wdt to check if python script is running.

Wed Jan 03, 2018 2:04 pm

basically you just need to start writing to device file '/dev/watchdog' and continue writing within less than 15s (watchdog timeout is 15s). No configuration, no additional package needed.

that's what I do

M_Cremer
Posts: 2
Joined: Wed Jan 03, 2018 3:24 am

Re: Set the BCM2835_wdt to check if python script is running.

Thu Jan 04, 2018 5:57 pm

thnx for the answers

I follow the thread of paulv to and tried it all without any luck. I guess to much diferences in debian stretch

I'll like youre style Sparky777. how do you mean by "writing to device file '/dev/watchdog'"
is it a command like echo 1 >......or maybe a poem...hihi. Can you give me an example

grrtz

sparkie777
Posts: 118
Joined: Tue Nov 27, 2012 4:37 am

Re: Set the BCM2835_wdt to check if python script is running.

Thu Jan 04, 2018 6:38 pm

M_Cremer wrote:
Thu Jan 04, 2018 5:57 pm
Can you give me an example
poems are not supported yet:-)

an example is already linked above. I repeat: that's what I do

Return to “Advanced users”