Différences entre versions de « Mydin-advanced-usage »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
Ligne 29 : Ligne 29 :
 
== Exception handling ==
 
== Exception handling ==
  
An exception occuring in the ''userloop'' task will be captured and will ends the  
+
'''An exception occuring in the ''userloop'' task''' will be captured and will ends the code execution.
 +
 
 +
'''Exception occuring in other tasks''' will be only be reported into REPL.
  
 
== Activating watchdog ==
 
== Activating watchdog ==
  
 
== Add Scheduler Task ==
 
== Add Scheduler Task ==

Version du 29 avril 2025 à 16:43

Abstract

Before going into the details of the various controlers and backplanes, it may be opportune to learn some advanced behaviors of the MyDin asyncio implementation.

RUN_APP

RUN_APP pin is used to stop the MyDin software stack (or script execution after a reboot).

It is a convenient way to recover the control on the module when script goes wrong. It would also offer the full access to REPL.

When setting the RUN_APP pin to the "Stop" position (so tied to ground) while the MyDin software is already running, the code may takes up to 3 seconds to terminates.

It is also a good practice to check the RUN_APP pin in the boot.py startup file. This may allows debugging operations when Network operation goes wrong!

from machine import Pin
# Use the RUN_APP pin as defined on your controler board!
RUN_APP = Pin.board.GP3  # High=Run, Low=Stop

if Pin( RUN_APP, Pin.IN, Pin.PULL_UP ).value()==False:
  print( '[BOOT] skip execution (RUN_APP is false)' )
else:
  print( '[BOOT] entering...' )
  # >>> PLACE BOOT CODE HERE <<<
  print( '[BOOT] exit' )

Exception handling

An exception occuring in the userloop task will be captured and will ends the code execution.

Exception occuring in other tasks will be only be reported into REPL.

Activating watchdog

Add Scheduler Task