This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Event based programming in ecos
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Wayne Gemmell <waynetg at telkomsa dot net>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Wed, 23 Mar 2005 19:40:33 +0100
- Subject: Re: [ECOS] Event based programming in ecos
- References: <200503231717.44169.waynetg@telkomsa.net>
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