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.

loop at nonos.c transceiver mode CC3200

Other Parts Discussed in Thread: CC3200

Hi,

I am modifying the transceiver_mode example. I have 2 tasks with different priority. The task with priority 2 initializes the board and configures it, this task ends properly and there are no loops in it. The task with priority 1 has an infinite loop where I:

* Read frames in the transceiver mode

* if (memcmp(&(buffer[8]),RawData_Ping,122)==0)

       - A frame is sent in the transceiver mode

The program runs as expected, but after an arbitrary amount of time it stops, without any error or message either in the console or the UART. It seems that there are no problems with memory neither. When I pause the code, it directs me to different parts in the file "nonos.c". 

What could be causing this behavior? a power management policy? I need the system to be working indefinitely, until I manually reset it. Thanks!

  • Hi Fernando,

    If you are using RTOS with simplelink drive then nonos.c shouldn't be used at all. Can you check and make sure that you are using the library compiled for OS environment. For CCS it should be available under <cc3200-sdk>/simplelink/ccs/OS  directory.

    Regards,

    Ankur

  • Hi Ankur,

    I included the simplelink.a, that is under <cc3200-sdk>/simplelink/ccs/OS  directory. Is this what you mean? Note below that <cc3200-sdk>/simplelink/ccs/NON_OS/simplelink.a is also included, if I delete it I get errors regarding _SlNonOsMainLoopTask. In the code I have twice:

    #ifndef SL_PLATFORM_MULTI_THREADED
    _SlNonOsMainLoopTask();
    #endif

    This is part of the Transceiver_mode example, so I don´t modify that. But leave <cc3200-sdk>/simplelink/ccs/NON_OS/simplelink.a included.

    Maybe I have a mix of OS and NON_OS configuration. The current configuration is as follows:

    //USE_TIRTOS;

    //USE_FREERTOS;

    ...

    Compiler include options

    Linker File Search Path

    CCS Build Dependencies

    Note that ti_rtos_config is a project reference

    Still, the program seems to run properly initially, but suddenly the proper behavior stops. If I pause the debugging session, I just get:

    Can't find a source file at "D:/CC32xx/SDK_0.5.2/simplelink/source/nonos.c"
    Locate the file or edit the source lookup path to include its location.

    I am not sure if I have the proper operating system configuration.

    Cheers,

    Fernando

  • Hi Fernando,

    You shouldn't use Non-OS and OS libraries simultaneously.

    I suggest you to check the SDK example using the RTOS as a reference. You can also use exiting RTOS example as base and start modifying it for your application.

    When using the OS environment, SL_PLATFORM_MULTI_THREADED should be defined in project properties. Since you are using TI-RTOS you should also define USE_TIRTOS in project property.

    Regards,

    Ankur

  • Hi,

    To avoid any issues with operating systems, I took the "transceiver mode" example and slightly modified the main file as in the attachment.

    //*****************************************************************************
    //
    // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 
    // 
    // 
    //  Redistribution and use in source and binary forms, with or without 
    //  modification, are permitted provided that the following conditions 
    //  are met:
    //
    //    Redistributions of source code must retain the above copyright 
    //    notice, this list of conditions and the following disclaimer.
    //
    //    Redistributions in binary form must reproduce the above copyright
    //    notice, this list of conditions and the following disclaimer in the 
    //    documentation and/or other materials provided with the   
    //    distribution.
    //
    //    Neither the name of Texas Instruments Incorporated nor the names of
    //    its contributors may be used to endorse or promote products derived
    //    from this software without specific prior written permission.
    //
    //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // Application Name     -   Transceiver mode
    // Application Overview -   This is a sample application demonstrating the
    //                          use of raw sockets on a CC3200 device.Based on the
    //                          user input, the application either transmits data
    //                          on the channel requested or collects Rx statistics
    //                          on the channel.
    //
    // Application Details  -
    // docs\examples\CC32xx_Transceiver_Mode.pdf
    // or
    // http://processors.wiki.ti.com/index.php/CC32xx_Transceiver_Mode
    //
    //*****************************************************************************
    
    
    //*****************************************************************************
    //
    //! \addtogroup transceiver
    //! @{
    //
    //*****************************************************************************
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    // Simplelink includes
    #include "simplelink.h"
    
    //Driverlib includes
    #include "hw_types.h"
    #include "hw_ints.h"
    #include "interrupt.h"
    #include "utils.h"
    #include "uart.h"
    #include "hw_memmap.h"
    #include "prcm.h"
    #include "rom.h"
    #include "rom_map.h"
    
    //Common interface includes
    #include "pinmux.h"
    #ifndef NOTERM
    #include "uart_if.h"
    #endif
    
    #ifdef NOTERM
    #define UART_PRINT(x,...)
    #else
    #define UART_PRINT Report
    #endif
    
    #define APPLICATION_NAME        "TRANSCEIVER_MODE STA 1"
    #define APPLICATION_VERSION     "1.0.0"
    #define SUCCESS                 0
    
    
    #define SSID_LEN_MAX            (32)
    #define BSSID_LEN_MAX           (6)
    
    #define SL_STOP_TIMEOUT          30
    #define UNUSED(x)               x = x
    #define CLR_STATUS_BIT_ALL(status_variable)  (status_variable = 0)
    
    
    #define PREAMBLE            1        /* Preamble value 0- short, 1- long */
    #define CPU_CYCLES_1MSEC (80*1000)
    
    // For STA 1
    int iSoc; // Socket
    int iChannel = 1;
    SlRateIndex_e rate = RATE_54M; //13
    int iTxPowerLevel = 0; // 0 for max Tx power
    #define BUFFER_SIZE  131
    char RawData_1[] = {0x88,0x01,0x75,0x00,0x88,0x5a,0x92,0xd9,0x4c,0x8f,0x78,0xa5,0x04,0x10,0xe3,0x6e,0xc4,0x34,0x6b,0x9a,0xdf,0x80,0x10,0x75,0x00,0x00,0xaa,0xaa,0x03,0x00,0x00,0x00,0x08,0x00,0x45,0x00,0x03,0xfd,0x07,0x51,0x00,0x00,0x80,0xff,0xb6,0x85,0x0a,0x64,0x63,0x65,0x0a,0x64,0xff,0xfe,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x00,0x5b,0x58,0xac,0x14};
    
    // Loop forever, user can change it as per application's requirement
    #define LOOP_FOREVER(line_number) \
                {\
                    while(1); \
                }
    
    // check the error code and handle it
    #define ASSERT_ON_ERROR(line_number, error_code) \
                {\
                    if (error_code < 0) return error_code;\
                }
    
    //Status bits - These are used to set/reset the corresponding bits in
    // given variable
    typedef enum{
        STATUS_BIT_CONNECTION =  0, // If this bit is Set SimpleLink device is
                                    // connected to the AP
    
        STATUS_BIT_IP_AQUIRED,       // If this bit is Set SimpleLink device has
                                     // acquired IP
    
    }e_StatusBits;
    
    
    // Application specific status/error codes
    typedef enum{
        // Choosing -0x7D0 to avoid overlap w/ host-driver's error codes
        LAN_CONNECTION_FAILED = -0x7D0,
        DEVICE_NOT_IN_STATION_MODE = LAN_CONNECTION_FAILED - 1,
        STATUS_CODE_MAX = -0xBB8
    }e_AppStatusCodes;
    
    #define SET_STATUS_BIT(status_variable, bit)  status_variable |= (1<<(bit))
    #define CLR_STATUS_BIT(status_variable, bit)  status_variable &= ~(1<<(bit))
    #define GET_STATUS_BIT(status_variable, bit)  (0 != (status_variable & (1<<(bit))))
    
    #define IS_CONNECTED(status_variable)         GET_STATUS_BIT(status_variable, \
                                                           STATUS_BIT_CONNECTION)
    #define IS_IP_ACQUIRED(status_variable)       GET_STATUS_BIT(status_variable, \
                                                           STATUS_BIT_IP_AQUIRED)
    
    typedef struct
    {
        int choice;
        int channel;
        int packets;
        SlRateIndex_e rate;
        int Txpower;
    }UserIn;
    
    //
    // GLOBAL VARIABLES -- Start
    //
    unsigned long  g_ulStatus = 0;//SimpleLink Status
    unsigned long  g_ulGatewayIP = 0; //Network Gateway IP address
    unsigned char  g_ucConnectionSSID[SSID_LEN_MAX+1]; //Connection SSID
    unsigned char  g_ucConnectionBSSID[BSSID_LEN_MAX]; //Connection BSSID
    
    // Beacon from the Ciscosb AP as seen in Wireshark -26B from the beginning. The last 4 Bytes are used to allocate the FCS that is added at the Tx in the transceiver mode.
    char RawData_Ping[] = {0x80,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x88,0x5a,0x92,0xd9,0x4c,0x8f,0x88,0x5a,0x92,0xd9,0x4c,0x8f,0x90,0x42,0x80,0x5d,0x91,0x06,0x00,0x00,0x00,0x00,0x64,0x00,0x21,0x04,0x00,0x07,0x63,0x69,0x73,0x63,0x6f,0x73,0x62,0x01,0x08,0x82,0x84,0x8b,0x96,0x8c,0x12,0x98,0x24,0x03,0x01,0x01,0x05,0x04,0x00,0x01,0x00,0x00,0x2a,0x01,0x00,0x32,0x04,0xb0,0x48,0x60,0x6c,0xdd,0x18,0x00,0x50,0xf2,0x02,0x01,0x01,0x84,0x00,0x03,0xa4,0x00,0x00,0x27,0xa4,0x00,0x00,0x42,0x43,0x5e,0x00,0x62,0x32,0x2f,0x00,0xdd,0x09,0x00,0x03,0x7f,0x01,0x01,0x00,0x00,0xff,0x7f,0xdd,0x0a,0x00,0x03,0x7f,0x04,0x01,0x00,0x06,0x00,0x40,0x00,0x08,0xc9,0xf0,0x4f};
    
    //char RawData_Ping[] = {
                       /*---- wlan header start -----*/
    //                   0x88,                                /* version , type sub type */
      //                 0x02,                                /* Frame control flag */
        //               0x2C, 0x00,
          //             0x00, 0x23, 0x75, 0x55,0x55, 0x55,   /* destination */
            //           0x00, 0x22, 0x75, 0x55,0x55, 0x55,   /* bssid */
              //         0x08, 0x00, 0x28, 0x19,0x02, 0x85,   /* source */
                //       0x80, 0x42, 0x00, 0x00,
                  //     0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, /* LLC */
                       /*---- ip header start -----*/
                    //   0x45, 0x00, 0x00, 0x54, 0x96, 0xA1, 0x00, 0x00, 0x40, 0x01,
    //                   0x57, 0xFA,                          /* checksum */
      //                 0xc0, 0xa8, 0x01, 0x64,              /* src ip */
        //               0xc0, 0xa8, 0x01, 0x02,              /* dest ip  */
                       /* payload - ping/icmp */
          //             0x08, 0x00, 0xA5, 0x51,
            //           0x5E, 0x18, 0x00, 0x00, 0x41, 0x08, 0xBB, 0x8D, 0x00, 0x00, 0x00, 0x00,
              //         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                //       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                  //     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    //   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                      // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    //                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      //                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        //               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
          //             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            //           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
              //         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                //       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                  //     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    //   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                      // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    //                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      //                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        //               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
          //             0x00, 0x00, 0x00, 0x00};
    #if defined(ccs)
    extern void (* const g_pfnVectors[])(void);
    #endif
    #if defined(ewarm)
    extern uVectorEntry __vector_table;
    #endif
    
    //
    // GLOBAL VARIABLES -- End
    //
    
    //****************************************************************************
    //                      LOCAL FUNCTION PROTOTYPES
    //****************************************************************************
    static UserIn UserInput();
    static int Tx_continuous(int iChannel,SlRateIndex_e rate,int iNumberOfPackets,int iTxPowerLevel,long dIntervalMiliSec);
    static int RxStatisticsCollect();
    static void DisplayBanner(char * AppName);
    static void BoardInit(void);
    
    
    
    //*****************************************************************************
    // SimpleLink Asynchronous Event Handlers -- Start
    //*****************************************************************************
    
    
    //*****************************************************************************
    //
    //! \brief The Function Handles WLAN Events
    //!
    //! \param[in]  pWlanEvent - Pointer to WLAN Event Info
    //!
    //! \return None
    //!
    //*****************************************************************************
    void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent)
    {
        switch(pWlanEvent->Event)
        {
            case SL_WLAN_CONNECT_EVENT:
            {
                SET_STATUS_BIT(g_ulStatus, STATUS_BIT_CONNECTION);
    
                //
                // Information about the connected AP (like name, MAC etc) will be
                // available in 'sl_protocol_wlanConnectAsyncResponse_t' - Applications
                // can use it if required
                //
                //  sl_protocol_wlanConnectAsyncResponse_t *pEventData = NULL;
                // pEventData = &pWlanEvent->EventData.STAandP2PModeWlanConnected;
                //
    
                // Copy new connection SSID and BSSID to global parameters
                memcpy(g_ucConnectionSSID,pWlanEvent->EventData.
                       STAandP2PModeWlanConnected.ssid_name,
                       pWlanEvent->EventData.STAandP2PModeWlanConnected.ssid_len);
                memcpy(g_ucConnectionBSSID,
                       pWlanEvent->EventData.STAandP2PModeWlanConnected.bssid,
                       SL_BSSID_LENGTH);
    
                UART_PRINT("[WLAN EVENT] STA Connected to the AP: %s , BSSID: %x:%x:%x:%x:%x:%x\n\r",
                          g_ucConnectionSSID,g_ucConnectionBSSID[0],
                          g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
                          g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
                          g_ucConnectionBSSID[5]);
            }
            break;
    
            case SL_WLAN_DISCONNECT_EVENT:
            {
                sl_protocol_wlanConnectAsyncResponse_t*  pEventData = 0; //NULL
    
                CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_CONNECTION);
                CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_AQUIRED);
    
                pEventData = &pWlanEvent->EventData.STAandP2PModeDisconnected;
    
                // If the user has initiated 'Disconnect' request,
                //'reason_code' is SL_USER_INITIATED_DISCONNECTION
                if(SL_USER_INITIATED_DISCONNECTION == pEventData->reason_code)
                {
                    UART_PRINT("[WLAN EVENT]Device disconnected from the AP: %s,"
                    		   " BSSID: %x:%x:%x:%x:%x:%x on application's"
                    		   " request \n\r",
                               g_ucConnectionSSID,g_ucConnectionBSSID[0],
                               g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
                               g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
                               g_ucConnectionBSSID[5]);
                }
                else
                {
                    UART_PRINT("[WLAN ERROR]Device disconnected from the AP AP: %s,"
                    		   " BSSID: %x:%x:%x:%x:%x:%x on an ERROR..!! \n\r",
                               g_ucConnectionSSID,g_ucConnectionBSSID[0],
                               g_ucConnectionBSSID[1],g_ucConnectionBSSID[2],
                               g_ucConnectionBSSID[3],g_ucConnectionBSSID[4],
                               g_ucConnectionBSSID[5]);
                }
                memset(g_ucConnectionSSID,0,sizeof(g_ucConnectionSSID));
                memset(g_ucConnectionBSSID,0,sizeof(g_ucConnectionBSSID));
            }
            break;
    
            default:
            {
                UART_PRINT("[WLAN EVENT] Unexpected event [0x%x]\n\r",
                           pWlanEvent->Event);
            }
            break;
        }
    }
    
    //*****************************************************************************
    //
    //! \brief This function handles network events such as IP acquisition, IP
    //!           leased, IP released etc.
    //!
    //! \param[in]  pNetAppEvent - Pointer to NetApp Event Info
    //!
    //! \return None
    //!
    //*****************************************************************************
    void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
    {
        switch(pNetAppEvent->Event)
        {
            case SL_NETAPP_IPV4_ACQUIRED:
            {
                SlIpV4AcquiredAsync_t *pEventData = 0; //NULL
    
                SET_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_AQUIRED);
    
                //Ip Acquired Event Data
                pEventData = &pNetAppEvent->EventData.ipAcquiredV4;
    
                //Gateway IP address
                g_ulGatewayIP = pEventData->gateway;
    
                UART_PRINT("[NETAPP EVENT] IP Acquired: IP=%d.%d.%d.%d , Gateway=%d.%d.%d.%d\n\r",
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,3),
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,2),
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,1),
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,0),
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,3),
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,2),
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,1),
                SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,0));
            }
            break;
    
            default:
            {
                UART_PRINT("[NETAPP EVENT] Unexpected event [0x%x] \n\r",
                           pNetAppEvent->Event);
            }
            break;
        }
    }
    
    
    //*****************************************************************************
    //
    //! \brief This function handles HTTP server events
    //!
    //! \param[in]  pServerEvent - Contains the relevant event information
    //! \param[in]    pServerResponse - Should be filled by the user with the
    //!                                      relevant response information
    //!
    //! \return None
    //!
    //****************************************************************************
    void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pHttpEvent,
                                      SlHttpServerResponse_t *pHttpResponse)
    {
        // Unused in this application
    }
    
    //*****************************************************************************
    //
    //! \brief This function handles General Events
    //!
    //! \param[in]     pDevEvent - Pointer to General Event Info
    //!
    //! \return None
    //!
    //*****************************************************************************
    void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *pDevEvent)
    {
        //
        // Most of the general errors are not FATAL are are to be handled
        // appropriately by the application
        //
        UART_PRINT("[GENERAL EVENT] - ID=[%d] Sender=[%d]\n\n",
                   pDevEvent->EventData.deviceEvent.status,
                   pDevEvent->EventData.deviceEvent.sender);
    }
    
    
    //*****************************************************************************
    //
    //! This function handles socket events indication
    //!
    //! \param[in]      pSock - Pointer to Socket Event Info
    //!
    //! \return None
    //!
    //*****************************************************************************
    void SimpleLinkSockEventHandler(SlSockEvent_t *pSock)
    {
        //
        // This application doesn't work w/ socket - Events are not expected
        //
           
    }
    
    //*****************************************************************************
    // SimpleLink Asynchronous Event Handlers -- End
    //*****************************************************************************
    
    
    //*****************************************************************************
    //
    //! \brief This function initializes the application variables
    //!
    //! \param    None
    //!
    //! \return None
    //!
    //*****************************************************************************
    static void InitializeAppVariables()
    {
        g_ulStatus = 0;
        g_ulGatewayIP = 0;
        memset(g_ucConnectionSSID,0,sizeof(g_ucConnectionSSID));
        memset(g_ucConnectionBSSID,0,sizeof(g_ucConnectionBSSID));
    }
    
    //*****************************************************************************
    //! \brief This function puts the device in its default state. It:
    //!           - Set the mode to STATION
    //!           - Configures connection policy to Auto and AutoSmartConfig
    //!           - Deletes all the stored profiles
    //!           - Enables DHCP
    //!           - Disables Scan policy
    //!           - Sets Tx power to maximum
    //!           - Sets power policy to normal
    //!           - TBD - Unregister mDNS services
    //!
    //! \param   none
    //! \return  On success, zero is returned. On error, negative is returned
    //*****************************************************************************
    
    static long ConfigureSimpleLinkToDefaultState()
    {
        SlVersionFull   ver = {0};
    
        unsigned char ucVal = 1;
        unsigned char ucConfigOpt = 0;
        unsigned char ucConfigLen = 0;
        unsigned char ucPower = 0;
    
        long lRetVal = -1;
        long lMode = -1;
    
        lMode = sl_Start(0, 0, 0);
        ASSERT_ON_ERROR(__LINE__, lMode);
    
        // Get the device's version-information
        ucConfigOpt = SL_DEVICE_GENERAL_VERSION;
        ucConfigLen = sizeof(ver);
        lRetVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &ucConfigOpt, \
        		            &ucConfigLen, (unsigned char *)(&ver));
    
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        UART_PRINT("Host Driver Version: %s\n\r",SL_DRIVER_VERSION);
        UART_PRINT("Build Version %d.%d.%d.%d.31.%d.%d.%d.%d.%d.%d.%d.%d\n\r",
                            ver.NwpVersion[0],ver.NwpVersion[1],
                            ver.NwpVersion[2],ver.NwpVersion[3],
                            ver.ChipFwAndPhyVersion.FwVersion[0],
                            ver.ChipFwAndPhyVersion.FwVersion[1],
                            ver.ChipFwAndPhyVersion.FwVersion[2],
                            ver.ChipFwAndPhyVersion.FwVersion[3],
                            ver.ChipFwAndPhyVersion.PhyVersion[0],
                            ver.ChipFwAndPhyVersion.PhyVersion[1],
                            ver.ChipFwAndPhyVersion.PhyVersion[2],
                            ver.ChipFwAndPhyVersion.PhyVersion[3]);
    
        // Set connection policy to Auto + SmartConfig (Device's default connection
        // policy)
        lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, \
        		                   SL_CONNECTION_POLICY(1, 0, 0, 0, 1), 0, 0); //SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
    
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        // Remove all profiles
        lRetVal = sl_WlanProfileDel(0xFF);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        // If the device is not in station-mode, try putting it in staion-mode
        if (ROLE_STA != lMode)
        {
            if (ROLE_AP == lMode)
            {
                // If the device is in AP mode, we need to wait for this event
            	// before doing anything
                while(!IS_IP_ACQUIRED(g_ulStatus))
                {
    #ifndef SL_PLATFORM_MULTI_THREADED
                  _SlNonOsMainLoopTask();
    #endif
                }
            }
    
            // Switch to STA role and restart
            lRetVal = sl_WlanSetMode(ROLE_STA);
            ASSERT_ON_ERROR(__LINE__, lRetVal);
    
            lRetVal = sl_Stop(SL_STOP_TIMEOUT);
            ASSERT_ON_ERROR(__LINE__, lRetVal);
    
            lRetVal = sl_Start(0, 0, 0);
            ASSERT_ON_ERROR(__LINE__, lRetVal);
    
            // Check if the device is in station again
            if (ROLE_STA != lRetVal)
            {
                // We don't want to proceed if the device is not coming up
            	// in station-mode
                return DEVICE_NOT_IN_STATION_MODE;
            }
        }
    
        //
        // Device in station-mode. Disconnect previous connection if any
        // return 0 if 'Disconnected done', negative number if already disconnected
        // Wait for 'disconnection' event if 0 is returned, Ignore other
        // return-codes
        //
        lRetVal = sl_WlanDisconnect();
        if(0 == lRetVal)
        {
            // Wait
            while(IS_CONNECTED(g_ulStatus))
            {
    #ifndef SL_PLATFORM_MULTI_THREADED
                  _SlNonOsMainLoopTask();
    #endif
            }
        }
    
        // Enable DHCP client
        lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        // Disable scan
        ucConfigOpt = SL_SCAN_POLICY(0);
        lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, 0, 0); //lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, NULL, 0);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        // Set Tx power level for station mode
        // Number between 0-15, as dB offset from max power - 0 will set
        // maximum power
        ucPower = 0;
        lRetVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&ucPower);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        // Set PM policy to normal
        lRetVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, 0, 0); //lRetVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        lRetVal = sl_Stop(SL_STOP_TIMEOUT);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        InitializeAppVariables();
    
        return lRetVal; // Success
    }
    
    //*****************************************************************************
    //
    //! Application startup display on UART
    //!
    //! \param  AppName
    //!
    //! \return none
    //!
    //*****************************************************************************
    static void DisplayBanner(char * AppName)
    {
    
      Report("\n\n\n\r");
      Report("\t\t *************************************************\n\r");
      Report("\t\t\t CC3200 %s Application       \n\r", AppName);
      Report("\t\t *************************************************\n\r");
      Report("\n\n\n\r");
    }
    
    
    //*****************************************************************************
    //
    //! Board Initialization & Configuration
    //!
    //! \param  None
    //!
    //! \return None
    //
    //*****************************************************************************
    static void BoardInit(void)
    {
    /* In case of TI-RTOS vector table is initialize by OS itself */
    #ifndef USE_TIRTOS
      //
      // Set vector table base
      //
    #if defined(ccs)
        MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
    #endif
    #if defined(ewarm)
    	MAP_IntVTableBaseSet((unsigned long)&__vector_table);
    #endif
    #endif
      //
      // Enable Processor
      //
      MAP_IntMasterEnable();
      MAP_IntEnable(FAULT_SYSTICK);
    
      PRCMCC3200MCUInit();
    }
    
    
    
    //*****************************************************************************
    //
    //! UserInput
    //!
    //! This function
    //!		1. Function for reading the user input.
    //!
    //! \return none
    //
    //*****************************************************************************
    static UserIn UserInput()
    {
        UserIn User;
        char acCmdStore[512];
        int iRetVal;
        int iRightInput = 0;
    
    
        do
        {
            UART_PRINT("\r\nOptions:\r\n1. Send packets.\r\n2. Collect statistics about received packets.\r\n");
            UART_PRINT("Enter the option to use: ");
            iRetVal = GetCmd(acCmdStore, sizeof(acCmdStore));
            if(iRetVal == 0)
            {
              //
              // No input. Just an enter pressed probably. Display a prompt.
              //
              UART_PRINT("\n\n\rEnter Valid Input.");
              iRightInput = 0;
            }
            else
            {
              User.choice = (int)strtoul(acCmdStore,0,10);
              if(User.choice != 1 && User.choice != 2)
              {
                UART_PRINT("\n\n\rWrong Input");
                iRightInput = 0;
              }
              else
              {
                iRightInput = 1;
              }
            }
            UART_PRINT("\n\r");
        }while(!iRightInput);
    
    
    
        if (User.choice == 1)
        {
            /*channel*/
            do
            {
                UART_PRINT("Enter the channel to use[1:13]: ");
                iRetVal = GetCmd(acCmdStore, sizeof(acCmdStore));
                if(iRetVal == 0)
                {
                  //
                  // No input. Just an enter pressed probably. Display a prompt.
                  //
                  UART_PRINT("\n\rEnter Valid Input.");
                  iRightInput = 0;
                }
                else
                {
                  User.channel = (int)strtoul(acCmdStore,0,10);
                  if(User.channel <= 0 || User.channel > 13)
                  {
                    UART_PRINT("\n\rWrong Input");
                    iRightInput = 0;
                  }
                  else
                  {
                    iRightInput = 1;
                  }
                }
    
                UART_PRINT("\r\n");
            }while(!iRightInput);
    
            /*Number of packets*/
            do
            {
                UART_PRINT("Enter the number of packets to send : ");
                iRetVal = GetCmd(acCmdStore, sizeof(acCmdStore));
                if(iRetVal == 0)
                {
                  //
                  // No input. Just an enter pressed probably. Display a prompt.
                  //
                  UART_PRINT("\n\rEnter Valid Input.");
                  iRightInput = 0;
                }
                else
                {
                  User.packets = (int)strtoul(acCmdStore,0,10);
                  if(User.packets <= 0 && User.packets > 65535)
                  {
                    UART_PRINT("\n\rWrong Input");
                    iRightInput = 0;
                  }
                  else
                  {
                    iRightInput = 1;
                  }
                }
                UART_PRINT("\r\n");
            }while(!iRightInput);
    
            /*Rate*/
            do
            {
                UART_PRINT("Enter the rate: ");
                iRetVal = GetCmd(acCmdStore, sizeof(acCmdStore));
                if(iRetVal == 0)
                {
                    //
                    // No input. Just an enter pressed probably. Display a prompt.
                    //
                    UART_PRINT("\n\rEnter Valid Input.");
                    iRightInput = 0;
                }
                else
                {
                    User.rate = (SlRateIndex_e)strtoul(acCmdStore,0,10);
                    if(User.rate < RATE_1M || User.rate > RATE_MCS_7)
                    {
                        UART_PRINT("\n\rWrong Input");
                        iRightInput = 0;
                    }
                    else
                    {
                        iRightInput = 1;
                    }
                }
    
                UART_PRINT("\r\n");
            }while(!iRightInput);
            /* Tx Power level */
            do
            {
                UART_PRINT("Enter the Tx power[0:15]: ");
                iRetVal = GetCmd(acCmdStore, sizeof(acCmdStore));
                if(iRetVal == 0)
                {
                    //
                    // No input. Just an enter pressed probably. Display a prompt.
                    //
                    UART_PRINT("\n\rEnter Valid Input.");
                    iRightInput = 0;
                }
                else
                {
                    User.Txpower = (int)strtoul(acCmdStore,0,10);
                    if(User.Txpower < 0 || User.Txpower > 15)
                    {
                        UART_PRINT("\n\rWrong Input");
                        iRightInput = 0;
                    }
                    else
                    {
                        iRightInput = 1;
                    }
                }
    
                UART_PRINT("\r\n");
            }while(!iRightInput);
        }
    
        return User;
    }
    
    
    
    
    //*****************************************************************************
    //
    //! Tx_continuous
    //!
    //! This function
    //!		1. Function for sending out pinging data on the
    //!                channel given by the user.
    //!
    //! \return none
    //
    //*****************************************************************************
    static int Tx_continuous(int iChannel,SlRateIndex_e rate,int iNumberOfPackets,int iTxPowerLevel,long dIntervalMiliSec)
    {
        int iSoc;
        long lRetVal = -1;
        long ulIndex;
    
        iSoc = sl_Socket(SL_AF_RF,SL_SOCK_RAW,iChannel);
        if(iSoc < 0)
        {
    	  UART_PRINT("Failed to create socket\r\n");
    	  ASSERT_ON_ERROR(__LINE__, iSoc);
        }
    
        UART_PRINT("Transmitting data...\r\n");
        for(ulIndex = 0 ; ulIndex < iNumberOfPackets ; ulIndex++)
        {
        	lRetVal = sl_Send(iSoc,RawData_Ping,sizeof(RawData_Ping),SL_RAW_RF_TX_PARAMS(iChannel,  rate, iTxPowerLevel, PREAMBLE));
            if(lRetVal < 0)
            {
            	UART_PRINT("Transmition Failed!\r\n");
            	sl_Close(iSoc);
            	ASSERT_ON_ERROR(__LINE__, lRetVal);
            }
            //Sleep(dIntervalMiliSec);
            MAP_UtilsDelay(4000000);
        }
    
        lRetVal = sl_Close(iSoc);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
        UART_PRINT("Transmission complete.\r\n");
        return SUCCESS;
    }
    
    //*****************************************************************************
    //
    //! RxStatisticsCollect
    //!
    //! This function
    //!		1. Function for performing the statistics by listening on the
    //!                channel given by the user.
    //!
    //! \return none
    //
    //*****************************************************************************
    static int RxStatisticsCollect()
    {
    	int iSoc;
    	char acBuffer[1500];
    	SlGetRxStatResponse_t rxStatResp;
        //char cChar;
    	int iIndex;
        int iChannel;
        long lRetVal = -1;
        int iRightInput = 0;
        char acCmdStore[512];
        struct SlTimeval_t timeval;
    
    	timeval.tv_sec =  0;             // Seconds
    	timeval.tv_usec = 20000;         // Microseconds. 10000 microseconds resoultion
    
    
        //
        //Clear all fields to defaults
        //
        rxStatResp.ReceivedValidPacketsNumber = 0;
        rxStatResp.ReceivedFcsErrorPacketsNumber = 0;
        rxStatResp.ReceivedPlcpErrorPacketsNumber = 0;
        rxStatResp.AvarageMgMntRssi = 0;
        rxStatResp.AvarageDataCtrlRssi = 0;
        for(iIndex = 0 ; iIndex < SIZE_OF_RSSI_HISTOGRAM ; iIndex++)
    	{
    		rxStatResp.RssiHistogram[iIndex] = 0;
    	}
    	for(iIndex = 0 ; iIndex < NUM_OF_RATE_INDEXES ; iIndex++)
    	{
    		rxStatResp.RateHistogram[iIndex] = 0;
    	}
        rxStatResp.GetTimeStamp = 0;
        rxStatResp.StartTimeStamp = 0;
    
        //
        //Prompt the user for channel number
        //
        do
        {
          UART_PRINT("\n\rEnter the channel to listen[1-13]:");
          //
          // Wait to receive a character over UART
          //
          lRetVal = GetCmd(acCmdStore, sizeof(acCmdStore));
          if(lRetVal == 0)
          {
            //
            // No input. Just an enter pressed probably. Display a prompt.
            //
            UART_PRINT("\n\rEnter Valid Input.");
            iRightInput = 0;
          }
          else
          {
            iChannel = (int)strtoul(acCmdStore,0,10);
            if(iChannel <= 0 || iChannel > 13)
            {
              UART_PRINT("\n\rWrong Input");
              iRightInput = 0;
            }
            else
            {
              iRightInput = 1;
            }
          }
    
        }while(!iRightInput);
    
    
        UART_PRINT("\n\rPress any key to start collecting statistics...");
    
    	//
    	// Wait to receive a character over UART
    	//
    	MAP_UARTCharGet(CONSOLE);
    
    	//
    	//Start Rx statistics collection
    	//
    	lRetVal = sl_WlanRxStatStart();
    	ASSERT_ON_ERROR(__LINE__, lRetVal);
    
    	//
    	//Open Socket on the channel to listen
        //
        iSoc = sl_Socket(SL_AF_RF,SL_SOCK_RAW,iChannel);
        if( iSoc < 0 )
        {
          // error
          UART_PRINT("\n\rFailed to create socket...");
          ASSERT_ON_ERROR(__LINE__, iSoc);
        }
    
        lRetVal = sl_SetSockOpt(iSoc,SL_SOL_SOCKET,SL_SO_RCVTIMEO, &timeval, sizeof(timeval));    // Enable receive timeout
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        lRetVal = sl_Recv(iSoc,acBuffer,1470,0);
    
        if(lRetVal < 0)
        {
        	//error
        	UART_PRINT("\n\rFailed to get statistics data!");
        	sl_Close(iSoc);
        	ASSERT_ON_ERROR(__LINE__, lRetVal);
        }
    	UART_PRINT("\n\rPress any key to stop and display the statistics...");
    
        //
        // Wait to receive a character over UART
        //
        MAP_UARTCharGet(CONSOLE);
    
        //
        //Get the Statistics collected in this time window
        //
        lRetVal = sl_WlanRxStatGet(&rxStatResp,0);
        if(lRetVal < 0)
        {
        	//error
        	UART_PRINT("\n\rFailed to get statistics data!");
        	sl_Close(iSoc);
        	ASSERT_ON_ERROR(__LINE__, lRetVal);
        }
    
        //
        //Printing the collected statistics
        //
        UART_PRINT("\n\n\n\r\t\t=========================================== \n \
                   \r");
        UART_PRINT("\n\r\t\t\t\tRx Statistics \n\r");
        UART_PRINT("\t\t=========================================== \n\r");
    
        UART_PRINT("\n\n\rThe data sampled over %ld microsec\n\n\r",	\
                   (unsigned int)(rxStatResp.GetTimeStamp -
                                  rxStatResp.StartTimeStamp));
    
        UART_PRINT("Number of Valid Packets Received:  %d\n\r",
        						rxStatResp.ReceivedValidPacketsNumber);
    	UART_PRINT("Number of Packets Received Packets with FCS: %d\n\r",
                       rxStatResp.ReceivedFcsErrorPacketsNumber);
    	UART_PRINT("Number of Packets Received Packets with PLCP: %d\n\n\r",   \
                       rxStatResp.ReceivedPlcpErrorPacketsNumber);
    	UART_PRINT("Average Rssi for management packets: %d\
                        \n\rAverage Rssi for other packets: %d\n\r",
                       rxStatResp.AvarageMgMntRssi,rxStatResp.AvarageDataCtrlRssi);
    	for(iIndex = 0 ; iIndex < SIZE_OF_RSSI_HISTOGRAM ; iIndex++)
    	{
              UART_PRINT("Number of packets with RSSI in range %d dbm - %d dbm: %d\n\r",
                         ((-40+(-8*iIndex))),((-40+(-8*(iIndex+1)))+1),
                           rxStatResp.RssiHistogram[iIndex]);
    	}
    	UART_PRINT("\n\r");
    
        //for(iIndex = 0 ; iIndex < NUM_OF_RATE_INDEXES ; iIndex++)
    	iIndex = 0;
        {
          UART_PRINT("Number of Packets with Rate 1Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 2Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 5.5Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 11Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 6Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 9Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 12Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 18Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 24Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 36Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 48Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate 54Mbps  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_0  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_1  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_2  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_3  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_4  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_5  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_6  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
          UART_PRINT("Number of Packets with Rate MCS_7  : %d\n\r",
                     rxStatResp.RateHistogram[iIndex++]);
     	}
    
    	//
        //Stop Rx statistics collection
        //
        lRetVal = sl_WlanRxStatStop();
        ASSERT_ON_ERROR(__LINE__, lRetVal);
    
        //
        //Close the socket
        //
        lRetVal = sl_Close(iSoc);
        ASSERT_ON_ERROR(__LINE__, lRetVal);
        return SUCCESS;
    }
    
    //*****************************************************************************
    //
    //! main
    //!
    //! This function
    //!		1. Main function for the application.
    //!		2. Make sure there is no profile before activating this test.
    //!     3. This test is not optimized for current consumption at this stage.
    //!
    //! \return none
    //
    //*****************************************************************************
    
    int main()
    {
      UserIn User;
      int iFlag = 1;
      long lRetVal = -1;
      char cChar;
      unsigned char policyVal;
      //
      // Initialize Board configuration
      //
      BoardInit();
      //
      //
      //Pin muxing
      //
      PinMuxConfig();
      // Configuring UART
      //
      InitTerm();
      DisplayBanner(APPLICATION_NAME);
    
      InitializeAppVariables();
    
      //
      // Following function configure the device to default state by cleaning
      // the persistent settings stored in NVMEM (viz. connection profiles &
      // policies, power policy etc)
      //
      // Applications may choose to skip this step if the developer is sure
      // that the device is in its default state at start of applicaton
      //
      // Note that all profiles and persistent settings that were done on the
      // device will be lost
      //
      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");
    	  LOOP_FOREVER(__LINE__);
      }
    
      UART_PRINT("Device is configured in default state \n\r");
    
      CLR_STATUS_BIT_ALL(g_ulStatus);
    
      //
      // Assumption is that the device is configured in station mode already
      // and it is in its default state
      //
      lRetVal = sl_Start(0, 0, 0);
      if (lRetVal < 0 || ROLE_STA != lRetVal)
      {
    	UART_PRINT("Failed to start the device \n\r");
    	LOOP_FOREVER(__LINE__);
      }
    
      UART_PRINT("Device started as STATION \n\r");
    
      //
      // reset all network policies
      //
      lRetVal = sl_WlanPolicySet(  SL_POLICY_CONNECTION,
                      SL_CONNECTION_POLICY(0,0,0,0,0),
                      &policyVal,
                      1 /*PolicyValLen*/);
      if (lRetVal < 0)
      {
      	UART_PRINT("Failed to set policy \n\r");
      	LOOP_FOREVER(__LINE__);
      }
    
    
    
    
    
      iSoc = sl_Socket(SL_AF_RF,SL_SOCK_RAW,iChannel);
         // ASSERT_ON_ERROR(iSoc);
          UART_PRINT("Transceiver mode socket opened...\r\n");
              Report("Socket identifier: %d\r\n", iSoc);
              Report("Channel: %d\r\n", iChannel);
    
    
    	UINT8 buffer[BUFFER_SIZE] = {'\0'};
    	INT32 recievedBytes = 0;
    
    	   while (TRUE) {
    		   memset(&buffer[0], 0, sizeof(buffer));
    		   recievedBytes = sl_Recv(iSoc, buffer, BUFFER_SIZE, 0);
    		   Report("recievedBytes = %d \r\n", recievedBytes);
    
    		   // If the beacon, from the SimpleLink board as transmitted by the ciscosb AP, is received
    
    		   	   Report("memcmp(&(buffer[8]),RawData_Ping,122)= %d \r\n", memcmp(&(buffer[8]),RawData_Ping,122));
    
    		   	   if (memcmp(&(buffer[8]),RawData_Ping,122)==0)
    		   	   {
    		   		   // Tx just after the beacon is received
    		   		   lRetVal = sl_Send(iSoc,RawData_1,sizeof(RawData_1),\
    		   		                                      SL_RAW_RF_TX_PARAMS(iChannel,  rate, iTxPowerLevel, PREAMBLE));
    		   		   Report("lRetVal = %d \r\n", lRetVal);
    		   	   }
    	   }
    
    
    
    
    /*
      while (iFlag)
      {
        User = UserInput();
    
        switch(User.choice)
        {
          case(1):
    */
          /*******An example of Tx continuous on user selected channel, rate 11,
           * user selected number of packets, minimal delay between packets*******/
    /*		lRetVal = Tx_continuous(User.channel,User.rate,User.packets, \
    				                 User.Txpower,0);
            if(lRetVal < 0)
            {
            	UART_PRINT("Error during transmission");
            	LOOP_FOREVER(__LINE__);
            }
              break;
          case(2):
    */
           /******An example of Rx statistics using user selected channel *******/
    /*		lRetVal = RxStatisticsCollect();
          if(lRetVal < 0)
    	  {
    		UART_PRINT("Error while collecting statistics");
    		LOOP_FOREVER(__LINE__);
    	  }
              break;
        }
    
        UART_PRINT("\n\rEnter \"1\" to restart or \"0\" to quit: ");
        //
        // Wait to receive a character over UART
        //
        cChar = MAP_UARTCharGet(CONSOLE);
        //
        // Echo the received character
        //
        MAP_UARTCharPut(CONSOLE, cChar);
        UART_PRINT("\n\r");
        iFlag = atoi(&cChar);
      }
      UART_PRINT("\r\nEnding the application....");
      //
      // power off network processor
      //
      sl_Stop(SL_STOP_TIMEOUT);
    
      LOOP_FOREVER(__LINE__);
    */
    }
    
    //*****************************************************************************
    //
    // Close the Doxygen group.
    //! @}
    //
    //*****************************************************************************
    

    The program compiles without errors, and runs as expected, but suddenly, the proper operation stops (you can recognize this event because the output at Teraterm stops) and if I pause the debugging session I just see the message:

    Can't find a source file at "D:/CC32xx/SDK_0.5.2/simplelink/source/nonos.c"
    Locate the file or edit the source lookup path to include its location.

    Why? What can I do?

    Please let me know how to solve this issue. I need the program to be running indefinitely.

    Thanks!

  • Could this be an issue with the reception? It seems that when the proper operation stops, when I pause the debugging session, in the debug window is always see the command sl_Recv, as highlighted below:

  • I tried to enable receive timeout 

    sl_SetSockOpt(iSoc,SL_SOL_SOCKET,SL_SO_RCVTIMEO, &timeval, sizeof(timeval));    // Enable receive timeout

    but the result is the same, after an arbitrary time the proper operation stops.

    I really appreciate advise on this issue, since I am using exactly the code in the transceiver mode example and I have ran out of ideas.

    Thanks!

  • Hi Fernando,

    In transceiver mode there should be at least 50ms delay between sending 2 packets. Please try adding a 50ms delay after sl_Send() 

    One question:

    • Can you confirm the service pack version you are using?

    From the code you shared it looks like you are using SDK 0.5.2.

    Regards,

    Ankur

  • Hi,

    Thanks for your reply!

    After reading your comment, I took the transceiver_mode example from SDK 1.0.0 and modified it. Just the main.c file was modified. The resulting main.c file is attached.

    6470.main.c

    But the result is the same. The program runs as expected and suddenly stops. When I pause it, I am directed to a function I have not modified. 

    I uninstalled the SDK and installed it again. I installed:

    CC31xx_CC32xx_ServicePack-1.0.0.1.2-windows-installer.exe

    CC3200_OTA_Update-1.0.0-windows-installer.exe

    CC3200SDK-1.0.0-windows-installer.exe

    In that order.

    The result was the same, although I have the impression that now it takes longer until the proper operation stops.

    In one of the trials I found the result in the following figure when I pressed "Pause":

    That is, the program was looking for the file socket.c in the driver D:\

    I do not have TI programs in D:\

    so I searched for the socket.c file in C:\ and chose the proper path.

    Thanks for your help in advance!

  • Hi, 

    I re-installed everything  (CCS and SDKs). The problem is still there. To avoid confusions with the previous posts I re-state everything here. The attached program

    2068.main.c

    is a slightly modification of the transceiver_mode example. The program runs as expected, generating an output like the following

    *************************************************
    CC3200 TRANSCEIVER_MODE Application
    *************************************************

    Host Driver Version: 1.0.0.1
    Build Version 2.0.7.0.31.0.0.3.0.1.1.8.8
    Device is configured in default state
    Device started as STATION
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 56
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 64
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 64
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128
    memcmp(&(acBuffer[8]),RawData_Ping,122)= 64
    memcmp(&(acBuffer[8]),RawData_Ping,122)= -128

    but suddenly the program output stops. If at this point I pause the debugging session, I am directed to a function that I have never modified nonos.c

    I need to program to run indefinitely. 

    Any information is appreciated. Thanks!

  • Hi Fernando,

    The service pack version you are using is very old and may lead to compatibility issues with SDK 1.0.0. I suggest you to try updating to latest service pack 1.0.0.1.2.

    I tested your code for 40 minutes with service pack 1.0.0.1.2 and it worked fine for me.

    As I mentioned in my previous post please add a 50 ms delay after sending a packet in transceiver mode.

    Regards,

    Ankur

  • Hi,

    I updated to the suggested service pack. 

    Adding a delay after sl_Send() helps, but additionally a delay is needed after sl_Recv(). Anyway, after approximately 10 minutes, the program was hanging again.

    I added a delay after sl_Send() and sl_Recv() using MAP_UtilsDelay(4000000); - that is, more than 50ms.

    It seems to me that this is not the solution of the issue, just a work around. 

    Please let me know which is the parameter for MAP_UtilsDelay(x); that I should include after sl_Send() and sl_Receive()

    Thanks!