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.

RTOS/AM3352: Sendto does not free memory when there is no network

Part Number: AM3352
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

In our application, we will send out a UDP broadcast once every 2.5 seconds using the sendto function until we see a response.  If there is no Ethernet cable connected, we're seeing that after ~190 calls, sendto will return SOCKET_ERROR.  Further checking reveals that it is because we are getting ENOBUFS which is "Memory allocation failure while attempting to send data."

The question is how do I free up the memory that has been allocated by a previous call to sendto if there is no cable and therefore no mechanism to actually get the packet out onto the wire?  Currently running NDK 2.24.3.35.

Kevin Jennings

  • Hi Kevin,

    Let me consult with a colleague that has more NDK experience & I will reply back shortly.

    Best,
    -- Emmanuel
  • Hi Kevin,

    The NIMUSendPacket() API (which is called internally by the stack) frees the memory if the driver has a problem:

    void NIMUSendPacket (HANDLE hIF, PBM_Pkt *pPkt)
    {
        NETIF_DEVICE*   ptr_device;
     
        /* Get the NIMU Network Interface object. */
        ptr_device = (NETIF_DEVICE *)hIF;
     
        /* Pass the packet to the driver through the registered 'send' function. */
        if (ptr_device->send (ptr_device, (PBM_Handle)pPkt) < 0) // ß this is a call to the driver function
        {
            /* Driver reported an error and was unable to transmit the packet.
             * The NIMU will clean the packet memory. */
            PBM_free( (PBM_Handle)pPkt );
            return;
        }
        return;
    }

    It would be helpful to see what the driver is returning.  Can you place a breakpoint in the driver's send function (once the cable is unplugged)?  If you are not sure which is the NIMU driver's send function you can look for where the "ptr_device->send is assigned in the driver source:

     ptr_device->send        = "EmacSend";

    It is possible that the function is actually called "EmacSend" as the code above was taken from the AM335x SDK (

    C:\ti\am335x_sysbios_ind_sdk_01.01.03.03\sdk\os_drivers\source\ICSS\icss_nimu_eth.c).

    Regards,

    -- Emmanuel