AnsweredAssumed Answered

nio_serial gets blocked

Question asked by Adrian Rockall on Aug 20, 2015
Latest reply on Aug 25, 2015 by isaacavila

I am using the printf debug console to show many diagnostics messages in a terminal window. Occasionally the function will block forever waiting for space in the output buffer. I have tracked down the reason but not the cause. In the nio_serial_txcallback function there is the section:

    if (buffer->FLAGS & NIO_SERIAL_WAITING)

    {   /* If the desired place in buffer was released, post blocking semaphore */

        if (!(--buffer->WAIT_NUM))

        {

Sometimes it can reach the --buffer->WAIT_NUM when WAIT_NUM is already 0 so it decrements to 4294967295 and then the semaphore never gets posted so the send function stays permanently blocked. I can't see why WAIT_NUM should be 0 when FLAGS has the NIO_SERIAL_WAITING bit set but it does.

 

For now I have change the test line to:

        if ((buffer->WAIT_NUM == 0) || !(--buffer->WAIT_NUM))

which seems to solve the lockup but I feel it is covering up the real problem.

 

Best regards,

Adrian.

Outcomes