This is the mail archive of the ecos-discuss@sourceware.org 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]

AW: driver development, how to make timeouts?


Thanks for your hint. It works fine with cyg_cond_timed_wait() !

But I have not found it in eCos documentation! Is there a newer manual
available, which is describing additional API functions?

Richard 


Richard Rauch
email: rrauch@itrgmbh.de
 
_______________________________________________

ITR GmbH 
Informationstechnologie Rauch 
Schnepfenreuther Hauptstrasse 27b
D-90425 Nuernberg
 
phone:  +49 (0) 911 3784437
VoIP:    +49 (0) 911 495221739
web:     http://www.itrgmbh.de
email:   info@itrgmbh.de
 
Geschaeftsfuehrer: Richard Rauch
Handelsregister: Nuernberg HR B 21676
USt-Id Nr. : DE228051873
_______________________________________________

-----Ursprüngliche Nachricht-----
Von: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] Im Auftrag von Sergei
Gavrikov
Gesendet: Samstag, 28. Mai 2011 19:15
An: Richard Rauch
Cc: ecos-discuss@ecos.sourceware.org
Betreff: Re: [ECOS] driver development, how to make timeouts?

On Sat, 28 May 2011, Richard Rauch wrote:

> Hi all,
> 
> How I have to implement a timeout inside an eCos Driver?
> 
> I have following code, which is waiting on an interrupt event:
> 
>     cyg_drv_mutex_lock(&(extra->i2c_lock));
>     cyg_drv_dsr_lock();
>     while (!extra->i2c_completed) {
>         cyg_drv_cond_wait(&(extra->i2c_wait));
>     }
>     cyg_drv_dsr_unlock();
>     cyg_drv_mutex_unlock(&(extra->i2c_lock));
> 
> 
> The cyg_drv_cond_wait() never returns, as long as no interrupt occurs. 
> But in special cases (if the hardware is not wired properly), there 
> will be never an interrupt.
> 
> How can I break in this function after a while?
> 
> In normal user API, there is a function cyg_cond_timed_wait() which is 
> able to return in case of timeout.
> I haven't found a similar function in driver's kernel API!
>
> Who knows a solution?

Hi,

There is such a precedent in io/can/current/src/can.c:

69 #ifdef CYGOPT_IO_CAN_SUPPORT_TIMEOUTS 70 #define CYG_DRV_COND_WAIT(_cond,
_time) cyg_cond_timed_wait(_cond, cyg_current_time() + (_time))
71 #else
72 #define CYG_DRV_COND_WAIT(_cond, _time) cyg_drv_cond_wait(_cond)

But, keep in a mind that needs eCos kernel packages:

    cdl_component CYGOPT_IO_CAN_SUPPORT_TIMEOUTS {
        display       "Support read/write timeouts"
        flavor        bool
        default_value 0
        active_if     CYGPKG_KERNEL
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ...

HTH

Sergei

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



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


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