How to find originated event

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

How to find originated event

Post by ucasano »

Hello all,

I have a thread which stays in wait state, until an event is fired. So, in this thread I use

eventmask_t e = chEvtWaitOne(3);

which should stand for: wait for eventmask 1 or 2... is this right?

In interrupt routine, I fire events through:

chEvtSignalFlags(thread_in_wait, 1);

or

chEvtSignalFlags(thread_in_wait, 2);

Problem is I always receive 1. Is it possible to decode the originated event?

Thanks
-g
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: How to find originated event

Post by Giovanni »

Hi,

The only error I see is that you should use chEvtSignalFlagsI() from an ISR, doesn't the state checker complain about that?

The function chEvtWaitOne(3) should return you 1 or 2 depending on the signaled flags, are you sure that signaling 2 is really executed?

Giovanni
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: How to find originated event

Post by ucasano »

Well, I did as you wrote and now I get both of the events simultaneously.
I set the thread priority to HIGH level, but I still get both of the events at the same time.
Is the interrupt routine signaling events too fast?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: How to find originated event

Post by Giovanni »

chEvtWaitOne() should only return an event each time, a single bit at 1 in the returned mask (and it is not matter of speed). chEvtWaitAny() would return all the pending bits at once.

It is very strange chEvtWaitOne() returning 3, are you sure?

Giovanni
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: How to find originated event

Post by ucasano »

Ok, I solved it by removing a chevtclearflags I tried before.

just for information: where could I find more info about "state checker"?
-g
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: How to find originated event

Post by Giovanni »

Hi,

It is one of the debug options found in chconf.h, it verifies that the various APIs are called from the right context, for example S-class and I-class APIs called from within a lock.
It is mentioned in this article: http://www.chibios.org/dokuwiki/doku.ph ... ebug_guide

Giovanni
Post Reply