Part Number:LAUNCHXL-CC3235SFOther Parts Discussed in Thread:CC3235SF
大家好,最近在用CC3235SF进行无线网络通信实验时,遇到了一个问题,大家帮忙看看。
调用sl_SendTo()函数进行数据采集,有时会发送失败,返回的错误码是-2005:
/* API has been aborted due to an error detected by host driver */
#define SL_API_ABORTED (-2005L)
此时自动调用了sl_Close()函数,关闭了socket。
之后如果要继续进行数据传输,应该怎么做呢。
我做了以下实验:
1)调用sl_WlanDisconnect()函数断开网络,再重新联网。
但是调用sl_WlanDisconnect()函数时,总是失败,我想问一下为什么会失败呢?
2)不断网,重新创建socket进行数据传输,但是在重新创建socket时,
在UDPClient()函数中,下面这行代码:
sock = sl_Socket(sa->sa_family,SL_SOCK_DGRAM, 0);
一直失败,我研究了挺长时间也没整明白,
哪位遇到过这方面的问题,希望能帮助解答一下,谢谢!
Galaxy Yue:
您好,
1.有没有考虑过内存溢出的情况
在sl_Close()函数逐步调试一下,查看有没有堆栈溢出的情况
您先判断一下,我们再定位其他原因
2.您的代码是否改动?如果未改动,请将例程路径说一下;如果改动,麻烦您把代码贴上来,感谢您的配合。这将更好的解决问题。
,
chongtao yuan:
您好,整个工程的base是network_terminal这个demo。
其中做了几处修改:
1)在network_terminal.c的mainThread函数中,做了如下修改:
/* Display Network Terminal API commands */ showAvailableCmd();//connect network. RetVal = networkConnect();Semaphore_Params sema_sampletimer_Params_daq; Semaphore_Params_init(&sema_sampletimer_Params_daq); Semaphore_construct(&sema_sampletimer_struct_daq, 1, &sema_sampletimer_Params_daq); sema_sampletimer_Handle_daq = Semaphore_handle(&sema_sampletimer_struct_daq);//Create DAQ task. Task_Params task_daq_params; Task_Params_init(&task_daq_params); task_daq_params.stackSize = DAQTASKSTACKSIZE; task_daq_params.stack = &task_daq_rx_Stack; task_daq_params.priority = 1; Task_construct(&task_daq_Struct, (Task_FuncPtr)task_daq_Send_Fxn, &task_daq_params, NULL);Timer_Handle Sample_Timer_handle_DAQ; Timer_Params Sample_Timer_params_DAQ;// Initialize Timer parameters Timer_Params_init(&Sample_Timer_params_DAQ); Sample_Timer_params_DAQ.periodUnits = Timer_PERIOD_HZ; Sample_Timer_params_DAQ.period = 2000; Sample_Timer_params_DAQ.timerMode = Timer_CONTINUOUS_CALLBACK; Sample_Timer_params_DAQ.timerCallback = Sample_Timer_Callback_DAQ;Sample_Timer_handle_DAQ = Timer_open(CONFIG_TIMER_2, &Sample_Timer_params_DAQ); if (Sample_Timer_handle_DAQ == NULL) { // Timer_open() failed while (1); }int32_t begin_DAQ; begin_DAQ = Timer_start(Sample_Timer_handle_DAQ); if (begin_DAQ == Timer_STATUS_ERROR) { while (1); }/* * Calling UART handling method which serves as the application main loop. * Note that this function doesn't return. */ /* RetVal = cmd_prompt(NULL);if(RetVal) { while(1) { ; } } */return(0);}此外,在文件中追加了以下两个函数:
void Sample_Timer_Callback_DAQ(Timer_Handle myHandle, int_fast16_t send) { int ret = 0;Semaphore_post(sema_sampletimer_Handle_daq);if(errFlg == 0) { count1++;if(count1==10) { count2=10; count1 = 0; } } else { ret = sl_WlanDisconnect(); gSocket = Connect_to_PC();errFlg = 0;} }void task_daq_Send_Fxn(UArg arg0, UArg arg1) { UInt32 time1, time2; int ret = -1;gSocket = Connect_to_PC();for(;;) { if(errFlg == 0) { if(count2==10) { int32_t sock = 0 ,st; app_CB.gDataBuffer.nwData[3]++;time1 = Clock_getTicks(); st = Send_UDP_Data_to_PC(gSocket); if(st < 0) { errFlg = 1; UART_PRINT("\n\r errFlg : %d \n\r ", errFlg);}sendtimes++; if(sendtimes > 10) { errFlg = 1; UART_PRINT("\n\r sendtimes > 10 %d \n\r", sendtimes); }time2 = Clock_getTicks(); if(app_CB.gDataBuffer.nwData[3]==255) { app_CB.gDataBuffer.nwData[2]++; } count2=0; } } }}其中,networkConnect()函数就是网络连接,
Connect_to_PC()函数是连接UDP,Send_UDP_Data_to_PC(gSocket)就是调用sl_SendTo()进行数据发送,
这三个函数是我自己提取出来的,主要功能与Demo本身没什么变化,就不提供了。
麻烦帮忙看一下,谢谢。
,
Galaxy Yue:
1.目前认为有另一个线程调用 SimpleLink API的可能性,您需要自检一下是否存在另一个线程调用 SimpleLink API的现象。
2.您可以看一下NWP指南,收集NWP日志观察一下 在20.1章节
www.ti.com/…/swru455m.pdf