3

I have a Beaglebone Black running Debian and I need a script running in background, which would check every few seconds if the system is still running. As far as I understand, watchdog in BBB is hardware-based and runs independently from OS, so it can reboot the device even if OS is completely frozen (right?). Here is a very simple example from logicsupply:

#!/usr/bin/env python

import time
import os

os.nice(20)
time.sleep(60)                  # Wait before starting
wd = open("/dev/watchdog", "w+")
while 1:
     wd.write("\n")
     wd.flush()
     time.sleep(5)

But I can't find a way to change default timeout. In C it would look like:

ioctl(fd, WDIOC_SETTIMEOUT, &timeout);

But calling ioctl functions in Python seems to be rather obscure. From this discussion it seems like C macro definitions may have different values depending on hardware. Is there a convenient way to address them (at least, this particular one, to change default watchdog timeout) in Python? And what is the best way to run the script in background so that it could reboot the system with a frozen OS?

Community
  • 1
  • 1
  • Can you not do this from the watchdog conf or use the pid? Do you actually want to reboot if the script fails? – Padraic Cunningham Apr 20 '15 at 14:32
  • @PadraicCunningham BBB will be used as a controller in a mobile robot. If there is a problem with OS or control software (crash/freeze), we need to restore control as soon as possible. That's why I would like to go as low-level as possible. – Kelly Roadkill Apr 20 '15 at 18:34
  • I am not overly familiar with watchdog but looking at the manpage, I thought setting the interval woud work http://linux.die.net/man/5/watchdog.conf – Padraic Cunningham Apr 20 '15 at 19:39
  • @PadraicCunningham it works, thanks! I've abandoned the idea of making it through ioctl, instead changing .conf file. – Kelly Roadkill May 02 '15 at 15:33

1 Answers1

1

This comment by Padraic Cunningham has directed me to the manpage for watchdog.conf which is the right and working way to configure the hardware WDT on AM335x, so there's no need for additional scripts/daemons:

watchdog-timeout = 10