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.

EK-TM4C1294XL - Problem showing variable in web page using the example enet_lwip

Hello, i am using the example enet_lwip for show a integer variable in the web page. The problem is this is wrong showed. For example, the value in the variable is 50 and the value shown in the web page is 0ERR. In the .c file. When the client do a GET, call the function and this response sending this:

Request: 

function getvoltage() {

var vol = false;

function VoltageComplete() {
                   if(vol.readyState == 4) {
                                if(vol.status == 200) {
                                             document.getElementById("voltage").innerHTML = "<div>" + vol.responseText + "</div>";
                                                                     }
                                                           }
                                                  }

if(window.XMLHttpRequest) {
           vol = new XMLHttpRequest();
}


else if(window.ActiveXObject)
{
vol = new ActiveXObject("Microsoft.XMLHTTP");
}


if(vol)
{
vol.open("GET", "/cgi-bin/get_voltage?id" + Math.random(), true);
vol.onreadystatechange = VoltageComplete;
vol.send(null);
}
}

Response:

if(ustrncmp(pcName, "/cgi-bin/get_voltage", 19) == 0)
{
static char pcBuf[5];


usnprintf(pcBuf,5, "%d%",decena);

psFile->data = pcBuf;
psFile->len = strlen(pcBuf);
psFile->index = psFile->len;
psFile->pextension = NULL;

//
// Return the psFile system pointer.
//
return(psFile);
}

decena is the name of the variable showed in the web page.

I think the problem is in usnprintf... but i dont know what is the correct form

Regards

Matias

  • Hello Matias,

    Perhaps try a string %s for value rather than %d being the pcBuf[5] is an array?

    If using IE web browser the ActiveX filter may be enabled. ATL key toolbar Tools drop down.

    If the pcBuf[5] value is an integer or hex it may need to be converted prior to output into IE via usnprintf(). Perhaps a conversion something like below might help. 0=auto radix selection,  8=char, 16=int.


    ustrtoul(pcInputValue, NULL, 0);