9 years ago.

Ticker, Timeout or RtosTimer to schedule a function call?

Hello,

i my project is my target to shedule the call of a funtion. After a delay of 50ms or 100ms a can response shall be send.

The steps are: 1. main(): get the can message by interrupt (RxIrq) and check ID. If valid, pass to messageConsumer_Thread with

   queue.put(ptr_msg);

2.in my messageConsumer_Thread inside while(true):

  if (evt.status == osEventMessage)
    CANMessage *ptr_msg = (CANMessage*) evt.value.p;					
    switch (ptr_msg->id{             
	case LOW:                          
	     consumeLOW_Message(ptr_msg)
	break;
	case HIGH:            
	     consumeHIGH_Message(ptr_msg);
	break;
   ...

3. Inside the void consumeHIGH(consumeLOW)-Function (after setting the payload of the frame):

RtosTimer sendTimer(send_Frame, osTimerOnce, (void *) ptr_msg);
sendTimer.start(50);  //sendTimer.start(100); if consumeLOW()

4. Atfer 50ms(100ms) the send_Frame-Function shall send the CANFrame (after casting):

if (can2.write(*ptr_msg)) {
	memoryPool.free(ptr_msg);
                 led1 = !led1;

The problems here are: the send_Frame() is never called -> sendTimer dies after exiting consumeHigh? How can i shedule the send job in other way? by a seperate senderThread (passing the Timer to it and keep it alive)? or is a timeout object the better solution?

Can somebody help me with that issue?

Thank you.

Question relating to:

Be the first to answer this question.