User Tools

Site Tools


module:python:checkthread:checkthread

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
module:python:checkthread:checkthread [2021/12/09 20:46] – [Benutzung] omdevelopmodule:python:checkthread:checkthread [2022/09/13 11:58] (current) – external edit 127.0.0.1
Line 49: Line 49:
         return         return
 </code> </code>
-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 as THR
 # #
-#----------------------------------------- +def CBOnStart(thread): 
-def CBOnExecute(thread): +    print('CBOnStart') 
-  print('CBOnExecute[{}]: begin'.format(thread.ID)) +    return
-  I = 0 +
-  while (thread.IsBusy): +
-    I += 1 +
-    print("CBOnExecute[{}]: Hello({})!".format(thread.ID, I)) +
-    time.sleep(1) +
-  print('CBOnExecute[{}]: end'.format(thread.ID))+
 # #
-#-----------------------------------------+def CBOnBusy(thread): 
 +    print('CBOnBusy: 0') 
 +    while (THR.EStateThread.stBusy == thread.State): 
 +        print('CBOnBusy...'
 +        time.sleep(1.0) 
 +    return 
 +# 
 +def CBOnAbort(thread): 
 +    print('CBOnAbort'
 +    return 
 +
 +def CBOnEnd(thread): 
 +    print('CBOnEnd'
 +    return 
 +
 +#-----------------------------------------------------------
 if ('__main__' == __name__): if ('__main__' == __name__):
-  print('*** Esp32CheckThreading: begin'+    print('*** CheckThread: begin'
-  T = Thread.CThread('T1'CBOnExecute+    # 
-  T.Start() +    Thread = THR.CThread(CBOnStart, CBOnBusy, CBOnAbortCBOnEnd
-  time.sleep(5) +    Thread.Start() 
-  T.Abort() +    time.sleep(5.0
-  time.sleep(5) +    Thread.Abort() 
-  print('*** Esp32CheckThreading: end')+    # 
 +    print('*** CheckThread: end') 
 +    #
 # #
 </code> </code>
Line 82: Line 93:
 Run-Ausgabe im Terminal: Run-Ausgabe im Terminal:
 <code> <code>
->>> Running ..\Esp32Threading.py +In [19]: runfile('C:/Downloads/python/CheckThread.py', wdir='C:/Downloads/python') 
->>> +Reloaded modules: Thread 
->>> *** Esp32CheckThreading: begin +*** CheckThread: begin 
-CBOnExecute[T1]: begin +CBOnStart 
-CBOnExecute[T1]Hello(1)! +CBOnBusy0 
-CBOnExecute[T1]: Hello(2)! +CBOnBusy... 
-CBOnExecute[T1]: Hello(3)! +CBOnBusy... 
-CBOnExecute[T1]: Hello(4)! +CBOnBusy... 
-CBOnExecute[T1]: Hello(5)! +CBOnBusy... 
-CBOnExecute[T1]: end +CBOnBusy... 
-*** Esp32CheckThreading: end +CBOnAbort 
-♦♦> +*** CheckThread: end 
-MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32 +CBOnEnd 
-Type "help()" for more information. +
->>>+
 </code> </code>
  
Line 103: Line 113:
 ===== Version ===== ===== Version =====
  
-{{:module:micropython:2112081352_Esp32CheckThreading_01V01.zip | 2112081352_Esp32CheckThreading_01V01.zip}}+{{:module:python:CheckThread:2112092053_CheckThread_01V01.zip | 2112092053_CheckThread_01V01.zip}}
  
  
module/python/checkthread/checkthread.1639079204.txt.gz · Last modified: 2021/12/09 21:46 (external edit)