Hello
I’m want to use sprintf function in my task and I’ve got some problems with it. Here’s the code:
void vMyTask(void *pvParameters)
{
while(1)
{
char mytext[50];
sprintf(mytext, "blah blah");
char *pointer = mytext;
xQueueSend(Global_Queue_Handle, &pointer, 1000);
vTaskDelay(5000);
}
}
So far, the sprintf function works, data is being sent to httpd-cgi and then to web interface, where it displays “blah blah” text just fine. But if I put some integer in the code, say:
char mytext[50];
int value=123;
sprintf(mytext, "%d blah blah", value);
char *pointer = mytext;
It doesn’t work – code compiles fine, but the web interface doesn’t even start. I did some searching and found, that this could be a problem with stack overflow, so I’ve increased the stack:
xTaskCreate(vMyTask, "MyTask", configMINIMAL_STACK_SIZE, NULL, 1, NULL ); //original
xTaskCreate(vMyTask, "MyTask", 50000, NULL, 1, NULL ); //modified
So now the web interface displays fine, but there is no expected “123 blah blah”. And what’s more, if I go back to simple “blah blah” (no integer), it doesn’t display as well – I have to go back to configMINIMAL
STACKSIZE in order for it to display.
And this is where I’ve got so far. What can I do in order to make it work? I’ve seen that there is a low memory cost implementation
printf-stdarg. Do I use it? How do I use it? I’m fine with any solution that allows me to convert integers (no floats in my code) into chars.
I’m running the code on FreeRTOS v7.5.2 and LPC2468 – 16MB SDRAM seems plenty…
Regards,
George