We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am using the CMSIS version of rtx.
Here is my code:
void status_led_task(void const * arg) { bool b_flashing_state = false; uint16_t flashing_led_mask = 0; uint16_t current_led_mask; int current_state; osEvent event; mail_t * p_mail; init(); while(1) { /* wait for a message or the desired flashing perid */ event = osMailGet(g_mail_queue, osWaitForever);//STATUS_LED_FLASHING_PERIOD); if (event.status == osEventTimeout) { /* time to flash any status leds that are in the flashing state */ if (b_flashing_state == true) { leds_on(flashing_led_mask); } else { leds_off(flashing_led_mask); } b_flashing_state = !b_flashing_state; } else if (event.status == osEventMail) { p_mail = event.value.p; current_led_mask = p_mail->led_num + STATUS_LED_GPIO_OFFSET; current_led_mask = (1 << current_led_mask); current_state = p_mail->state; osMailFree(g_mail_queue, p_mail); switch(current_state) { case LED_OFF: /* disable flashing mode for this pin */ flashing_led_mask &= ~current_led_mask; led_off(current_led_mask); break; case LED_ON: /* disable flashing mode for this pin */ flashing_led_mask &= ~current_led_mask; led_on(current_led_mask); break; case LED_FLASHING: /* enable flashing mode for this pin */ flashing_led_mask |= current_led_mask; break; } } } }
As you can see this is a simple led driver. Another task sends messages to this task via a mail queue. The message indicates a led number and a desired state. To handle any leds that are in the flashing state, I have a timeout on my osMailGet() call. If a timeout occured I toggle any leds in the flashing state, else if a message arrived, I put the indicated led into the correct state.
My problem is this. You will notice above that I have commented out the timeout on the osMailGet() call. This essentially removes the flashing functionality. The reason I did this is because if the timeout condition is present then the task that sends the message to this task, will have a stack overflow very quickly after the first few messages. If I don't have a timeout and wait forever for messages then I dont' have any problems and I can run all day sending messages to this task, albeit without the flashing functionality.
Can anyone see anything wrong with the way I have implemented this code, or give me an understanding as to why having the timeout condition might be a problem. Frankly I am beginning to suspect a bug with the CMSIS port of RTX.
I will add that currently I am using a switch that I am manually pressing to send the messages to this led driver. The switch is being debounced by having to have 2 consecutive reads of the switch be the same, where the polling frequency is 25ms.
Thanks,
A problem within CMSIS RTOS port of RTX in regards to mailbox timeout has already been identified and corrected.
An updated version of CMSIS RTOS RTX will be released shortly.
Wondering where I would find reference to any errata like this. It would have saved me a lot of time debugging yesterday, if there was an errata reference for the CMSIS port. Also do you know how long this has been a known issue, ie when you say shortly for a fix, do you mean days or weeks?
Updated version of CMSIS RTOS RTX is expected to be released in a few days.
Changes are listed in the documentation under the Revision History.
So I assume you are saying that there is no other errata that I should be worried about in the mean time?
There are no other known problems.
Is this fix avaialable yet?
Thanks
Updated version of CMSIS RTOS RTX V4.61 is available at: http://www.keil.com/demo/eval/rtx.htm