2013-03-05 01:29 AM
Hello,
I work with Atollic and STM3220 kit. I use the console with SWV. When I use printf with ''tiny_printf.c'' I have no problem.This is the method:in syscalls.c_write int (int file, char * ptr, int len){/ * Implement write your code here, this is used by printf and puts for example * /myprintf (file, ptr, len);return len;}myprintf void (int file, char * ptr, int len){int i = 0; for (i = 0; i <len; i + +) ITM_SendChar ((* ptr + +));}But tiny printf is not always enough I would use FULL printf and full printf is not redirected to _write.The workaround is to go through (a) sprintf:if (i == 10000000ul){ i = 0; asprintf (& buf, ''var =% 02i'', i); printf (''% s'', buf); free (buf);}But how to redirect full printf to _write. Someone has already been doing that?thank you2013-03-05 01:47 AM
It seems that full printf is redirect to _write when the len is equal to 1024 bytes. Each new string is concatenated with teh previous...
In stdio.h there is one #define#ifdef __BUFSIZ__#define BUFSIZ __BUFSIZ__#else#define BUFSIZ 1024#endifI don't know if there is a link???Pierre2013-03-05 03:12 AM
Finally I found one solution somewhere :
''The
stdout
stream is buffered, so will only display what's in the buffer after it reaches a newline ''
then should beprintf (''var = %02i '',i); instead ofprintf (''var = %02i'',i); Otherwise nothing is sent until the buffer is full.