微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > CC3200 在使用文件读写时,当WIFI没有连接成功的时候会一直处于_SlNonOsMainLoopTask中

CC3200 在使用文件读写时,当WIFI没有连接成功的时候会一直处于_SlNonOsMainLoopTask中

时间:10-02 整理:3721RD 点击:

板子已经通过smartLink配置成功

//
// Device connect ap
//
deviceConnectWlan();


DeviceDefaultConfig(); 

while (1)
{
    _SlNonOsMainLoopTask();
}

如果我先连接WIFI ,在进行读写文件,就没问题;

DeviceDefaultConfig(); 

//
// Device connect ap
//
deviceConnectWlan();

如果我先读写文件, 在调用fs_open之后,就会一直处于_SlNonOsMainLoopTask函数中;

void main()
{

    //
    // Board Initialization
    //
    BoardInit();

    //
    // Initialize the uDMA
    //
    UDMAInit();

    //
    // Configure the pinmux settings for the peripherals exercised
    //
    PinMuxConfig();

    //
    // Configuring UART
    //
    InitTerm();

    //
    // Display banner
    //
    DisplayBanner(APPLICATION_NAME);
	
	DeviceDefaultConfig();	
	
	//
    // Device connect ap
    //
	//deviceConnectWlan();

		

	
    while (1)
    {
        _SlNonOsMainLoopTask();
    }
}

//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************



int deviceConnectWlan( void )
{
      long lRetVal = -1;

      InitializeAppVariables();

    //lRetVal = ConfigureSimpleLinkToDefaultState();

    if(lRetVal < 0)
    {
      if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
         UART_PRINT("Failed to configure the device in its default state \n\r");

     // ASSERT_ON_ERROR(DEVICE_DEFAULT_ERROR);
    }

    UART_PRINT("Device is configured in default state \n\r");


    lRetVal = sl_Start(0, 0, 0);
    if (lRetVal < 0)
    {
        UART_PRINT("Failed to start the device \n\r");
        ASSERT_ON_ERROR(DEVICE_START_ERROR);
    }

    UART_PRINT("Device started as STATION \n\r");


    UART_PRINT("Connecting to AP: %s ...\r\n",SSID_NAME);

    //lRetVal = WlanConnect();
    if(lRetVal < 0)
    {
        UART_PRINT("Connection to AP failed \n\r");
        ASSERT_ON_ERROR(DEVICE_CONNECT_ERROR);
    }

		// Wait for WLAN Event
    while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus)))
    {
        _SlNonOsMainLoopTask();
    }
    
	
    UART_PRINT("Connected to AP: %s \n\r",SSID_NAME);

    UART_PRINT("Device IP: %d.%d.%d.%d\n\r\n\r",
                      SL_IPV4_BYTE(g_ulIpAddr,3),
                      SL_IPV4_BYTE(g_ulIpAddr,2),
                      SL_IPV4_BYTE(g_ulIpAddr,1),
                      SL_IPV4_BYTE(g_ulIpAddr,0));
	
	return SUCCESS;
	
}


long DeviceDefaultConfig( void )
{
  	long lRetVal = -1;
	
    //
    //  create a user file
    //
    lRetVal = sl_FsOpen((unsigned char *)USER_FILE_NAME,
                FS_MODE_OPEN_CREATE(65536, \
                          _FS_FILE_OPEN_FLAG_COMMIT|_FS_FILE_PUBLIC_WRITE),
                        NULL,
                        lFileHandle);
    if(lRetVal < 0)
    {
        //
        // File may already be created
        //
        lRetVal = sl_FsClose(*lFileHandle, 0, 0, 0);
        ASSERT_ON_ERROR(lRetVal);
    }
    else
    {
        //
        // close the user file
        //
        lRetVal = sl_FsClose(*lFileHandle, 0, 0, 0);
        if (SL_RET_CODE_OK != lRetVal)
        {
            ASSERT_ON_ERROR(FILE_CLOSE_ERROR);
        }
    }
	Report("Cread file success.\r\n");
	lRetVal = sl_FsOpen((unsigned char *)USER_FILE_NAME,
                        FS_MODE_OPEN_READ, 
                        NULL,
                        lFileHandle);
    if(lRetVal < 0)
    {
        lRetVal = sl_FsClose(*lFileHandle, 0, 0, 0);
        ASSERT_ON_ERROR(FILE_OPEN_WRITE_FAILED);
    }
  
	Report("open read is success.\r\n");
	
	return SUCCESS;
}

代码如下:

文件系统是通过NWP进行读写的,在文件读写之前需要将Sl_Start()开启后才能正常操作文件系统

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top