Empty string when using the sprinft() for float variables

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
sergey3778
Posts: 4
Joined: Thu Feb 23, 2023 10:56 pm

Empty string when using the sprinft() for float variables

Post by sergey3778 »

Hi.
I got a problem while using the function sprintf(), when I was trying to output a float variable. The problem first appeared after using the dtostrf() function. If I add a float variable, I get an empty string as a result.
Variables of type int are fine. As soon as the identifier "f" or "lf" appears in the arguments of the sprintf() function, after that sprintf() returns an empty string.
I am using the Arduino_STM32-master library in the Arduino IDE 2.0.3. Board type STM32F4VE.
Help me please. The third day, nothing happens.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Empty string when using the sprinft() for float variables

Post by fpiSTM »

You have to enable printf float support for nano lib, STM32 core provides a way to enable it:
https://github.com/stm32duino/Arduino_C ... 4-L11996C4

But this is not available in Roger's core, So here :
https://github.com/rogerclarkmelbourne/ ... rm.txt#L48

Add:

Code: Select all

-u _printf_float
sergey3778
Posts: 4
Joined: Thu Feb 23, 2023 10:56 pm

Re: Empty string when using the sprinft() for float variables

Post by sergey3778 »

I used this guide to installation.
I have downloaded this version of Roger's core:
Download a zip file containing the Arduino STM32 files from here.
Based on the link, this is an archived version of the Roger's Core.
There is already a mention of "-u _printf_float" in the platform.txt file from this Core. Here is part of that file:

Code: Select all

# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.combine.flags=-u _printf_float -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
#compiler.c.elf.extra_flags="-L{build.variant.path}/ld" -specs=nosys.specs -specs=nano.specs {compiler.combine.flags}
compiler.c.elf.extra_flags="-L{build.variant.path}/ld" "-Wl,--wrap=atexit,--wrap=__cxa_atexit,--wrap=exit" -specs=nano.specs
compiler.cpp.extra_flags= 
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
But the problem still remains.
Maybe the "-u _printf_float" definition needs to be added elsewhere? But I still do not understand where else to add "-u _printf_float".

Update

I just noticed that you wrote me a link for STM32, for the F1 series. But I am using F4 series controller's. For it, in the file platform.txt already has a definition for "-u _printf_float". And, by the way, exactly as I wrote above.
https://github.com/rogerclarkmelbourne/ ... atform.txt
Post Reply

Return to “General discussion”