AnsweredAssumed Answered

full printf redirection

Question asked by pcu on Mar 5, 2013
Latest reply on Mar 5, 2013 by pcu

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 you