This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Exosite IOT (tcp_write) LWIP assigned callback error handler never appears to trigger event errors.

Guru 56218 points

Seems the error handler assigned callback function in IOT code is not triggering on any errors being returned in an IF clause. Yet testing the error variable locally triggers the (ExoHAL) error event handler as the call back should be doing. Seems when LWIP Debug is enabled the TCP callbacks may be working or at least the ASSERT debug errors then will print (UARTprintf) messages. 

 Appears to be a hanging ERR_INPROGRESS (-5), unless filtered would & should be triggering call back TCPError() repeatedly.

LWIP (tcp_write) returns only ERR_OK, ERR_CONN, ERR_MEM.

LWIP (tcp_output) returns ERR_OK or "another (err_t) on error" , that presumably infers all other errors -1 to -15?

Does adding variable to head of IF clause in a caller negate the return to the caller? 

Odd we have to filter the ERR_INPROGRESS or the ExoHAL error flag is fired at a continuous rate from eError fall through check. Yet never does the user assigned TCPError() ever register an (err_t) event with ExoHAL even when NETIF errors occur.

(LWIP_CALLBACK_API == 1 ) user function is assigned for call back error handler shown here top to service the TCP callback events.

void
TCPError(void *vPArg, err_t iErr)
{

	UARTprintf("eth_client_lwip(): << TCPError: ETH_CLIENT_EVENT_ERROR >>\n\n");
    //
    // Signal event handler that there was an error.
    //
    g_sEnet.pfnEvent(ETH_CLIENT_EVENT_ERROR, 0, (uint32_t)iErr);


void
lwIPHostTimerHandler(void)
{
    uint32_t ui32IPAddr;
    err_t eError;

    //
    // The state flag has informed us to send pre buffered data
    //
    if(g_sEnet.eState == iEthSend)
    {
    	 /** Checks if tcp_write is allowed or not (checks state, snd_buf and snd_queuelen).*/
        // Queue the send.
        //
        if (eError = (tcp_write(g_sEnet.psTCP, g_pui8SendBuff + g_sEnet.ui32SendIndex,
                           g_sEnet.ui32SendSize, TCP_WRITE_FLAG_COPY) == ERR_OK))
        {
		// Just in case LWIP user function error trap fails during tcp_write.
        //
		if((eError == ERR_CONN || ERR_MEM) && !ERR_INPROGRESS)
		{
			(g_sEnet.pfnEvent(ETH_CLIENT_EVENT_ERROR, 0, eError));

			g_sEnet.ui32SendSize = 0;

			return;
		    }
        }
        // If tcp write succeeds, Write data for sending (but does not send it immediately).
			{
        	// Find out what we can send and send it.
            //
            if(eError = (tcp_output(g_sEnet.psTCP) == ERR_OK))
            {
        		// Just in case LWIP user function error trap fails during tcp_output
        		if((eError != ERR_OK) && !ERR_INPROGRESS)
        		{
        			(g_sEnet.pfnEvent(ETH_CLIENT_EVENT_ERROR, 0, eError));

        			g_sEnet.ui32SendSize = 0;

        			return;
        		}
		}
		//
		// No more data to send.
		//
		g_sEnet.ui32SendSize = 0;

		//
		// Set state to Idle
		//
		g_sEnet.eState = iEthIdle;

		}
    }

 

  • After adding a static export void we witnessed vendor supplied (TI) error handler actually work today. Still don't understand why ERROR_INPROGRESS flag is constant returned into (eError) during (tcp_write/tcp_output) since neither one returns that err_t event.

    (lwip_eth_lient.h)

    //*****************************************************************************
    //
    // Exported Ethernet function prototypes.
    //
    //*****************************************************************************
    #include "lwip/err.h"
    static void TCPError(void *vPArg, err_t iErr);