Closed sakunamary closed 2 years ago
The code needs to be written as follows to pass ledState between tasks
xTask shortTask = xTaskCreate("SHORT", taskShort_main, &ledState); xTask longTask = xTaskCreate("LONG", taskLong_main, &ledState); xTask OLEDTask = xTaskCreate("OLED", taskOLED_main, &ledState);
Also, you should not use delay() in any task. Instead, use a task timer.
Oh!!!! What a simple mistake I have made ........LOL
DO remember double CHECK all parms which are need to passthrough !!!
Thank you so much ! best wishes! @MannyPeterson
Hi Guys : I am learning how to make a multi-tasks project with HeliOS 0.3.3 ,I make the code as following:
heliOS_learning.zip which is base on HeliOS example "Coop" .I am trying to run 3 tasks in this program 1:blink the LED (base on example "Blink") 2: two task-nobody (just delay(XXX) and print a letter out to serial port
Here is the task function:
void taskShortmain(xTask task, xTaskParm parm_) { int ledState = DEREFTASKPARM(int, parm); Serial.print("led 1 ");Serial.println(ledState); if (ledState) { digitalWrite(LED_BUILTIN, HIGH);
Serial.print("led 2 ");Serial.println(ledState);
} else { digitalWrite(LED_BUILTIN, LOW);
} DEREFTASKPARM(int, parm) = ledState; Serial.print("led 5 ");Serial.println(ledState); return; }
And serial print out :
08:38:03.355 -> L 08:38:03.966 -> M 08:38:03.966 -> led 1 0 timeloop1 in-value =0 ,init value ,OK 08:38:03.966 -> led 4 1 timeloop1 change ledstate ,working good 08:38:03.966 -> led 5 1 08:38:04.342 -> L 08:38:04.953 -> M 08:38:05.375 -> L 08:38:05.375 -> led 1 0 timeloop2 in-value =0?,suppose to be 1 ,working not OK now 08:38:05.375 -> led 4 1 timeloop2
08:38:05.375 -> led 5 1
The var Ledstate do changed in Task "taskShort_main" and pass-thought out to DEREFTASKPARM(int, parm) (LED 1 in-value = 0 , LED4 out-value = 1 ),but in the next task Schedule Led1 read in value still is 0 ,suppose to be LED1 = 1 .
so , I make the same coding in example "Blink" , as following :
Blink-check.zip
And serial print out :
08:46:44.589 -> led 1 0 timeloop1 in-value =0 ,init value ,OK 08:46:44.589 -> led 4 1 timeloop1 change ledstate ,working good 08:46:45.625 -> led 1 1 timeloop2 in-value =1 ,from lastloop led4 out-value ,working good
08:46:45.625 -> led 2 1 timeloop2 08:46:45.625 -> led 3 0 timeloop2 change ledstata, output value . 08:46:46.602 -> led 1 0 08:46:46.602 -> led 4 1 08:46:47.653 -> led 1 1 08:46:47.653 -> led 2 1 08:46:47.653 -> led 3 0
the coding is work....
I have tried Arduino Nano , LGT8F328P Nano , both "blink" program running OK , "Coop+Blink" not OK , I also tried D1 mini ,but seems HeliOS 0.3.3 not working good . I can not locate where is "ARDUINO_ARCH_ESP8266" in HeliOS.h.
I am not sure which parts is not OK now ...... Would you Please help me to check it out !!!! Thanks all guys and best wishes !!!