Page 1 of 1

Do I need to link printf libraries if I use chprintf?

Posted: Tue Apr 11, 2017 5:42 am
by rongcuid
In the makefiles, I see the PRINTF_LIB_MIN, PRINTF_LIB_FLOAT, etc. Do I need these for chprintf to work? When I comment these out, the program compiles just fine, and the sizes are the same. The same stays true for scanf related stuff, although there is no chScanf equivalent.

Actually, `chPrintf()` is not thread safe... Is the only advantage that I can use drivers as parameters?

Re: Do I need to link printf libraries if I use chprintf?

Posted: Tue Apr 11, 2017 10:14 am
by Giovanni
Hi,

chprintf() is part of ChibiOS and is not affected by those library-related settings.

Giovanni

Re: Do I need to link printf libraries if I use chprintf?

Posted: Tue Apr 11, 2017 4:50 pm
by rongcuid
Ah, I see. Just as a side question, is there a way to use chprintf atomically? Or is there something that can acquire the serial bus? Or must I use other method of locking?

Re: Do I need to link printf libraries if I use chprintf?

Posted: Tue Apr 11, 2017 8:54 pm
by Giovanni
You could use a mutex for mutual exclusion.

Giovanni