zoukankan      html  css  js  c++  java
  • 看门狗定时器

    在procd中看到的看门狗。(不过从日志上看其实看门狗是没有生效的,从openwrt的配置文件上看看门狗是需要配置的)

    参考资料:https://blog.csdn.net/xiaopohaibebo/article/details/8090916

    procd中相关函数:

     1 void watchdog_init(int preinit)
     2 {
     3     char *env = getenv("WDTFD");
     4 
     5     if (wdt_fd >= 0)
     6         return;
     7 
     8     wdt_timeout.cb = watchdog_timeout_cb;
     9     if (env) {
    10         DEBUG(2, "Watchdog handover: fd=%s
    ", env);
    11         wdt_fd = atoi(env);
    12         unsetenv("WDTFD");
    13     } else {
    14          wdt_fd = open("/dev/watchdog", O_WRONLY);
    15     }
    16 
    17     if (wdt_fd < 0)
    18         return;
    19 
    20     if (!preinit)
    21         fcntl(wdt_fd, F_SETFD, fcntl(wdt_fd, F_GETFD) | FD_CLOEXEC);
    22 
    23     LOG("- watchdog -
    ");
    24     watchdog_timeout(30);/*设置超时时间*/
    25     watchdog_timeout_cb(&wdt_timeout);/*定时喂狗*/
    26 
    27     DEBUG(4, "Opened watchdog with timeout %ds
    ", watchdog_timeout(0));
    28 }
    29 
    30 static void watchdog_timeout_cb(struct uloop_timeout *t)
    31 {
    32     watchdog_ping();/*喂狗*/
    33     uloop_timeout_set(t, wdt_frequency * 1000 );/*重新定时*/
    34 }
    35 
    36 void watchdog_ping(void)
    37 {
    38     DEBUG(4, "Ping
    ");
    39     if (wdt_fd >=0 && write(wdt_fd, "X", 1) < 0)
    40         ERROR("WDT failed to write: %s
    ", strerror(errno));
    41 }
  • 相关阅读:
    js 脚本学习 索引
    nodejs 学习索引
    oracle 学习 笔记
    githut 的 管理 使用
    sublime text 插件记录
    web 学习 相关索引
    wpf 自定义 无边框 窗体 resize 实现
    vs 效率工具
    ANDROID开发实用小工具
    iOS开发之Core Animation
  • 原文地址:https://www.cnblogs.com/laymond/p/10042732.html
Copyright © 2011-2022 走看看