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.

TI-RTOS TM4C129 Http Server

Hi,
I'm working on DK-TM4C129X with TI-RTOS 2.00.01.23, NDK 2.23.01.01 and CCS 6.

I made the changes in the EMACSnow.c file as described in TI-RTOS TM4C129 Emac Issues but this seems doesn't work for me.
I have an http server that sends JSON strings.
I had define 11 strings with length less than 200. In my cgi I call a function that insert these strings in 11 buffers with snprintf taking values from an array that contains data that I want to show in my web page. Finally I send any string with httpSendClientStr.

//JSON string example:

#define JSON_TEMPERATURE    "\"rf_temp_1\":{\"value\":\"%.2f\",\"ok\":\"%d\"},\"rf_temp_2\":{\"value\":\"%.2f\",\"ok\":\"%d\"},"

//snprintf example:

snprintf(temperature,     MAX_RESPONSE_SIZE, JSON_TEMPERATURE,     vals[TEMP_RF_1].value, vals[TEMP_RF_1].ok, vals[TEMP_RF_2].value, vals[TEMP_RF_2].ok);

//send string with:

httpSendClientStr(htmlsock, json_pointer[i]);

where json_pointer[i] points to the string resulting from snprintf.

Every time that I change something in my code, for example the content of a JSON string or add/remove/move a piece of code (included the System_printf or the heartBeatfxn in the empty project example) the server stops to work (more specifically it isn't pingable).  
I tried to lower  CPU clock frequency to 80MHz, upgrade the network task stack sizes to 4096 bytes, use DHCP and static IP, send html rather than JSON but every time I change something the server starts or stops to work, in my opinion,  without any apparent logic.

An example:
I worked with 80MHz CPU freq and network task stack sizes of 4096 bytes, because these seemed to make reliable my server that didn't work anymore at 120MHz and 2048 bytes stacks sizes.
After the last little change inside a JSON string the server stops ping again.
After many attempts I add "SysCtlDelay(0x400000);" line in my main() before board init functions (as someone suggested in a discussion) and the server restarts to ping.
But doing other tests I delete "SysCtlDelay(0x400000);", I set again the CPU at 120MHz and the server also works, when before it didn't at this frequency.

Sorry I'm a beginner with TI-RTOS and I can't really find a connection between the changes made and the http server behavior.

Maybe are there limitations in the content type of data that I can send with this http server?
Is it possible that TI-RTOS TM4C129 Emac Issues doesn't solve the problem entirely?
Finally, I see that there is also the EMACTiva.c file in the emac drivers folder, why apply changes only to EMACsnow.c?

Thanks in advance.
Regards,

Enrica

  • Hi Enrica,

    Why things are not working properly, can you halt the target and look at Tools->ROV->EMAC->Statistics in CCS and look at the # of Rx, Tx, Rx dropped and Tx dropped packets. Can you report back what those are?

    The EMACTiva was for the Stellaris LM3 devices and the M3 of the Concerto device. For the TH4M129 devices you need the EMACSnow driver (the code name was Snowflake).

    Todd

  • Hi Todd,

    When the server doesn't work I have:

    • With static IP                ->  rxCount: 0, rxDropped: 0, txSent: 1 and txDropped: 0;
    • With DHCP after fault   ->  rxCount: 0, rxDropped: 0, txSent: 4 and txDropped: 32.

    Enrica

  • Hi Enrica,

     

    In my project, I am using an http server with XML data. I wonder how you send the data(JSON) to the page.

    Do you  use HttpSendStatusLine(sock, HTTP_OK, CONTENT_TYPE_HTML); + httpSendClientStr() or

     HttpSendStatusLine(sock, HTTP_OK, CONTENT_TYPE_JSON); + httpSendClientStr()?

    I appreciate any help,

    Vini

  • Hi Vinicius,

    I use CONTENT_TYPE_JSON.

    I add the

    #define CONTENT_TYPE_JSON "application/json ".


    Enrica

  • Hi Enrica,

    I was wondering how to send the data to web page. Could you share your code that send data, please.

    Thanks!

    Vini

  • Hi Vinicius,

    this is my code:

    #define html(str) httpSendClientStr(htmlsock, (char *)str)
    
    static char *CONTENT_TYPE_JSON = "application/json "; //The white space at the end is needed
    
    //My CGI function
    static Int updateData(SOCKET htmlsock, int ContentLength)
    {
    	 int i;
    	 char json_buffer[MAX_RESPONSE_SIZE];
    
    	 httpSendStatusLine(htmlsock, HTTP_OK, CONTENT_TYPE_JSON);
    	 html(CRLF);
             
             //I have  differents json strings with maximum lenght MAX_RESPONSE_SIZE
             for (i = 0; i < JSON_STRINGS; i++) {
                      //filljson is the function that copy json string i in the json_buffer
                      filljson(json_buffer, i);
                      //Than I send string
                      html(json_buffer);
             }
    
    
    	return (1);
    }
    
    Void AddWebFiles(void)
    {
    	efs_createfile("index.html", INDEX_SIZE, (UINT8 *)INDEX);
    	efs_createfile("updateData.cgi", 0, (UINT8 *)&updateData);
    }
    
    
    Void RemoveWebFiles(void)
    {
    	efs_destroyfile("index.html");
    	efs_destroyfile("updateData.cgi");
    }

    If I call the updateData.cgi in my web browser or via AJAX I receive my JSON. (When my server works, because I still haven't solved the problem) .

    Does your http server works every time that you run it? Is it always pingable?

  • Hi Enrica,

    Thank you very much! Sorry, I have one more question.

    Your page does get data through Javascript?

    "Does your http server works every time that you run it? Is it always pingable?" Yes, every time! I'm using tirtos_tivac_2_01_00_03 and ndk_2_23_01_01.

    Sometimes I have problems with DHCP or other services, because I use 4 tasks or more. The problem is conflict of priorities, so I have to change the priority of tasks. I'm currently using priorities 1, 2, 3 and 4.

    Vini