當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。