module:python:checkthread:checkthread
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
module:python:checkthread:checkthread [2021/12/09 20:46] – [Benutzung] omdevelop | module:python:checkthread:checkthread [2022/09/13 11:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 49: | Line 49: | ||
return | return | ||
</ | </ | ||
- | Wichtig: Die Library **Thread.py** muss im FileSystem des MicroControllers vorhanden sein! | ||
- | Aufrufendes Programm **Esp32CheckThreading.py** : | + | |
+ | Aufrufendes Programm **CheckThread.py** : | ||
<code python> | <code python> | ||
# | # | ||
import time | import time | ||
# | # | ||
- | import Thread | + | import Thread |
# | # | ||
- | # | + | def CBOnStart(thread): |
- | def CBOnExecute(thread): | + | print(' |
- | print(' | + | |
- | I = 0 | + | |
- | while (thread.IsBusy): | + | |
- | | + | |
- | print(" | + | |
- | time.sleep(1) | + | |
- | print(' | + | |
# | # | ||
- | # | + | def CBOnBusy(thread): |
+ | print(' | ||
+ | while (THR.EStateThread.stBusy == thread.State): | ||
+ | print(' | ||
+ | time.sleep(1.0) | ||
+ | return | ||
+ | # | ||
+ | def CBOnAbort(thread): | ||
+ | print(' | ||
+ | return | ||
+ | # | ||
+ | def CBOnEnd(thread): | ||
+ | print(' | ||
+ | return | ||
+ | # | ||
+ | # | ||
if (' | if (' | ||
- | | + | |
- | T = Thread.CThread(' | + | # |
- | T.Start() | + | |
- | time.sleep(5) | + | |
- | T.Abort() | + | time.sleep(5.0) |
- | | + | |
- | print(' | + | # |
+ | print(' | ||
+ | # | ||
# | # | ||
</ | </ | ||
Line 82: | Line 93: | ||
Run-Ausgabe im Terminal: | Run-Ausgabe im Terminal: | ||
< | < | ||
- | >>> | + | In [19]: runfile(' |
- | >>> | + | Reloaded modules: Thread |
- | >>> | + | *** CheckThread: begin |
- | CBOnExecute[T1]: | + | CBOnStart |
- | CBOnExecute[T1]: Hello(1)! | + | CBOnBusy: 0 |
- | CBOnExecute[T1]: | + | CBOnBusy... |
- | CBOnExecute[T1]: | + | CBOnBusy... |
- | CBOnExecute[T1]: | + | CBOnBusy... |
- | CBOnExecute[T1]: | + | CBOnBusy... |
- | CBOnExecute[T1]: | + | CBOnBusy... |
- | *** Esp32CheckThreading: end | + | CBOnAbort |
- | ♦♦> | + | *** CheckThread: end |
- | MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32 | + | CBOnEnd |
- | Type " | + | |
- | >>> | + | |
</ | </ | ||
Line 103: | Line 113: | ||
===== Version ===== | ===== Version ===== | ||
- | {{:module:micropython:2112081352_Esp32CheckThreading_01V01.zip | 2112081352_Esp32CheckThreading_01V01.zip}} | + | {{:module:python:CheckThread: |
module/python/checkthread/checkthread.1639079204.txt.gz · Last modified: 2021/12/09 21:46 (external edit)