Issue working with rtemsTimer

Martínez, Pablo pabloa.mar at gmail.com
Mon Sep 15 20:05:03 UTC 2014


Hi guys,

Im trying to implement a single shot timer.

I derive from rtemsTimer class and replace virtual void triggered()=0

#include <rtems++/rtemsTimer.h>
...

class Timer : public rtemsTimer {
public:
    Timer(const char* tname);
    virtual ~Timer();
private:
    void triggered();
};

in timer.cpp

void SynchTimer::triggered(){

    printf("hello Timer! \n");

}


Then I have the following task class who creates and fires a Timer object:

class TimerMngr : public rtemsTask{

public:
    TimerMngr(const char* tname);
    virtual ~TimerMngr();

private:
    void body(rtems_task_argument argument);

};


in timerMngr.cpp

TimerMngr::TimerMngr(const char* tname)
:    rtemsTask(tname,
        1,
        RTEMS_MINIMUM_STACK_SIZE,
        RTEMS_PREEMPT|RTEMS_TIMESLICE,
        0,
        RTEMS_NO_FLOATING_POINT,
        RTEMS_LOCAL)

{
    if(last_status_code()!=RTEMS_SUCCESSFUL)
        printf("SynchMngr::error when create()%d \n",
                last_status_code());
}



void TimerMngr::body(rtems_task_argument argument){

    printf("TimerMngr::body!  \n");   [1]

    /* Create the Timer
     * *****************************/
    Timer* timer=new Timer("timer");

    printf("SynchMngr, CurrentTime! @ %d \n",getCurrentTime());   [2]


    /* start timer
     * *****************************/
    rtems_status_code status;
    status=synch_timer->fire_after(120);
    printf("synch_timer->fire_after() status %d \n",status); [3]


    wake_after(500);
    printf("SynchMngr, CurrentTime @ %d \n",getCurrentTime()); [4]

}

unsigned TimerMngr::getCurrentTime(){
    //rtems_unsigned32  time_stamp;
    unsigned time_stamp;
    time_stamp=0;
    rtems_status_code status;

    status=rtems_clock_get(RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH,&time_stamp);
    if(status!=RTEMS_SUCCESSFUL)
        printf("error with rtems_clock_get %d \n",status);

    return time_stamp;
}

When I run the app I get the first and second printf [1] y [2]. But just
"syn" from the 3erd printf [3].

In the conf file:

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_TICKS_PER_TIMESLICE       30
#define CONFIGURE_MAXIMUM_TIMERS              4

Any suggestion?

Cheers,
Pablo

-- 
Martínez, Pablo Agustín
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20140915/9b0ad5bf/attachment.html>


More information about the users mailing list