当前位置: 首页>>代码示例>>Python>>正文


Python machine.WDT属性代码示例

本文整理汇总了Python中machine.WDT属性的典型用法代码示例。如果您正苦于以下问题:Python machine.WDT属性的具体用法?Python machine.WDT怎么用?Python machine.WDT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在machine的用法示例。


在下文中一共展示了machine.WDT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def start(self):
        """ 
        Start the watchdog.
        """
        if not self.enabled:
            log.info('Skipping watchdog timer (WDT)')
            return

        watchdog_timeout = self.timeout
        log.info('Starting the watchdog timer (WDT) with timeout {}ms'.format(watchdog_timeout))

        from machine import WDT
        self.wdt = WDT(timeout=watchdog_timeout)

        # Feed Watchdog once.
        self.feed() 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:18,代码来源:watchdog.py

示例2: close

# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def close(self):
        self._close()  # Close socket and WDT
        self._feed(WDT_CANCEL)

    # **** For subclassing ****

    # May be overridden e.g. to provide timeout (asyncio.wait_for) 
开发者ID:peterhinch,项目名称:micropython-iot,代码行数:9,代码来源:client.py

示例3: reset

# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def reset(led):
    import machine

    wdt = machine.WDT()
    wdt.feed()
    led(0)
    machine.reset() 
开发者ID:microhomie,项目名称:microhomie,代码行数:9,代码来源:main.py

示例4: reset

# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def reset(led):
    import machine
    wdt = machine.WDT()
    wdt.feed()
    while True:
        led(not led())
        sleep_ms(250) 
开发者ID:microhomie,项目名称:microhomie,代码行数:9,代码来源:main.py

示例5: wdt

# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def wdt(self):
        from machine import WDT

        wdt = WDT()
        while True:
            wdt.feed()
            await sleep_ms(WDT_DELAY) 
开发者ID:microhomie,项目名称:microhomie,代码行数:9,代码来源:device.py

示例6: reconfigure_watchdog

# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def reconfigure_watchdog(self, timeout_seconds=600):
        """

        :param timeout_seconds:  (Default value = 600)

        """
        try:
            from machine import WDT
            watchdog_timeout = timeout_seconds
            watchdog_timeout_effective = watchdog_timeout * 1000
            wdt = WDT(timeout=watchdog_timeout_effective)
            wdt.init(watchdog_timeout_effective)
            print('INFO:  Reconfigured watchdog to {} seconds'.format(watchdog_timeout))
        except:
            pass 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:17,代码来源:mininet.py

示例7: connection_handler

# 需要导入模块: import machine [as 别名]
# 或者: from machine import WDT [as 别名]
def connection_handler(self, client):
        """subscribe to all registered device and node topics"""
        if self._first_start is False:
            await self.publish(DEVICE_STATE, STATE_RECOVER)

        retained = []
        subscribe = self.subscribe

        # Broadcast topic
        await self.mqtt.subscribe("{}/{}/#".format(self.btopic, T_BC), QOS)

        # Micropython extension
        await self.mqtt.subscribe("{}/{}".format(self.dtopic, T_MPY), QOS)

        # node topics
        nodes = self.nodes
        for n in nodes:
            props = n._properties
            for pid, p in props.items():
                if p.restore:
                    # Restore from topic with retained message
                    await self.add_node_cb(n)
                    t = "{}/{}".format(n.id, pid)
                    await subscribe(t)
                    retained.append(t)

                if p.settable:
                    await self.add_node_cb(n)
                    await subscribe("{}/{}/set".format(n.id, pid))

        # on first connection:
        # * publish device and node properties
        # * enable WDT
        # * run all coros
        if self._first_start is True:
            await self.publish_properties()

            unsubscribe = self.unsubscribe
            # unsubscribe from retained topics
            for t in retained:
                await unsubscribe(t)

            self._first_start = False

            # activate WDT
            if LINUX is False and self.debug is False:
                launch(self.wdt, ())

            # start coros waiting for ready state
            _EVENT.set()
            await sleep_ms(MAIN_DELAY)
            _EVENT.clear()

        await self.publish(DEVICE_STATE, STATE_READY) 
开发者ID:microhomie,项目名称:microhomie,代码行数:56,代码来源:device.py


注:本文中的machine.WDT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。