Python machine.reset_cause() Examples
The following are 3
code examples of machine.reset_cause().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
machine
, or try the search function
.
Example #1
Source File: pycom.py From terkin-datalogger with GNU Affero General Public License v3.0 | 6 votes |
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
Example #2
Source File: compat.py From terkin-datalogger with GNU Affero General Public License v3.0 | 5 votes |
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
Example #3
Source File: wifi.py From terkin-datalogger with GNU Affero General Public License v3.0 | 5 votes |
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)