2017-05-25 06:47 AM
Hello all,
I have problems with Message Queue in CMSIS-RTOS. I have following code
for putting C structures onto the Message Queue
BOOL
put_program_chunk(
main_controller_req_t
req){
main_controller_req_t
*p_req;
BOOL
retval;
BOOL
no_memory =
FALSE;
osStatus
status;
uint8_t
tmp;// allocate memory in pool
p_req = (
main_controller_req_t
*)osPoolAlloc(flash_pool);
#ifdef
APP_DEBUG
if
(p_req == NULL){
printf(
'No more space in flash pool.\r\n'
);
}
#endif
if
(p_req != NULL){
*p_req = req;
// insert the prepared request into the transmission queue
// osOK = 0x0
if
(!osMutexWait(flash_queue_mutex, osWaitForever)){
// put the message into the queue
// wait 5
ms
?status = osMessagePut(flash_queue, (
uint32_t
)(p_req), 5);osMutexRelease(flash_queue_mutex);
if
(status ==
osOK){
tmp = 1;
}
else{
tmp = 0;
}
}
}
else{
no_memory =
TRUE;
}
if
(no_memory){
retval =
FALSE;
}
else{
retval =
TRUE;
}
return
retval;
}
As soon as I try to call the osMessagePut, the program stick somewhere in the osMessagePut
function and the function never returns any value. The Message queue is shared by two tasks.
One is a producer (with priority equal osPriorityLow
) and the second one is a consumer
(with priority equal osPriorityAboveNormal
). Producing task is processed each 100 ms and
consuming task each 20 ms. Can anybody give me any advice what I have been doing wrong?
Thanks in advance for any suggestions.