module:micropython:esp32checkthreading
                Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| module:micropython:esp32checkthreading [2021/12/08 11:21] – created omdevelop | module:micropython:esp32checkthreading [2022/09/13 11:58] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======  | + | ======  | 
| [[http:// | [[http:// | ||
| [ | [ | ||
| Line 8: | Line 8: | ||
| ] | ] | ||
| - | Esp32CheckMath | Esp32CheckMath]] | + | |
| - |   * [[:Module:MicroPython: | + | |
| - | * [[:Module:MicroPython:Esp32CheckThreading | Esp32CheckThreading]] | + | |
| + | |||
| + | |||
| + | |||
| + | |||
| + | ===== Benutzung ===== | ||
| + | Beispiel für die Einbindung der MicroPython-Library **Thread.py** : | ||
| + | <code python> | ||
| + | # | ||
| + | import _thread | ||
| + | # | ||
| + | class CThread(): | ||
| + | # | ||
| + |   def __init__(self, | ||
| + | self.ID = threadid | ||
| + | self.OnExecute = onexecute | ||
| + | self.IsBusy = False | ||
| + | return | ||
| + | # | ||
| + |   def Start(self): | ||
| + | self.IsBusy = True | ||
| + |     _thread.start_new_thread(self.OnExecute, | ||
| + | return | ||
| + |    | ||
| + |   def Abort(self): | ||
| + | self.IsBusy = False | ||
| + | return | ||
| + | # | ||
| + | </ | ||
| + | Wichtig: Die Library  | ||
| + | |||
| + | Aufrufendes Programm **Esp32CheckThreading.py** : | ||
| + | <code python> | ||
| + | # | ||
| + | import time | ||
| + | # | ||
| + | import Thread | ||
| + | # | ||
| + | # | ||
| + | def CBOnExecute(thread): | ||
| + |   print(' | ||
| + | I = 0 | ||
| + | while (thread.IsBusy): | ||
| + | I += 1 | ||
| + |     print(" | ||
| + | time.sleep(1) | ||
| + |   print(' | ||
| + | # | ||
| + | # | ||
| + | if (' | ||
| + |    | ||
| + |   T = Thread.CThread(' | ||
| + | T.Start() | ||
| + | time.sleep(5) | ||
| + | T.Abort() | ||
| + | time.sleep(5) | ||
| + |   print(' | ||
| + | # | ||
| + | </ | ||
| + | |||
| + | Run-Ausgabe im Terminal: | ||
| + | < | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | CBOnExecute[T1]: begin | ||
| + | CBOnExecute[T1]: Hello(1)! | ||
| + | CBOnExecute[T1]: Hello(2)! | ||
| + | CBOnExecute[T1]: Hello(3)! | ||
| + | CBOnExecute[T1]: Hello(4)! | ||
| + | CBOnExecute[T1]: Hello(5)! | ||
| + | CBOnExecute[T1]: | ||
| + | *** Esp32CheckThreading: | ||
| + | ♦♦> | ||
| + | MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32 | ||
| + | Type " | ||
| + | >>> | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Version ===== | ||
| + | |||
| + | {{: | ||
| ----- | ----- | ||
module/micropython/esp32checkthreading.1638958896.txt.gz · Last modified: 2021/12/08 12:21 (external edit)