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.

CCS/CC3200-LAUNCHXL: strlen to get post Token lenght gives back wrong value

Part Number: CC3200-LAUNCHXL
Other Parts Discussed in Thread: CC3200

Tool/software: Code Composer Studio

Hi, 

I'am working with the CC3200 LaunchpadXL and the httpServer example on SDK. On my webserver i want to enter default values for  some  sensors. I created  user difined tokens for post and get events. Every thing works good except one thing: The default values i would like to read should be shown in the input box on the webpage (like the example of oob). The lenght of data i response to the get token is not correct and the values on page are wrong but the data value i get from the post token is correct!

Here is the code i used in ccs:

char size_of_standard_temperatur = 2;      //default setting size of standard temperatur
char setting_standard_temperatur[] = "50";      //default setting standard temperatur


            case SL_NETAPP_HTTPGETTOKENVALUE_EVENT:
            //user setting standard temperatur
            if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data,
                      Setting_Standard_Temperatur, strlen((const char *)Setting_Standard_Temperatur)) == 0)
                {


                    strcpy((char*)pSlHttpServerResponse->ResponseData.token_value.data,(const char*)setting_standard_temperatur);
                    pSlHttpServerResponse->ResponseData.token_value.len = size_of_standard_temperatur;

                }  


                case SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT:
                //setting standard temperature
                if(memcmp(pSlHttpServerEvent->EventData.httpPostData.token_name.data,
                            POST_token_Standard_Temperatur, strlen((const char *)POST_token_Standard_Temperatur)) == 0)
                    {
                       unsigned char* ptrbuffer= pSlHttpServerEvent->EventData.httpPostData.token_value.data;
                       strcpy((char*)setting_standard_temperatur,(const char*)ptrbuffer);
                       size_of_standard_temperatur=strlen((const char *)ptrbuffer);

                        //used to check wether the correct value is in the post token:

                        if(memcmp(ptrbuffer, "20", 2) == 0)
                        {
                                //GPIO_IF_Set(GPIO_LED3, g_uiLED3Port, g_ucLED3Pin, 1);
                                GPIO_IF_LedOn(MCU_GREEN_LED_GPIO);
                                osi_Sleep(400);
                                GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
                        }
                        else
                        {       GPIO_IF_LedOn(MCU_RED_LED_GPIO);
                                osi_Sleep(400);
                                GPIO_IF_LedOff(MCU_RED_LED_GPIO);
                        }
                    }

html:

<script type="text/javascript">
$(function(){
    // assume that webserver will replace all the __SL_G token values with their
    // appropriate values if they exist
    var tokens = {
            "__SL_P_UST" : "__SL_G_US1", //standard temperature post token : setting from get token
            "__SL_P_UTH" : "__SL_G_US2",
            "__SL_P_UC1" : "__SL_G_US3",
            "__SL_P_UC2" : "__SL_G_US4",
            "__SL_P_UCH" : "__SL_G_US5",
            "__SL_P_USH" : "__SL_G_US6",
            "__SL_P_UHH" : "__SL_G_US7",
            "__SL_P_USB" : "__SL_G_US8",
            "__SL_P_UBH" : "__SL_G_US9"};

Example of the failed answer from the get token if i am sumbit 20 into the input box:

Can anyone say why the correct post token is shown wrong in the input box ifthe get token response the same data value ?

Any idea to fix the problem ? 

  • Hi,

    Please see linked post. It contains details information about GET requests.
    e2e.ti.com/.../364691

    Section 12.4.4 and 12.4.5 of the linked document could also be helpful
    www.ti.com/.../swru368a.pdf

    Regards,
    Charles O
  • Hi Charles,
    thanks for the answer!

    The post you linked was interesting but did not answer my quenstion.

    I read the document of the wru368 already but didn't find something that helps.

    How I told, the communication between webbrowser and webserver (the Launchpad) runs.
    There is an input field where user should set their default values for some sensors. These input value
    triggered an post-action.
    The webserver (launchpad) receive the post-action, value, lenght.
    To show the "new" default value I triggered a
    get-token-Event every second (the documentation says smaller than 2 seconds). Until here everything works fine.
    The "new" default value from the input field goes straight throw the Response token .
    For some reason the value from post to get token changed. I get the Input value + some strange character in the Input field.
    Refer to the Picture of my last post.

    New : If the value the users entered in the Input box have only one character everythings worked without some strange character!

    Should i terminated my string with "\0"? At the Moment it runs without, maybe thats my Problem!?



    Have i overlook something important?
    Why the value should change if i didn't do anything?

    Best greetings!

    -Felix