AnsweredAssumed Answered

Sprintf effect on Send_text LwIP is going wrong

Question asked by jendoubi saif ddine on Apr 21, 2018
Latest reply on Apr 21, 2018 by jendoubi saif ddine

so this is my function that works fine when i add it to the script :

  • send_text(pAcceptedConnection, " function drawChart() {var data = new google.visualization.DataTable();data.addColumn('string', 'Topping');data.addColumn('number', 'Slices');data.addRows([['Mushrooms', 3],['Onions', 2],['Olives', 1],['Zucchini', 4],['Pepperoni', 2]]);var options = {'title':'How Much Pizza I Ate Last Night','width':400,'height':300};var chart = new google.visualization.PieChart(document.getElementById('chart_div'));chart.draw(data, options);}");

but once i pass the inside message on Sprintf to make once of the values taken from a variable and do the same thing again like this : 

  • sprintf((char*) msggg1," function drawChart() {var data = new google.visualization.DataTable();data.addColumn('string', 'Topping');data.addColumn('number', 'Slices');data.addRows([['Mushrooms', 3],['Onions', 2],['Olives', 1],['Zucchini', 4],['Pepperoni', %d]]);var options = {'title':'How Much Pizza I Ate Last Night','width':400,'height':300};var chart = new google.visualization.PieChart(document.getElementById('chart_div'));chart.draw(data, options);}",x);
    send_text(pAcceptedConnection,(const char*)msggg1);

it won't work 

this is the send function :

  1. static void
    send_text(struct netconn *conn, const char *text)
    {
    const char *src = text;
    u16_t len = 0;

    while (*src++ != '\0')
    len++;

    netconn_write(conn, text, len, NETCONN_COPY);
    }

if anyone can help please and thanks 

Outcomes