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

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderators: utzig, tfAteba

rongcuid
Posts: 5
Joined: Fri Jan 13, 2017 7:29 pm

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

Postby rongcuid » Tue Apr 11, 2017 5:42 am

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?

User avatar
Giovanni
Site Admin
Posts: 10313
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 227 times
Been thanked: 203 times
Contact:

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

Postby Giovanni » Tue Apr 11, 2017 10:14 am

Hi,

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

Giovanni

rongcuid
Posts: 5
Joined: Fri Jan 13, 2017 7:29 pm

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

Postby rongcuid » Tue Apr 11, 2017 4:50 pm

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?

User avatar
Giovanni
Site Admin
Posts: 10313
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 227 times
Been thanked: 203 times
Contact:

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

Postby Giovanni » Tue Apr 11, 2017 8:54 pm

You could use a mutex for mutual exclusion.

Giovanni


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 1 guest