ERROR : region RAM overflowed with stack
응답
19. 9. 25 오전 6:07

Hi

i'm using Httpclient example code(by this code i'm sending sensor data to my local server), in this code I'm trying to add virtual sensor code to get 

compass data, but when i add this line code

VirtualSensor_Setup_T setup;

setup.Enable = VirtualSensors

VirtualSensor_Setup(&setup)

 

i'm getting  ERROR : region RAM overflowed with stack

how to rectify it

thank you.,

 

code flow

 

 

/* own header files */
#include "XdkAppInfo.h"

#undef BCDS_MODULE_ID  /* Module ID define before including Basics package*/
#define BCDS_MODULE_ID XDK_APP_MODULE_ID_APP_CONTROLLER

/* own header files */
#include "AppController.h"

/* system header files */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

/* additional interface header files */
#include "XDK_Sensor.h"
#include "XDK_VirtualSensor.h"
#include "XDK_WLAN.h"
#include "XDK_ServalPAL.h"
#include "XDK_HTTPRestClient.h"
#include "XDK_SNTP.h"
#include "BCDS_BSP_Board.h"
#include "BCDS_NetworkConfig.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"
#include "FreeRTOS.h"
#include "task.h"
#include "BSP_BoardType.h"
#include "BCDS_BSP_LED.h"
#include "BCDS_BSP_Board.h" // BCDS_BSP_Board.h
#include "PIp.h"
#include "Serval_HttpClient.h"
#include "BCDS_Orientation.h"
#include "XdkSensorHandle.h"


/* constant definitions ***************************************************** */

#if HTTP_SECURE_ENABLE
#define APP_RESPONSE_FROM_SNTP_SERVER_TIMEOUT           UINT32_C(10000)/**< Timeout for SNTP server time sync */
#endif /* HTTP_SECURE_ENABLE */

#define APP_RESPONSE_FROM_HTTP_SERVER_POST_TIMEOUT      UINT32_C(10000)/**< Timeout for completion of HTTP rest client POST */

#define APP_RESPONSE_FROM_HTTP_SERVER_GET_TIMEOUT       UINT32_C(1000)/**< Timeout for completion of HTTP rest client GET */

//const char* payload[255];
Orientation_EulerData_T compassValue;
int count = 0, halt_point = 0,count_ping = 0;;
//long double xm_data = 0.0, ym_data = 0.0, direction = 0.0;
float m_x_axis = 0.0;
float compass = 0.0f;
//
const VirtualSensor_Enable_T VirtualSensors =
        {
                .Rotation = 0,
                .Compass = 1,
                .AbsoluteHumidity = 0,
                .CalibratedAccel = 0,
                .CalibratedGyro = 0,
                .CalibratedMag = 0,
                .Gravity = 0,
                .StepCounter = 0,
                .FingerPrint = 0,
                .LinearAccel = 0,
                .Gesture = 0
        };
//const VirtualSensor_Enable_T VirtualSensorsA =
//        {
//                .Rotation = 0,
//                .Compass = 0,
//                .AbsoluteHumidity = 0,
//                .CalibratedAccel = 1,
//                .CalibratedGyro = 0,
//                .CalibratedMag = 0,
//                .Gravity = 0,
//                .StepCounter = 0,
//                .FingerPrint = 0,
//                .LinearAccel = 0,
//                .Gesture = 0
//        };
//const VirtualSensor_Enable_T VirtualSensorsB =
//        {
//                .Rotation = 0,
//                .Compass = 0,
//                .AbsoluteHumidity = 0,
//                .CalibratedAccel = 0,
//                .CalibratedGyro = 0,
//                .CalibratedMag = 1,
//                .Gravity = 0,
//                .StepCounter = 0,
//                .FingerPrint = 0,
//                .LinearAccel = 0,
//                .Gesture = 0
//        };
//

/* local variables ********************************************************** */
static WLAN_Setup_T WLANSetupInfo =
        {
                .IsEnterprise = false,
                .IsHostPgmEnabled = false,
                .SSID = WLAN_SSID,
                .Username = WLAN_PSK, /* Unused for Personal WPA2 connection */
                .Password = WLAN_PSK,
                .IsStatic = WLAN_STATIC_IP,
                .IpAddr = WLAN_IP_ADDR,
                .GwAddr = WLAN_GW_ADDR,
                .DnsAddr = WLAN_DNS_ADDR,
                .Mask = WLAN_MASK,
        };/**< WLAN setup parameters */

#if HTTP_SECURE_ENABLE
static SNTP_Setup_T SNTPSetupInfo =
{
    .ServerUrl = SNTP_SERVER_URL,
    .ServerPort = SNTP_SERVER_PORT,
};/**< SNTP setup parameters */
#endif /* HTTP_SECURE_ENABLE */

static HTTPRestClient_Setup_T HTTPRestClientSetupInfo =
        {
                .IsSecure = HTTP_SECURE_ENABLE,
        };/**< HTTP rest client setup parameters */

/*
 * @todo - Use only DEST_SERVER_PORT in the header for secure and non-secure.
 * And remove the below 6 lines of the macros
 */
#if HTTP_SECURE_ENABLE
#ifdef DEST_SERVER_PORT
#undef DEST_SERVER_PORT
#endif /* #ifdef DEST_SERVER_PORT */
#define DEST_SERVER_PORT        DEST_SERVER_PORT_SECURE
#endif /* if HTTP_SECURE_ENABLE */

static HTTPRestClient_Config_T HTTPRestClientConfigInfo =
        {
                .IsSecure = HTTP_SECURE_ENABLE,
                .DestinationServerUrl = DEST_SERVER_HOST,
                .DestinationServerPort = DEST_SERVER_PORT,
                .RequestMaxDownloadSize = REQUEST_MAX_DOWNLOAD_SIZE,
        }; /**< HTTP rest client configuration parameters */

static HTTPRestClient_Post_T HTTPRestClientPostInfo =
        {
                .Payload = POST_REQUEST_BODY,
                .PayloadLength = (sizeof(POST_REQUEST_BODY) - 1U),
                .Url = DEST_POST_PATH,
                .RequestCustomHeader0 = POST_REQUEST_CUSTOM_HEADER_0,
                .RequestCustomHeader1 = POST_REQUEST_CUSTOM_HEADER_1,
        }; /**< HTTP rest client POST parameters */

/**
 * @brief   The HTTP GET request response callback.
 *
 * @param [in] responseContent
 * Pointer to the GET request response
 *
 * @param [in] responseContentLen
 * Length of the GET request response
 *
 * @param [in] isLastMessage
 * Boolean to represent if it is the last part of the ongoing message
 */
//static void HTTPRestClientGetCB(const char* responseContent, uint32_t responseContentLen, bool isLastMessage);
//
//static HTTPRestClient_Get_T HTTPRestClientGetInfo =
//        {
//                .Url = DEST_GET_PATH,
//                .GetCB = HTTPRestClientGetCB,
//                .GetOffset = 0UL,
//        }; /**< HTTP rest client GET parameters */

static xTaskHandle AppControllerHandle = NULL; /**< OS thread handle for Application controller */

static CmdProcessor_T * AppCmdProcessor; /**< Handle to store the main Command processor handle to be reused by ServalPAL thread */

/* global variables ********************************************************* */

/* inline functions ********************************************************* */

/* local functions ********************************************************** */

/** Refer function definition for description */
//static void HTTPRestClientGetCB(const char* responseContent, uint32_t responseContentLen, bool isLastMessage)
//{
//    BCDS_UNUSED(isLastMessage);
//
//    if ((NULL != responseContent) && (0UL != responseContentLen))
//    {
//        printf("HTTPRestClientGetCB: HTTP GET response: %.*s\r\n", (int) responseContentLen, responseContent);
//
//    }
//}

/**
 * @brief This will validate the WLAN network connectivity
 *
 * Currently, upon abrupt disconnection the event from the WiFi chip is not
 * propagated / notified to the application. Until then, we manually validate
 * prior to ever HTTP Rest Client POST/GET cycle to make sure that the possibility
 * of software break is reduced. We check if the IP is valid to validate the same.
 *
 * If there is no connectivity we will restart the node after 10 seconds.
 */
static void AppControllerValidateWLANConnectivity(void)
{
    Retcode_T retcode = RETCODE_OK;
    NetworkConfig_IpStatus_T ipStatus = NETWORKCONFIG_IP_NOT_ACQUIRED;
    NetworkConfig_IpSettings_T ipAddressOnGetStatus;

    ipStatus = NetworkConfig_GetIpStatus();
    if (ipStatus == NETWORKCONFIG_IPV4_ACQUIRED)
    {
        retcode = NetworkConfig_GetIpSettings(&ipAddressOnGetStatus);
        if ((RETCODE_OK == retcode) && (UINT32_C(0) == (ipAddressOnGetStatus.ipV4)))
        {
            /* Our IP configuration is corrupted somehow in this case. No use in proceeding further. */
            retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NODE_IPV4_IS_CORRUPTED);
        }
    }
    else
    {
        /* Our network connection is lost. No use in proceeding further. */
        retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NODE_WLAN_CONNECTION_IS_LOST);
    }
    if (RETCODE_OK != retcode)
    {
        Retcode_RaiseError(retcode);
        printf("AppControllerValidateWLANConnectivity : Resetting the device. Check if network is available. Node will do a soft reset in 10 seconds.\r\n\r\n");
        vTaskDelay(pdMS_TO_TICKS(10000));
        BSP_Board_SoftReset();
        assert(false); /* Code must not reach here */
    }
}

static void PrintCompass(void)
{

//    Retcode_T retcode;
//    float compassData = 0.0f;
//
//    retcode = VirtualSensor_GetCompassData(&compassData);
//    if (RETCODE_OK == retcode)
//    {
//        printf("Compass Data : %3.2f\n\r", compassData);
//    }
//    else
//    {
//        printf("Compass Data Value Read failed \n\r");
//    }
}

/**
 * @brief Responsible for controlling the HTTP Example application control flow.
 *
 * - Synchronize the node with the SNTP server for time-stamp (if HTTPS)
 * - Check whether the WLAN network connection is available
 * - Do a HTTP rest client POST
 * - Wait for INTER_REQUEST_INTERVAL if POST was successful
 * - Do a HTTP rest client GET if POST was successful
 * - Wait for INTER_REQUEST_INTERVAL if GET was successful
 * - Redo the last 5 steps
 *
 * @param[in] pvParameters
 * Unused
 */
static void AppControllerFire(void* pvParameters)
{
    BCDS_UNUSED(pvParameters);
    Retcode_T retcode = RETCODE_OK;

#if HTTP_SECURE_ENABLE

    uint64_t sntpTimeStampFromServer = 0UL;

    /* We Synchronize the node with the SNTP server for time-stamp.
     * Since there is no point in doing a HTTPS communication without a valid time */
    do
    {
        retcode = SNTP_GetTimeFromServer(&sntpTimeStampFromServer, APP_RESPONSE_FROM_SNTP_SERVER_TIMEOUT);
        if((RETCODE_OK != retcode) ||(0UL == sntpTimeStampFromServer))
        {
            printf("AppControllerFire : SNTP server time was not synchronized. Retrying...\r\n");
        }
    }while (0UL == sntpTimeStampFromServer);

    BCDS_UNUSED(sntpTimeStampFromServer); /* Copy of sntpTimeStampFromServer will be used be HTTPS for TLS handshake */
#endif /* HTTP_SECURE_ENABLE */

    while (1)
    {
        /* Resetting / clearing the necessary buffers / variables for re-use */

        Retcode_T retcode = RETCODE_OK;
        Retcode_T VirtualSensor_GetCompassData     ( float * compass);
        printf("Compass Data : %3.2f\r\n", compass); // compassData.heading
//        PrintCompass();
        /* Check whether the WLAN network connection is available */
        AppControllerValidateWLANConnectivity();

        printf("numbers of ping : %d %3.2f \r\n", count_ping++,compass);

        /* Do a HTTP rest client POST */
        retcode = HTTPRestClient_Post(&HTTPRestClientConfigInfo, &HTTPRestClientPostInfo, APP_RESPONSE_FROM_HTTP_SERVER_POST_TIMEOUT);
        vTaskDelay(pdMS_TO_TICKS(INTER_REQUEST_INTERVAL));
        if (RETCODE_OK == retcode)
        {
        }
//            /* Wait for INTER_REQUEST_INTERVAL */
//            vTaskDelay(pdMS_TO_TICKS(INTER_REQUEST_INTERVAL));
//            /* Do a HTTP rest client GET */
//            retcode = HTTPRestClient_Get(&HTTPRestClientConfigInfo, &HTTPRestClientGetInfo, APP_RESPONSE_FROM_HTTP_SERVER_GET_TIMEOUT);
//        }
//        if (RETCODE_OK == retcode)
//        {
//            /* Wait for INTER_REQUEST_INTERVAL */
//            vTaskDelay(pdMS_TO_TICKS(INTER_REQUEST_INTERVAL));
//        }
//        if (RETCODE_OK != retcode)
//        {
//            /* Report error and continue */
//            Retcode_RaiseError(retcode);
//        }
    }
}

/**
 * @brief To enable the necessary modules for the application
 * - WLAN
 * - ServalPAL
 * - SNTP (if HTTPS)
 * - HTTP rest client
 *
 * @param[in] param1
 * Unused
 *
 * @param[in] param2
 * Unused
 */
static void AppControllerEnable(void * param1, uint32_t param2)
{
    BCDS_UNUSED(param1);
    BCDS_UNUSED(param2);
    VirtualSensor_Enable();
    Retcode_T retcode = WLAN_Enable();
    if (RETCODE_OK == retcode)
    {
        retcode = ServalPAL_Enable();
    }
#if HTTP_SECURE_ENABLE
    if (RETCODE_OK == retcode)
    {
        retcode = SNTP_Enable();
    }
#endif /* HTTP_SECURE_ENABLE */
    if (RETCODE_OK == retcode)
    {
        retcode = HTTPRestClient_Enable();
    }
    if (RETCODE_OK == retcode)
    {
        if (pdPASS != xTaskCreate(AppControllerFire, (const char * const ) "AppController", TASK_STACK_SIZE_APP_CONTROLLER, NULL, TASK_PRIO_APP_CONTROLLER, &AppControllerHandle))
        {
            retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_OUT_OF_RESOURCES);
        }
    }
    if (RETCODE_OK != retcode)
    {
        printf("AppControllerEnable : Failed \r\n");
        Retcode_RaiseError(retcode);
        assert(0); /* To provide LED indication for the user */
    }
}

/**
 * @brief To setup the necessary modules for the application
 * - WLAN
 * - ServalPAL
 * - SNTP (if HTTPS)
 * - HTTP rest client
 *
 * @param[in] param1
 * Unused
 *
 * @param[in] param2
 * Unused
 */
static void AppControllerSetup(void * param1, uint32_t param2)
{
    BCDS_UNUSED(param1);
    BCDS_UNUSED(param2);

    Retcode_T retcode = RETCODE_OK;
    VirtualSensor_Setup_T setup;
    setup.Enable = VirtualSensors;
    VirtualSensor_Setup(&setup);
//    if (RETCODE_OK == retcode)
//    {
//
//    }

     retcode = WLAN_Setup(&WLANSetupInfo);
    if (RETCODE_OK == retcode)
    {
        retcode = ServalPAL_Setup(AppCmdProcessor);
    }
#if HTTP_SECURE_ENABLE
    if (RETCODE_OK == retcode)
    {
        retcode = SNTP_Setup(&SNTPSetupInfo);
    }
#endif /* HTTP_SECURE_ENABLE */
    if (RETCODE_OK == retcode)
    {
        retcode = HTTPRestClient_Setup(&HTTPRestClientSetupInfo);
    }
    if (RETCODE_OK == retcode)
    {
        retcode = CmdProcessor_Enqueue(AppCmdProcessor, AppControllerEnable, NULL, UINT32_C(0));
    }
    if (RETCODE_OK != retcode)
    {
        printf("AppControllerSetup : Failed \r\n");
        Retcode_RaiseError(retcode);
        assert(0); /* To provide LED indication for the user */
    }
}

/* global functions ********************************************************** */

/** Refer interface header for description */
void AppController_Init(void * cmdProcessorHandle, uint32_t param2)
{
    BCDS_UNUSED(param2);
    Retcode_T retcode = RETCODE_OK;

    if (cmdProcessorHandle == NULL)
    {
        printf("AppController_Init : Command processor handle is NULL \r\n");
        retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NULL_POINTER);
    }
    else
    {
        AppCmdProcessor = (CmdProcessor_T *) cmdProcessorHandle;
        retcode = CmdProcessor_Enqueue(AppCmdProcessor, AppControllerSetup, NULL, UINT32_C(0));
    }

    if (RETCODE_OK != retcode)
    {
        Retcode_RaiseError(retcode);
        assert(0); /* To provide LED indication for the user */
    }
    PrintCompass();
}

/**@} */
/** ************************************************************************* */

 

 

 

0 (0 투표)
RE: ERROR : region RAM overflowed with stack
응답
19. 9. 25 오전 8:04 as a reply to arun s.

Hello,

You have to analyse your memory management to ensure the stability of your application and avoid an overflow. You can read article about XDK memory managment from https://developer.bosch.com/web/xdk/memory-management.

0 (0 투표)