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.

Application hangs in sl_Stop() function.

Hi,

My application is hanging inside the sl_Stop() function call.

The application is currently configured to restart the WiFi link once in 5 seconds or so, just to test the sl_Stop() issue.

The semaphore lock is being used to wait for two other tasks to complete their network activity.

Please see code below which shows the sequence of re-initialization of the WiFi link:

***********************************************************************************************

if ((ret = osi_LockObjLock(&pLockAp , OSI_WAIT_FOREVER)) <0)
{
UART_PRINT("IPSM Error locking Object...\n\r");
}
MAP_UtilsDelay(10000000/2.5);
MAP_UtilsDelay(10000000/2.5);

lRetVal = Network_IF_DeInitDriver();
if(lRetVal < 0)
{

UART_PRINT("Failed to stop SimpleLink Device...\n\r");
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("IPSM Error Unlocking Object...\n\r");
}

continue;
}

Network_IF_ResetMCUStateMachine(); // Reset The state of the machine

// Start the driver
lRetVal = Network_IF_InitDriver(ROLE_STA);
if(lRetVal < 0)
{
UART_PRINT("Failed to start SimpleLink Device...\n\r");
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("IPSM Error Unlocking Object...\n\r");
}
continue;
}

lRetVal = Network_IF_ConnectAP(g_cWlanSSID,g_SecParams);
if(lRetVal < 0)
{
UART_PRINT("Connection to an AP failed...\n\r");
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("IPSM Error Unlocking Object...\n\r");
}
continue;
}

// Get the IP address acquired by device
lRetVal = Network_IF_IpConfigGet(&ulIP,&ulSubMask,&ulDefGateway,&ulDns);
if(lRetVal < 0)
{
UART_PRINT("Getting IP Address failed...\n\r");
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("IPSM Error Unlocking Object...\n\r");
}
continue;
}

UART_PRINT("Device IP Address is %d.%d.%d.%d \n\r\n\r",
SL_IPV4_BYTE(ulIP, 3),SL_IPV4_BYTE(ulIP, 2),
SL_IPV4_BYTE(ulIP, 1),SL_IPV4_BYTE(ulIP, 0));
if(SL_IPV4_BYTE(ulIP, 3) == 0) // If IP address is "0.<something>.<something>.<something>", it is not valid.
{
UART_PRINT("Did not obtain IP Address...\n\r");
//Signal to any waiting task that net connection is down
net_connect = FALSE;
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("OTA Error Unlocking Object...\n\r");
}
continue;
}

// Get the serverhost IP address using the DNS lookup
lRetVal = Network_IF_GetHostIP((char*)IPSM_SERVER, &ulDestinationIP);
if(lRetVal < 0)
{
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
UART_PRINT("DNS lookup failed...\n\r",lRetVal);
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("OTA Error Unlocking Object...\n\r");
}
continue;
}

// ulDestinationIP = 0;//TODO Raj
UART_PRINT("IP address passed to create connection is %ul",ulDestinationIP);

lRetVal = Network_IF_GetHostIP((char*)"redmine-server.dyndns.org", &OtaIP);
if(lRetVal < 0)
{
UART_PRINT("DNS lookup failed...\n\r",lRetVal);
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
// MAP_UtilsDelay(10000000/2.5); // 2 seconds delay --TODO Raj
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("OTA Error Unlocking Object...\n\r");
}
continue;
}

//Signal to any waiting task that net connection is up
net_connect = TRUE;
if ((ret = osi_LockObjUnlock(&pLockAp)) <0)
{
UART_PRINT("OTA Error Unlocking Object...\n\r");
}
osi_Sleep(100);

**********************************************************************************

There is a sl_Stop() call that happens inside the Network_IF_DeInitDriver() function. I have a print before the App enters the sl_Stop() function and a print after the sl_Stop function. The print before the sl_Stop() function appears on the screen but not the print after the sl_Stop() function call. This happens randomly when the App runs for about half an hour or so.

Can someone please help resolve this issue?

thanks and regards,

Rajkumar

  • Hi Rajkumar,

    Can you step inside "sl_Stop" and confirm where exactly it is hanging?
    Also, what is the timeout value you are giving to sl_Stop()?

    Regards,
    Gigi Joseph.
  • Hi Gigi,

    When i put some prints inside sl_Stop() to find out what is happening and made a couple of other changes, the issue was not happening.(Is it the added delay?) After that I made some other changes and have been running the App for more than 10 hours, no issue yet.But I am not convinced the issue will not happen again.

    The timeout to sl_Stop()(where the issue was happening) is 0xffff.

    Are there any Do's and Don'ts that need to be followed? Are there any guidelines? Earlier when the issue was hapening and I commented out two of the three tasks, the issue went away so definitely it has something to do with the CPU/NP activity that is going on.

    Now, I have all the 3 tasks running using Free-RTOS. The tasks are all opening sockets and sending/receiving data.

    I am also protecting the opening of sockets and sending data and then closing sockets using Semaphores in all the tasks.

    Can  you please throw some light on this?

    thanks and regards,

    Rajkumar

  • Hi Rajkumar,

    The mutex and semaphore logic is part of the host driver and you need not implement it at application level for simplelink host driver API.
    I will suggest you to use sl_Stop() with timeout value less than 0xFFFF.

    Please try this and let us know if you are still seeing the issue.

    Regards,
    Ankur
  • Hi Rajkumar,

    Can you please update if the issue is resolved?

    Regards,
    Ankur
  • Hi Rajkumar,

    I am closing this thread, if the issue still exists please open a new thread and add a link to this one for reference.

    Regards,
    Ankur