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.

RTOS/TM4C1294NCPDT: Httpget NDK project Shifted receive data frome server

Part Number: TM4C1294NCPDT

Tool/software: TI-RTOS

Hi,

I'm working on Tiva C Launchpad, on the Httpget project provided by TI.


I try to get the Timestamp frome my server, but at this part of programme "httpget.c" line 124 :

    do {
        ret = HTTPCli_readResponseBody(&cli, data, sizeof(data), &moreFlag);
        if (ret < 0) {
            printError("httpTask: response body processing failed", ret);
        }

        len += ret;
    } while (moreFlag);

the programme execute the loop twice. At the first time, the Buffer data=[49 '1',52 '4',57 '9',57 '9',57 '9'...] It is the good value. But He make a second execution of the loop, so he become data=[97 'a',0 '\x00',57 '9',57 '9',57 '9'...] .... the tow firsts bytes are changed.

Questions :

1- I don't anderstand the second execution of the loop, because I send a small data size.

2- what means those values (97 'a',0 '\x00) ... It's all time the same

  • Toufik Chelmouni said:
    1- I don't anderstand the second execution of the loop, because I send a small data size.

    Looks like your data buffer was small to fit the entire data from response. So, the moreFlag was set to let you know that more data is available to read from the response. Even if you do not need the data, it has to be read so that the TCP buffer is flushed. I would suggest making your buffer bigger or transfer the data you need from buffer to some other variable/buffer before the next loop.

    Toufik Chelmouni said:
    2- what means those values (97 'a',0 '\x00) ... It's all time the same

    I am not sure what the data means but it is something your server is sending.

  • Hi Vikram,

    I'm using a 256 bytes buffer to read server response that is timestamp provided by this PHP code :

    <?php 
    echo time();
    ?>
    

    BR,

    Toufik

  • Hi Toufik,

    If you think there is enough space in the buffer and the readResponseBody is looping twice to read all bytes, then we should offset the data array pointer. This would ensure the data read in the first loop won't be overwritten. 

    In your code replace:

    HTTPCli_readResponseBody(&cli, data, sizeof(data), &moreFlag);

    with:

    HTTPCli_readResponseBody(&cli, data + len, sizeof(data) - len, &moreFlag);

    Let me know if this works.

    Vikram