AnsweredAssumed Answered

PEG Get Timer Event event if timer killed

Question asked by arnogir on Jan 30, 2020
Latest reply on Feb 24, 2020 by arnogir

Hello,

 

I start the project with peg 5 years ago, And at this time, there was a support via email.

Today, this email is broken!

So I ask the question here.

 

I’m facing a problem with the PEG which lead to a µC crash.

 

I’m on a Kinetis K70 with MQX 4.2, PEG lite 2.4.

 

I’m on a screen in which I start a timer when I press a PegButton:

 

case PEG_SIGNAL(ID_AP_SCREEN_Cleaning_ConfirmButton, PSF_CLICKED):
       
// WB_AUTO_GEN  Enter your code here:
….       
          SetTimer(AP_SCREEN_CLEANING_TIMER_ANIMATION, PEG_ONE_SECOND
/10, PEG_ONE_SECOND/10);
       
}

 

On another button, I select in the PegBuilder it should make a “switch to” the RootWindow, then the generated code is following:

 

case PEG_SIGNAL(ID_AP_SCREEN_Cleaning_CancelButton, PSF_CLICKED):
       
{
        PegWindow *pw
= new rootwindow(0, 0);
        Parent()
->Add(pw);
       
}
        Destroy(
this);
       
// WB_AUTO_GEN Enter your code here:
        KillTimer(AP_SCREEN_CLEANING_TIMER_ANIMATION);
       
return ID_AP_SCREEN_Cleaning_CancelButton;      /* WB_AUTO_GEN End case */

 

You can see the generated code, switch to the RootWindow, and destroy the current view.

After that, I kill the created timer.

 

But, in some case, I think the Timer event was already into the queue when the timer is killed.

Then, I get later event timer, in which for some reason, I do the following:

 

case PM_TIMER:
   
{
     
if (Mesg.Param == AP_SCREEN_CLEANING_TIMER_ANIMATION)
     
{       
        ….
       
if (AP_Clean_GetState() == AP_CLEAN_IDLE)
       
{
          ….

          PegWindow *pw = new rootwindow(0, 0);
          Parent()
->Add(pw);
          Destroy(
this);
          KillTimer(AP_SCREEN_CLEANING_TIMER_ANIMATION);
       
}
        CheckDefault();
     
}
      
return PegWindow::Message(Mesg);

In fact, it is a supervision timer which check a state of my application. If state is Idle, I should quit the current view and return to the root window.

Then, Like the event timer was into the queue before I press the cancel button, I also get the timer event in which I also create the rootwindow and destry(this)

So this part is done twice time! Then I obtain a µC crash on the Parent()->Add(pw);

 

Could you advise me if there are a simple way to discard all the selected timer event into the queue when I Kill them?

Outcomes