View unanswered posts | View active topics It is currently Fri Oct 31, 2014 12:06 am






Reply to topic  [ 2 posts ] 
Improper logical expression evauation 
Author Message
Rookie
User avatar

Joined: Mon Dec 31, 2007 12:51 pm
Posts: 5
Location: United States
Post Improper logical expression evauation
When using the debugger, the if statement in the aTask thread does not evaluate properly; i.e., when time_msec is negative, the expression still evaluates as true, and the debugger steps to the wait1Msec. Note: the following was intentionally modified to provide a negative value of time_msec.

Code:
task aThread()
{
  short time_msec = 0;

  while(true)
  {
    // Start timer
    time1[T1] = 0;
    time_msec = time1[T1];
    wait1Msec(50);
    time_msec -= time1[T1];
    nxtDisplayTextLine(2,"%d msec",time_msec);
// !!! the following line does not evaluate as false when using the debugger with time_msec < 0 !!!
    if(time_msec > 0)
    {
      // Put this task to sleep for the remainder of the sample time
      wait1Msec(time_msec);
    }
  }
}

task main()
{
  StartTask(aThread);
  // Display sensor data untill this task is externally killed
  while(true)
  {
    wait1Msec(100);
  }

  StopAllTasks();
}


- Olorin


Last edited by Olorin on Tue Jan 01, 2008 4:40 pm, edited 2 times in total.



Tue Jan 01, 2008 2:43 pm
Profile
Rookie
User avatar

Joined: Mon Dec 31, 2007 12:51 pm
Posts: 5
Location: United States
Post Improper logical expression evauation
Apparently, this is only a problem with the debugger break points (pausing execution) in "threads".

I have no problem using the debugger with a similar situation within the scope of main.

I replaced the use of breakpoints in the above source with an additional variable counter that indexed each time the expression failed to evaluate properly. Without stopping execution, I watched the counter in the debug window, and it did not increment (the expression evaluated properly).

I hope these clues may help the development team.

Cheers,
Olorin


Tue Jan 01, 2008 4:15 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.