简体   繁体   English

Python中的Beaglebone Black看门狗

[英]Beaglebone Black watchdog in Python

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. 我有一个运行Debian的Beaglebone Black,并且我需要一个在后台运行的脚本,该脚本每隔几秒钟检查一次系统是否仍在运行。 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?). 据我了解,BBB中的看门狗基于硬件,并且独立于操作系统运行,因此即使操作系统完全冻结,它也可以重新启动设备(对吗?)。 Here is a very simple example from logicsupply : 这是来自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: 在C中,它看起来像:

ioctl(fd, WDIOC_SETTIMEOUT, &timeout);

But calling ioctl functions in Python seems to be rather obscure. 但是在Python中调用ioctl函数似乎不太明显。 From this discussion it seems like C macro definitions may have different values depending on hardware. 这个讨论看来,C宏定义可能取决于硬件而具有不同的值。 Is there a convenient way to address them (at least, this particular one, to change default watchdog timeout) in Python? 在Python中是否有一种方便的方法来解决这些问题(至少是更改默认的看门狗超时这一特定方法)? And what is the best way to run the script in background so that it could reboot the system with a frozen OS? 在后台运行脚本以使其可以使用冻结的OS重新引导系统的最佳方法是什么?

Padraic Cunningham的 评论已将我定向到watchdog.conf联机帮助页,这是在AM335x上配置硬件WDT的正确且可行的方法,因此不需要其他脚本/守护程序:

watchdog-timeout = 10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM