[ECOS] Event based programming in ecos

Andrew Lunn andrew@lunn.ch
Wed Mar 23 21:36:00 GMT 2005


On Wed, Mar 23, 2005 at 05:17:44PM +0200, Wayne Gemmell wrote:
> Hi all
> 
> I'm looking to make an event based program. Is there any easy way to
> do this?  Could you please give me some directions, links. I was
> thinking of running a loop to monitor the sensors but this doesn't
> strike me as efficient and could possibly be done better with
> interrupts and threads.

eCos's message boxes are ideal for event loops. You have a thread
which simply takes takes messages out of the message box and acts on
them. The message box gives you a void * which is ideal as a pointer
to the actual message. 

Your sensors can then be interrupt driver. The DSR or a thread which
is woken up then posts a message to message box with the results from
the sensor. Just be careful not to use the blocking cyg_mbox_put()
from the DSR. You need to either use cyg_mbox_tryput() and handle the
case when the message box is full, or have the DSR signal a thread to
to the cyg_mbox_put() which can then block.

        Andrew

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



More information about the Ecos-discuss mailing list