Messaging Framework message not going through

Hi everyone,

I asked a similar question a while ago, but there has been no answer. So let's try it again:

I'm using the messaging framework to send a message from one thread to another. This usually works, but under a certain condition, when doing measurement in the thread I'm sending the message to, the message is only received when I pend an extremely long time (like 200ms). I can not afford to have that thread timeout 200ms just waiting for a message. An explanation of what the thread does when the message it not received:

I handled the callback like an interrupt, as short as possible:

void uart5_callback(uart_callback_args_t *p_args)
{
switch(p_args->event)
{
case UART_EVENT_RX_CHAR:
case UART_EVENT_BREAK_DETECT:
TEL[TEL_ptr++]=(UCHAR)p_args->data;
if(TEL[TEL_ptr-1]==0x0D)
{
tx_semaphore_put(&g_semaphore_uart5);
}
break;
case UART_EVENT_TX_COMPLETE:
tx_semaphore_put(&g_semaphore_uart5_tx_complete);
break;
default:
break;
}
}

The timeout is implemented as follows:

unsigned short wait_for_answer(void)
{
    USHORT result=1;
    new_weight_received=false;
    ldu_ok=false;
    result = tx_semaphore_get(&g_semaphore_uart5,TX_TIMER_TICKS_PER_SECOND*3);            //wait 3s for answer
    if(!result)
    {
        New_Telegram1();
    }
    TEL_ptr=0;
    return result;
}

Basically, I wait for the "telegram received"-semaphore with a timeout of 3s. Of course, when the external device is connected, it only takes a few ms to receive the answer and get the semaphore. The function I am calling in my main loop as mentioned in the first post:

unsigned short get_netto(float *weight)
{
    unsigned short errorcode=0;
    SendStringLDU("GN");                            
    if (wait_for_answer())errorcode=ldu_noanswer;
    if (!new_weight_received) errorcode=ldu_noweight;
    if(!errorcode)*weight=weight_n;
    return errorcode;
}

The bool "new weight received" is being set in the New_Telegram1()-function, if I ask the external device for a weight and also get one. This function is blocking, because wait_for_answer() blocks in the semaphore-get command.

The wait_for_answer() is blocking in the thread that is meant to receive the message. Can this be the reason of the framework not working?

Original thread is here: https://renesasrulz.com/synergy/f/synergy---forum/14353/messaging-framework-pend-not-receiving-message-if-wait-time-is-too-short

Regards,

Christoph