Quellcode durchsuchen

v3.1.6 - bug fix: issue 97

Anatoli Arkhipenko vor 5 Jahren
Ursprung
Commit
86b9270e35
5 geänderte Dateien mit 13 neuen und 100 gelöschten Zeilen
  1. 0 95
      README
  2. 1 1
      README.md
  3. 1 1
      library.json
  4. 1 1
      library.properties
  5. 10 2
      src/TaskScheduler.h

+ 0 - 95
README

@@ -1,95 +0,0 @@
-Task Scheduler – cooperative multitasking for Arduino, ESPx, STM32 and other microcontrollers
-Version 3.1.5 2020-05-08
-
-If you find TaskScheduler useful for your Arduino project, please drop me an email: arkhipenko@hotmail.com
-----------------------------------------------------------------------------------------------------------
-
-OVERVIEW:
- A lightweight implementation of cooperative multitasking (task scheduling) supporting:
- 1. Periodic task execution (with dynamic execution period in milliseconds or microseconds)
- 2. Number of iterations (n times)
- 3. Execution of tasks in predefined sequence
- 4. Dynamic change of task execution parameters (frequency, number of iterations, callback function)
- 5. Power saving via entering IDLE sleep mode between tasks are scheduled to run
- 6. Task invocation via Status Request object
- 7. Task IDs and Control Points for error handling and watchdog timer
- 8. Local Task Storage pointer (allowing use of same callback code for multiple tasks)
- 9. Layered task prioritization
-10. Support for std::functions (tested on ESPx only)
-11. Overall task timeout
-12. Static and dynamic callback method binding
-13. CPU load / idle statistics for time critical applications
-
-Scheduling overhead: between 15 and 18 microseconds per scheduling pass (check the benchmark example).
-
-Tested on the following microcontrollers:
- - Arduino Uno R3
- - Arduino Nano
- - Arduino Micro
- - ATtiny85
- - ESP8266 (Node MCU v2.0)
- - ESP32
- - Teensy (tested on Teensy 3.5)
- - STM32F1 (tested on Mini USB STM32F103RCBT6 ARM Cortex-M3 leaflabs Leaf maple mini module F)
- - MSP430 and MSP432 boards
-
-For detailed functionality overview please refer to TaskScheduler Wiki page: 
-            https://github.com/arkhipenko/TaskScheduler/wiki
-============================================================================
-
-Check out what TaskScheduler can do:
-====================================
-  Endeavor - build a space capable craft, with the ability to maneuver both in and out of atmosphere.
-    (by Radical Space Technologies
-     http://radicalspacetechnologies.com/2015/10/01/endeavor-phase-i/
-
-         "So after some digging I found TaskScheduler an awesome little library developed by Anatoli Arkhipenko,
-          his github is here and the documentation is here. Its fantastic, so far I’ve been able to replicate
-          some things I’ve seen in Ardupilot. ..."
-  link: http://radicalspacetechnologies.com/2015/10/25/endeavors-code-definitely-progress/
-
-
-  3 Devo - Quality 3D printing filament, now made accessible and affordable
-     http://3devo.eu/   (http://3devo.eu/license-information/)
-
-
-  Houston midi clock project - TaskScheduler with microseconds resolution
-    (by chaffneue: My first arduino project. It's a multi-master midi controller with a shared clock and
-     auto count in behaviour. Project files on github: https://github.com/chaffneue/houston
-	 youtube: https://www.youtube.com/watch?v=QRof550TtXo)
-
-
-  Hackabot Nano -  Compact Plug and Play Arduino compatible robotic kit
-    (by Funnyvale: http://hackarobot.com/
-     also: https://www.kickstarter.com/projects/hackarobot/hackabot-nano-compact-plug-and-play-arduino-robot)
-
-
-  Arduino Nano based Hexbug Scarab Robotic Spider
-    (by arkhipenko: http://www.instructables.com/id/Arduino-Nano-based-Hexbug-Scarab-Robotic-Spider/)
-
-
-  Wave your hand to control OWI Robotic Arm... no strings attached
-    (by arkhipenko: http://www.instructables.com/id/Wave-your-hand-to-control-OWI-Robotic-Arm-no-strin/)
-
-
-  APIS - Automated Plant Irrigation System
-    (by arkhipenko: http://www.instructables.com/id/APIS-Automated-Plant-Irrigation-System/)
-
-
-  IoT APIS v2 - Autonomous IoT-enabled Automated Plant Irrigation System
-    (by arkhipenko: http://www.instructables.com/id/IoT-APIS-V2-Autonomous-IoT-enabled-Automated-Plant/)
-
-
-  Interactive Halloween Pumpkin
-    (by arkhipenko: http://www.instructables.com/id/Interactive-Halloween-Pumpkin/)
-
-
-  Interactive Predator Costume with Real-Time Head Tracking Plasma Cannon
-    (by arkhipenko: https://www.instructables.com/id/Interactive-Predator-Costume-With-Head-Tracking-Pl/)
-
-
-  Party Lights LEDs music visualization
-    (by arkhipenko: https://www.instructables.com/id/Portable-Party-Lights/)
-
-Changelog is located here: https://github.com/arkhipenko/TaskScheduler/wiki/Changelog
-=====================================================================================

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # Task Scheduler
 ### Cooperative multitasking for Arduino, ESPx, STM32 and other microcontrollers
-#### Version 3.1.5: 2020-05-08 [Latest updates](https://github.com/arkhipenko/TaskScheduler/wiki/Latest-Updates)
+#### Version 3.1.6: 2020-05-12 [Latest updates](https://github.com/arkhipenko/TaskScheduler/wiki/Latest-Updates)
 
 [![arduino-library-badge](https://www.ardu-badge.com/badge/TaskScheduler.svg?)](https://www.ardu-badge.com/TaskScheduler)
 

+ 1 - 1
library.json

@@ -16,7 +16,7 @@
       "maintainer": true
     }
   ],
-  "version": "3.1.5",
+  "version": "3.1.6",
   "frameworks": "arduino",
   "platforms": "*"
 }

+ 1 - 1
library.properties

@@ -1,5 +1,5 @@
 name=TaskScheduler
-version=3.1.5
+version=3.1.6
 author=Anatoli Arkhipenko <arkhipenko@hotmail.com>
 maintainer=Anatoli Arkhipenko <arkhipenko@hotmail.com>
 sentence=Cooperative multitasking for Arduino, ESPx, STM32 and other microcontrollers.

+ 10 - 2
src/TaskScheduler.h

@@ -170,6 +170,9 @@
 //
 // v3.1.5:
 //    2020-05-08 - feature: implemented light sleep for esp32
+//
+// v3.1.6:
+//    2020-05-12 - bug fix: deleteTask and addTask should check task ownership first (Issue #97)
 
 
 #include <Arduino.h>
@@ -721,8 +724,9 @@ void Scheduler::init() {
  */
  void Scheduler::addTask(Task& aTask) {
 
-// Avoid adding task twice to the same scheduler
-    if (aTask.iScheduler == this)
+// If task already belongs to a scheduler, we should not be adding
+// it to this scheduler. It should be deleted from the other scheduler first. 
+    if (aTask.iScheduler != NULL)
         return;
 
     aTask.iScheduler = this;
@@ -745,6 +749,10 @@ void Scheduler::init() {
  * @param &aTask - reference to the task to be deleted from the chain
  */
 void Scheduler::deleteTask(Task& aTask) {
+// Can only delete own tasks
+    if (aTask.iScheduler != this) 
+        return;
+    
     aTask.iScheduler = NULL;
     if (aTask.iPrev == NULL) {
         if (aTask.iNext == NULL) {