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


Python machine.reset_cause方法代码示例

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


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

示例1: humanize

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset_cause [as 别名]
def humanize(self):
        """
        Yield dictionary containing reset cause and wakeup reason
        suitable for human consumption through an appropriate log message.
        """

        platform_info = get_platform_info()

        reset_cause_magic = machine.reset_cause()
        if platform_info.vendor == platform_info.MICROPYTHON.Pycom:
            wakeup_reason_magic, _ = machine.wake_reason()
        else:
            wakeup_reason_magic = machine.wake_reason()

        log.debug('Reset cause: %s', reset_cause_magic)
        log.debug('Wakeup reason: %s', wakeup_reason_magic)

        reset_cause_label = self.reset_causes.get(reset_cause_magic, 'UNKNOWN')
        wakeup_reason_label = self.wakeup_reasons.get(wakeup_reason_magic, 'UNKNOWN')
        status = {
            'reset_cause': {'code': reset_cause_magic, 'message': reset_cause_label},
            'wakeup_reason': {'code': wakeup_reason_magic, 'message': wakeup_reason_label},
        }
        return status 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:26,代码来源:pycom.py

示例2: monkeypatch_machine

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

    from mock import Mock

    import uuid
    import machine

    # Some primitives.
    machine.enable_irq = Mock()
    machine.disable_irq = Mock()
    machine.unique_id = lambda: str(uuid.uuid4().fields[-1])[:5].encode()
    machine.freq = Mock(return_value=42000000)
    machine.idle = Mock()

    # Reset cause and wake reason.
    machine.PWRON_RESET = 0
    machine.HARD_RESET = 1
    machine.WDT_RESET = 2
    machine.DEEPSLEEP_RESET = 3
    machine.SOFT_RESET = 4
    machine.BROWN_OUT_RESET = 5

    machine.PWRON_WAKE = 0
    machine.GPIO_WAKE = 1
    machine.RTC_WAKE = 2
    machine.ULP_WAKE = 3

    machine.reset_cause = Mock(return_value=0)
    machine.wake_reason = wake_reason 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:31,代码来源:compat.py

示例3: start_interface

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset_cause [as 别名]
def start_interface(self):
        """
        Genuine MicroPython:
        https://docs.micropython.org/en/latest/library/network.WLAN.html
        
        Pycom MicroPython:
        https://docs.pycom.io/tutorials/all/wlan.html
        https://github.com/pycom/pydocs/blob/master/firmwareapi/pycom/network/wlan.md
        """

        if self.platform_info.vendor == self.platform_info.MICROPYTHON.Pycom:
            self.station = network.WLAN()
        else:
            log.info('WiFi STA: Will exclusively use STA mode on this platform. AP mode not implemented yet.')
            self.station = network.WLAN(network.STA_IF)

        #if machine.reset_cause() == machine.SOFT_RESET:
        #   print("WiFi STA: Network connection after SOFT_RESET.")
        #    self.print_short_status()
        #    # Inform about networking status.
        #    self.print_address_status()
        #    return True

        # Save the default ssid and auth for restoring AP mode later
        #original_ssid = self.station.ssid()
        #original_auth = self.station.auth()

        # Inform about networking status.
        self.print_address_status()

        # Setup network interface.
        log.info("WiFi: Starting interface")

        if self.platform_info.vendor == self.platform_info.MICROPYTHON.Pycom:
            self.configure_antenna()

            # FIXME: Make STA or AP or STA_AP configurable.
            self.station.mode(network.WLAN.STA_AP)

            # Initialize the WiFi peripheral.
            self.station.init()

        else:
            self.station.active(True) 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:46,代码来源:wifi.py


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