Welcome to the fascinating world of RTOS!
Presently, rtosSetup() is an extension of the RTOS and hasn't been implemented yet in Energia MT. It's awaiting validation at the GitHub repository. See Main setup() for Energia MT #631.
With Energia, copy-paste rtosGlobals.h into Second.ino, delete rtosGlobals.h, edit Second.ino and add the empty loop rtosLoop() will be called once at the beginning. Add Serial.begin(115200); to rtosSetup(). The Serial port needs to be initialised in each thread.
void rtosSetup()
{
Serial.begin(115200);
myTask.begin(functionTask, Task_numPriorities - 1);
}
void rtosLoop() { ; }
You're sharing one single resource, the Serial port, between two clients. More over, delay(500); and delay(1000); are colliding. Try with delay(600); instead of delay(500);.
Actually, you're losing the interest of the Task element. A simpler solution would be to skip myTask and use Second.ino with standard setup() and loop() functions.
void rtosSetup() {
Serial.begin(9600);
}
void rtosLoop()
{
Serial.println("hello from task");
delay(600);
}
However, the correct solution is to use a semaphore. The semaphore ensures the resource, here the Serial port, is used by only one client at a time. The semaphore grants an exclusive access at the resource to one client only at a time. See the Galaxia_Semaphore library and the associated example.
As a matter of facts, I'm no longer using the Energia IDE but only the Energia framework on Xcode, thanks to the embedXcode plug-in I've developed. If you're a Mac user, give it a try!
I'm exploring TI-RTOS and developing easy-to-use libraries for Energia MT.
The idea is to encapsulate each RTOS element into a class. Up to now, I've implemented the following libraries:
Event library with choice of event number Event_Id_00 ... Event_Id_31
Semaphore library
Mailbox library
Timer library