Skip to content

mock_machine Module

register_as_machine()

This will register mock_machine as machine so it can be imported by other modules expecting import machine to work.

Source code in mock_machine.py
def register_as_machine():
    """
    This will register mock_machine as machine so it can be imported by other
    modules expecting `import machine` to work.
    """
    import sys

    log.warning("All imports of machine are mocked from here on")
    sys.modules["machine"] = sys.modules["mock_machine"]

reset_cause()

https://docs.micropython.org/en/latest/library/machine.html#machine.reset_cause

Source code in mock_machine.py
def reset_cause():
    """
    https://docs.micropython.org/en/latest/library/machine.html#machine.reset_cause
    """
    return __reset_cause__

Constants

Reset Causes

  • SOFT_RESET = 0
  • PWRON_RESET = 1
  • HARD_RESET = 2
  • WDT_RESET = 3
  • DEEPSLEEP_RESET = 4

Memory Access

mem8 = Memory(255) module-attribute

mem16 = Memory(65535) module-attribute

mem32 = Memory(4294967295) module-attribute