View unanswered posts | View active topics It is currently Fri May 25, 2018 5:24 am






Reply to topic  [ 9 posts ] 
Multitasking on EV3 
Author Message
Rookie

Joined: Thu Sep 25, 2014 8:34 pm
Posts: 22
Post Multitasking on EV3
This problem is similar to the thread started on June 1st with the topic: " ev3 program doesn't run directly from brick "

I have encountered the same problem using the Multitasking Sample Program. I am opening the sample program: Sample Programs > EV3 > Advanced Examples > Multitasking.

The program compiles just fine and downloads to the EV3 without any trouble. I can even run the program from the RobotC development environment on the computer. I press the "Start" button and it works just fine.

However, when I stop the program and try to run the very same program from the EV3 (you know, the one with the small LCD and left/right and up/down buttons) the program just hangs. It does not go any further than the blinking green LED and the message on the LCD that says: "Mindstorms: Multitasking demo".

I can re-start the program from the computer just fine. But for some reason, I am unable to start it from the EV3 brick once it has already been run once.

If the EV3 is connected to the computer via USB cable, there is an error box that appears with the title: RobotC Debugger Exception.
Exception Type: 'Bad integrity of internal task queues(42)'
Error at PC: +0x178B
Task PC: Task: main+0x0000,
TaskState: 'Exception'
[CANCEL]

Multitasking seems to work. But only if you start the program from the PC. There seems to be a problem if you try starting the program from the EV3.

Any ideas?

I forgot to mention one other thing. Once the EV3 hangs from this error, it is impossible to start ANY program that was downloaded to the brick. It will start the Demo program. But I cannot start any other program that I downloaded. The only way I can run a program from the EV3 is to reboot the EV3 itself. Then I can run the program again.


Thu Sep 25, 2014 8:49 pm
Profile
Rookie

Joined: Thu Sep 25, 2014 8:34 pm
Posts: 22
Post Re: Multitasking on EV3
I think I have found a reasonable solution.

To re-cap the original problem: Once you have exited from a program that implemented multitasking (for example, the Sample Multitasking program) you are unable to start any other programs from the EV3 brick. You can start other programs from the RobotC development environment--just not from the EV3 brick.

I found out that if you utilize the function: stopAllTasks(); to terminate the main program, then the program will stop and you can re-start any program from the EV3 brick without having to start them through the RobotC development environment.

If you terminate a multitasking program by using the "back" button on the EV3 (by the lower left corner of the LCD panel), the EV3 system will become corrupted in some way that prevents you from re-starting any other programs.

If you disable the "back" button with the function: setBlockBackButton(true); and then reassign the "left" key to perform the function: "stopAllTasks();" you should be able to have a program that performs multitasking and that also terminates properly enabling you to continue using the EV3 brick.

I would alter the Multitasking demo to include the following change to the mainTask:

task main() {
setBlockBackButton(true);
startTask(TOne); // Start Task TOne.
startTask(TTwo); // Start Task TTwo.

while(true) {
if (getButtonPress(buttonLeft)) stopAllTasks();
wait1Msec(300); // Allow for a short wait, freeing up the CPU for other tasks.
displayCenteredBigTextLine(0, "TASK M"); // Display that Main is running.
}
return;
}


Fri Sep 26, 2014 10:31 am
Profile
Rookie

Joined: Thu Sep 25, 2014 8:34 pm
Posts: 22
Post Re: Multitasking on EV3
I noticed on the version 4.27 Change Log that the Multi-Tasking was fixed as stated: "Task queue was not being initialized for EV3 firmware except when running with Debugger. Caused all multitasking programs started from the On-Brick EV3 GUI to fail."

However, I am still having trouble getting the Multitasking demo program to run as expected. I can download it to the robot and run it just fine from the Development Environment. However, if I stop the program and try to run it again (although this time from the EV3 Brick program list), it will hang with the blinking message: "Mindstorms Multitasking demo" and fails to run any program on the EV3 Brick unless I reboot the brick or start a new program from the Development Environment.

While a temporary solution would be to call stopAllTasks() from the main program when you want to exit the program, the problem is if the user presses the "back" button next to the LCD screen. Once that gets pressed, then the robot hangs and fails to start any other programs (except through the Development Environment).

Is Multitasking fixed in RobotC version 4.27?


Sun Dec 07, 2014 11:47 pm
Profile
Rookie

Joined: Fri Dec 12, 2014 8:55 am
Posts: 7
Post Re: Multitasking on EV3
jkandra wrote:
....... if I stop the program and try to run it again (although this time from the EV3 Brick program list), it fails to run any program on the EV3 Brick unless I reboot the brick or start a new program from the Development Environment.


Hi, yesterday I had the same problem with my first multitasking program.
Moreover, after I started the program by brick, a motor is always ON :-(


Fri Dec 12, 2014 9:30 am
Profile
Rookie

Joined: Fri Dec 12, 2014 8:55 am
Posts: 7
Post Re: Multitasking on EV3
jkandra wrote:
I think I have found a reasonable solution.
I would alter the Multitasking demo to include the following change to the mainTask:

task main() {
setBlockBackButton(true);
startTask(TOne); // Start Task TOne.
startTask(TTwo); // Start Task TTwo.

while(true) {
if (getButtonPress(buttonLeft)) stopAllTasks();
wait1Msec(300); // Allow for a short wait, freeing up the CPU for other tasks.
displayCenteredBigTextLine(0, "TASK M"); // Display that Main is running.
}
return;
}


Hi,

Yesterday I changed my code, and now I can use EXIT button to stop all tasks, so I can use multitasking without problems :-)

// this task watches for exit button to STOP the program
task StopAllTasksWithExitButton()
{
setBlockBackButton(true);
while(true)
{
if (getButtonPress(buttonBack))stopAllTasks();
wait1Msec(100); // Allow for a short wait, freeing up the CPU for other tasks.
}
}

// This is the MAIN TASK ^^^^^^^^
task main()
{
.............
startTask (StopAllTasksWithExitButton);
.............
repeat(forever){}
}


Mon Dec 15, 2014 4:31 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Multitasking on EV3
Could you see if you can recreate this with 4.28? You can download it here: http://downloads.robotc.net/lego/ROBOTC ... 28Beta.exe

= Xader

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Dec 24, 2014 11:32 am
Profile WWW
Rookie

Joined: Fri Dec 12, 2014 8:55 am
Posts: 7
Post Re: Multitasking on EV3
Hi,

with the new version 4.28 multitask problems are the same :-(

HAPPY NEW YEAR


Sun Dec 28, 2014 11:37 am
Profile
Rookie

Joined: Thu Sep 25, 2014 8:34 pm
Posts: 22
Post Re: Multitasking on EV3
I have downloaded RobotC version 4.30. I have the same problem with the Sample multitasking program. I am using an EV3 with an EV3 touch sensor. To get to the sample multitasking program I go to: File -> Sample Programs -> EV3 -> Advanced Examples -> Multitasking

I changed the Touch Sensor to an EV3 Touch Sensor through the Motors and Sensors Setup dialog.
Then I just run the program which runs just fine from the RobotC development environment.

When I press the Back button (on the EV3 brick) to stop the program, I am unable to restart it through the EV3's menu system. It just hangs on the flash screen: Mindstorms ----- Multitasking Demo. (with a blinking green light). I can't do anything with the EV3 brick at this point except re-boot it (complete power down and then power it back on).

If I assign some other button to execute the function: StopAllTasks(), then it seems to work OK.
For example, if I insert the following line in the demo program:
if (getButtonPress(buttonUp)) stopAllTasks();
Then the demo works perfectly as long as I don't press the Back button to exit. If I press the Up button, the program will exit normally and I can re-start it from the brick without any trouble.

Is there something else I can do with the Back Button?
Somehow the Back Button is failing to exit the program properly. Is there a way I can get the Back Button to execute: "stopAllTasks"?

I tried:
if (getButtonPress(buttonBack)) stopAllTasks();
But that didn't seem to work.


Sat Feb 21, 2015 12:26 am
Profile
Rookie

Joined: Fri May 08, 2015 3:24 am
Posts: 1
Post Re: Multitasking on EV3
Valter1966 wrote:
jkandra wrote:
I think I have found a reasonable solution.
I would alter the Multitasking demo to include the following change to the mainTask:

task main() {
setBlockBackButton(true);
startTask(TOne); // Start Task TOne.
startTask(TTwo); // Start Task TTwo.

while(true) {
if (getButtonPress(buttonLeft)) stopAllTasks();
wait1Msec(300); // Allow for a short wait, freeing up the CPU for other tasks.
displayCenteredBigTextLine(0, "TASK M"); // Display that Main is running.
}
return;
}


Hi,

Yesterday I changed my code, and now I can use EXIT button to stop all tasks, so I can use multitasking without problems :-)

// this task watches for exit button to STOP the program
task StopAllTasksWithExitButton()
{
setBlockBackButton(true);
while(true)
{
if (getButtonPress(buttonBack))stopAllTasks();
wait1Msec(100); // Allow for a short wait, freeing up the CPU for other tasks.
}
}

// This is the MAIN TASK ^^^^^^^^
task main()
{
.............
startTask (StopAllTasksWithExitButton);
.............
repeat(forever){}
}


I have same problem, but i haven't still deal with it yet ???


Fri May 08, 2015 3:29 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.