This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Mail Box Timeout


"Chuck Chen" <ycchen@zcom.com.tw> writes:

> Hello Eric,
> 
> Thanks foe your quick feedback.
> Yes. I pass the absolute timeout to cyg_mbox_timed_get()
> Howver, the value of cyg_current_time() is always 0 so that the callback
> functiob od alarm can't be run repeatedly.
> The alarm code is following.
> 
> void cyg_start(void)
> {
>      cyg_handle_t counter_hdl;
>      cyg_handle_t sys_clk;
>      cyg_handle_t alarm_hdl;
>      cyg_alarm alarm_obj;
>      unsigned long index;
> 
>     sys_clk=cyg_real_time_clock();
>     cyg_clock_to_counter(sys_clk, &counter_hdl);
>     cyg_alarm_create(counter_hdl, test_callback, (cyg_addrword_t) &index,
> &alarm_hdl, &alarm_obj);
>     cyg_alarm_initialize(alarm_hdl, cyg_current_time(), 50);
>     .......
> }
> 
> void test_callback(cyg_handle_t alarm_handle, cyg_addrword_t data)
> {
>     diag_printf("Alarm is active!\n");
> }
> 
> 
> Then, the callback function of alarm is executed once only.
> 

cyg_start() is run before the scheduler is started. Because your alarm
sets its trigger to the current time, it gets called immediately from
cyg_alarm_initialize(). Further alarms will only happen once the OS is
actually running. You need to call cyg_scheduler_start() for this to
happen. Take a look at some of the examples or test programs.

-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com      The eCos and RedBoot experts


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]