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.

[参考译文] SIMPLELINK-SDK-WIFI-plugin:致命错误-在 MSP432P401R 和 CC3120MOD 系统中检测到驱动程序中止

Guru**** 633810 points
Other Parts Discussed in Thread: CC3120
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1075929/simplelink-sdk-wifi-plugin-fatal-error---driver-abort-detected-with-msp432p401r-and-cc3120mod-system

部件号:SIMPLELINK-SDK-WIFI-plugin
“线程:CC3120测试”中讨论的其它部件

您好,

我目前正在使用由 MSP432和 CC3120设备组成的定制无线网络。 该系统从一个 MSP432/CC3120发送数据,并在另一个 MSP432/CC3120接收数据。 我正在使用 WiFi SDK 来实现这一目标。

发送节点 使用 SL_Send 和 SL_Recv 命令向接收节点传输恒定数据流。 在发送节点进入 LPM3.5和接收节点进入 AP 模式之前,此过程将在设定的时间内进行。

在发送循环期间,所有操作都完美无缺,但在完成该过程时似乎存在问题。

在查看接收节点的终端时,我注意到进程完成后会弹出一个错误。 这将显示“[错误]-致命错误:检测到驱动程序中止。”。 我知道这是 来自 SimpleLinkFatalErrorEventHandler(),但我不知道为什么。

发生这种情况时,最后一个收到的数据包末尾的部分字节将被切断,设备将变得无响应。 我试图重置 NWP,因为我在另一个论坛帖子中看到了类似的问题,但这似乎给我带来了另一个错误,同时也打印了相同的内容。

下面是主操作循环的代码以及用于启动和重置 NWP 的代码。 错误首先抛出在 sensorNetDataRecv()内,然后在 restartNWP()内再次发生。

在发送节点与接收节点创建的 AP 断开连接的同时,使用 SL_Recv()调用是否会导致错误? 我尝试了一系列调试,结果各不相同。 例如,在  SimpleLinkFatalErrorEventHandler()内添加 usleep(1000000)可让 sensorNetDataRecv()函数按预期返回,但当 NWP 尝试再次启动时,它将抛出各种不同的错误。

我愿意分享任何有助于进一步解决此问题的代码。 请提前感谢您的帮助。

格雷格

/* Start up the NWP */
void startupNWP(void)
{
    int ret;

    /* Turn NWP on */
    ret = sl_Start(NULL, NULL, NULL);
    if(ret < 0)
    {
        /* Handle Error */
        UART_PRINT("sl_start failed - %d\n", ret);
    }

    /* sl_Start returns on success the role that device started on */
    app_CB.Role =ret;

    /* disable the soft-roaming */
    //cmdSoftRoamingDisablecallback();

    /* Unregister mDNS services */
    ret = sl_NetAppMDNSUnRegisterService(0, 0, 0);
    if(ret < 0)
    {
        /* Handle Error */
        UART_PRINT("sl_NetAppMDNSUnRegisterService failed - %d\n", ret);
    }
}

/* Reset the NWP */
void restartNWP(void)
{
    int ret;

    sl_Stop(0);

    sleep(3);

    ret = sl_Start(0, 0, 0);
    if(ret < 0)
    {
        /* Handle Error */
        UART_PRINT("sl_start failed - %d\n", ret);
    }
}


void * mainThread(void *arg)
{
    int32_t ret;
    wakeup_flag = 0;
    wakeup_count = 0;
    pthread_attr_t pAttrs_spawn;
    struct sched_param priParam;
    struct timespec ts = {0};

    /* Initializes the SPI interface to the Network
       Processor and peripheral SPI (if defined in the board file) */
    SPI_init();
    GPIO_init();

    /* Init Application variables */
    ret = initAppVariables();

    /* Init Terminal UART */
    InitTerm();

    /* initialize the realtime clock */
    clock_settime(CLOCK_REALTIME, &ts);

    /* Switch off all LEDs on boards */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
    GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_OFF);
    GPIO_write(Board_GPIO_LED2, Board_GPIO_LED_OFF);

    /* Create the sl_Task internal spawn thread */
    pthread_attr_init(&pAttrs_spawn);
    priParam.sched_priority = SPAWN_TASK_PRIORITY;
    ret = pthread_attr_setschedparam(&pAttrs_spawn, &priParam);
    ret |= pthread_attr_setstacksize(&pAttrs_spawn, TASK_STACK_SIZE);

    /* The SimpleLink host driver architecture mandate spawn
       thread to be created prior to calling Sl_start (turning the NWP on). */
    /* The purpose of this thread is to handle
       asynchronous events sent from the NWP.
     * Every event is classified and later handled
       by the Host driver event handlers. */
    ret = pthread_create(&gSpawn_thread, &pAttrs_spawn, sl_Task, NULL);
    if(ret < 0)
    {
        /* Handle Error */
        UART_PRINT("Network Terminal - Unable to create spawn thread \n");
        return(NULL);
    }

    /* Run NWP Startup Sequence */
    startupNWP();

    /* Output device information to the UART terminal */
    dbg = 1;                // Debug mode on/off
    if (dbg)
    {
        ClearTerm();
        ret = DisplayAppBanner(APPLICATION_NAME, APPLICATION_VERSION);
        if(ret < 0)
        {
            /* Handle Error */
            UART_PRINT(
                "Network Terminal - Unable to retrieve device information \n");
            return(NULL);
        }
    }

    /* Parse MAC address for network functions */
    setNodeNum();

    /*
     * Coordinator Operation Loop
     *
     * This loop occurs infinitely once the coordinator is turned on and operational.
     * It begins by polling for whether the SensorNet needs to turn on to
     * collect data. If the SensorNet needs to turn on, it then asks for the
     * number of SMs.
     *
     */
    while(1)
    {
        /* Enter AP Mode */
        ret =  cmdWlanStartApCallback();
        if (ret < 0)
        {
            if (dbg) UART_PRINT("\n\r[wlan ap start] : Unable to configure AP role.\n\r");
        }

        /* Wait for SM Requests */
        ret = cdWakeupMode();
        if (ret < 0)
        {
            if (dbg) UART_PRINT("Failed to wakeup SMs. Hanging Program.");
            while(1)
            {
            }
        }

        /* If SMs are staying awake, keep AP up */
        putch('a'); // CH signal: entering data collection

        /* Wait for connection to AP */
        if(dbg)
        {
            UART_PRINT("\n\n\rReady to Receive Packets!\n\r");
            UART_PRINT("Waiting for connection...\n\r");
        }
        while (1)
        {
            ret = GET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION);
            if (ret)
            {
                /* Receive Packets */
                if(dbg)
                {
                    UART_PRINT("Connection established\n\r");
                }
                putch('c'); // CH Signal: Receiving packets
                ret = sensorNetDataRecv();  // calls sl_Recv on loop

                /* Return Message */
                if(dbg) UART_PRINT("Done Collecting Data. Returning to Request Polling\n");

                /* Reset NWP */
                restartNWP();

                /* Reset Memory */
                wakeup_count = 0;
                wakeup_flag = 0;
                sem_post(&pollSem);
                break;
            }
        }
    }
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您确定不是太早进入 LPM? 您是否可以仅在循环中测试数据事务,以确保无线通信没有问题?  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    感谢您的快速回复。

    您的上述建议实际上有助于解决该问题。 在无线发送节点进入 LPM 之前添加休眠已修复其中一个驱动程序在接收节点上中止。 然后,我对重新启动做了一些较小的调整,以使第二个驱动程序中止以离开。

    但是,我现在似乎正在处理另一个问题,我不确定它是否相关。 因此,数据收集完成后,接收节点将保持 AP 状态,并再次等待连接。 第一次运行正常,但第二次尝试创建套接字时似乎失败。

    我得到了2005年的代码。 此外,我的 UART_PRIN()调用似乎失败,但我的 putch()调用没有失败。 我认为 malloc 由于堆问题而失败。

    如果您认为插槽问题可能与此相关,请告诉我。

    格雷格

    /* UART_PRINT calls Report */
    int Report(const char *pcFormat,
               ...)
    {
        int iRet = 0;
        char        *pcBuff;
        char        *pcTemp;
        int iSize = 256;
        va_list list;
    
        pcBuff = (char*)malloc(iSize);
        if(pcBuff == NULL)
        {
            return(-1);
        }
        while(1)
        {
            va_start(list,pcFormat);
            iRet = vsnprintf(pcBuff, iSize, pcFormat, list);
            va_end(list);
            if((iRet > -1) && (iRet < iSize))
            {
                break;
            }
            else
            {
                iSize *= 2;
                if((pcTemp = realloc(pcBuff, iSize)) == NULL)
                {
                    Message("Could not reallocate memory\n\r");
                    iRet = -1;
                    break;
                }
                else
                {
                    pcBuff = pcTemp;
                }
            }
        }
        Message(pcBuff);
        free(pcBuff);
    
        return(iRet);
    }
    
    /* This seems to be working */
    void putch(char ch)
    {
    #ifdef UART_NONPOLLING
        UART_write(uartHandle, &ch, 1);
    #else
        UART_writePolling(uartHandle, &ch, 1);
    #endif
    }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    请描述您的网络设置吗? 设备是否正在改变模式? 例如,从 STA->AP? 我不认为我完全理解您的情况。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    当然! 我很乐意更详细地描述设置。

    接收节点:

    -此节点以 AP 的形式启动,等待 STA 的连接,然后在设定的时间段内进入 SL_Recv()循环。

    -在接收环路后,设备将关闭插座,并位于 while 环路中,再次等待连接(而第一个 POST 中显示的环路)。

    -此设备还通过串行与计算机上的应用程序通信 ,这就是为什么使用 UART_PRINT 和 Putch 的原因。

    发送节点:

    -此节点在设定的时间段后从 LPM3.5唤醒,连接到 AP,并在设定的时间段内开始 SL_Send()循环。

    -在发送环路后,设备将关闭插座并再次进入 LPM3.5。

    取得的进展(我意识到我可能需要进一步澄清):

    接收节点是我看到所有问题的节点。 当设备退出 sensorNetDataRecv()函数并返回到外部 while (1)循环时,我最初看到两个驱动程序中止错误。

    您的建议是确保发送节点未进入 LPM 太快,从而修复了第一条错误消息。 我只是用了一个 SLEEP (睡眠)来解决这个问题。 第二个错误消息通过轻微调整 restartNWP()函数来修复。 尽管如此,我现在似乎遇到了上述问题,这些问题与任何返回-2005错误的套接字以及与 malloc 相关的函数不起作用有关。

    接下来我将附上我对 While 循环 和 NWP 函数所做的更改。

    感谢您迄今为止的帮助。

    /* Just the while loop from the main above */
    while(1)
    {
        if (dbg) UART_PRINT("\n\rEntering Wakeup Loop\n\r");
    
        /* Wait for SM Requests */
        ret = cdWakeupMode();
        if (ret < 0)
        {
            if (dbg) UART_PRINT("Failed to wakeup SMs. Hanging Program.");
            while(1)
            {
            }
        }
    
        /* If SMs are staying awake, keep AP up */
        putch('a'); // CH signal: entering data collection
    
        /* Wait for connection to AP */
        if(dbg)
        {
            UART_PRINT("\n\n\rReady to Receive Packets!\n\r");
            UART_PRINT("Waiting for connection...\n\r");
        }
        while (1)
        {
            ret = GET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION);
            if (ret)
            {
                /* Receive Packets */
                if(dbg)
                {
                    UART_PRINT("Connection established\n\r");
                }
                putch('c'); // CH Signal: Receiving packets
                ret = sensorNetDataRecv();
    
                /* Return Message */
                if(dbg) UART_PRINT("\n\rDone Collecting Data. Returning to Request Polling\n");
    
                /* Reset NWP */
                sleep(3);
                sl_Stop(0);
                sleep(3);
                startupNWP();
    
                /* Reset Memory */
                wakeup_count = 0;
                wakeup_flag = 0;
                sem_post(&pollSem);
                break;
            }
        }
    }
    
    /* NWP Function */
    void startupNWP(void)
    {
        int ret;
    
        /* Turn NWP on */
        ret = sl_Start(0, 0, 0);
        if(ret < 0)
        {
            /* Handle Error */
            UART_PRINT("sl_start failed - %d\n", ret);
        }
    
        /* sl_Start returns on success the role that device started on */
        app_CB.Role =ret;
    
        /* Unregister mDNS services */
        ret = sl_NetAppMDNSUnRegisterService(0, 0, 0);
        if(ret < 0)
        {
            /* Handle Error */
            UART_PRINT("sl_NetAppMDNSUnRegisterService failed - %d\n", ret);
        }
    }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    2005错误指向“SL_API_ABorted”。 您是从同一个任务还是多个任务中睡眠? 查找硬件或软件中的冲突。 我会尝试简化您的问题。 删除 LPM 功能,只需关注正确传输/接收数据。  

    如果您的分配器出现故障,是否确定您已设置了大小,并且没有超过该值?  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    我今天 上午刚刚解决了这个问题。 结果,malloc()没有失败,或者-2005错误与前面看到的驱动程序中止消息有关。

    我最初是在网络终端示例如何处理这些过程之后,对发送和接收函数建模的:动态分配发送和接收结构。 事实证明,这在某种程度上导致在事件处理程序内部调用 malloc()时失败,但仅在数据收集的第二个循环上调用。

    在找到原因之前,我确实使用了 MSP_EXP432P401R_TIRTOS.cmd 中声明的堆大小,其中将其设置为0x8000。

    感谢您的建议,即启动此修复程序。 我学到了很多关于 NWP 操作的知识,以及我的团队应该如何使用与之相切的 LPM 向前迈进。

    格雷格