本文整理匯總了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
示例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
示例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)