Wait for message and signal simultaneously using CMSIS RTX call
Hi All,
I am using CMSIS RTX V4.80.0. I need to wait for a message and a signal simultaneously in a single thread.
In the CMSIS RTOS API, I came across a function osWait() which meets my requirement. Is there any methods to achieve the same using the CMSIS RTX API.
In CMSIS RTX, both the osSignalWait and the osMessageGet functions return the same structure an osEvent which contains osStatus that contains the information for unblock(an osEventSignal or an osEventMessage). I tried using osSignalWait/osMessageGet function in the thread and identify whether message or signal is received using the return status. But for osSignalWait only osEventSignal is received as status and for osMessageGet only osEventMessage is received as status.
Is there any other alternatives to meet the requirement.
Thank you.
Just a footnote - if the wait-complex can't consume all "ready" event information in a single call, then it should be written like:
int wait_complex(unsigned timeout) { res = wait(summary,timeout); if (res != timeout && res != error) { crit(x) { if (a && b) { a = false; b = false; res = EVENT_A_AND_B; } else if (c) { c = false; res = EVENT_C; } else if (d) { d = false; res = EVENT_D; } else { res = EVENT_EMPTY; } if (a&&b || c || d) signal(summary); // so next wait() doesn't hang } } return res; }
It then needs to "restart" the summary signal, in case there are more state information ready to process.