This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC2640R2F: [BUG]-- UartLog display float variable as 0.0000 using %f as format

Part Number: CC2640R2F

Tool/software: TI-RTOS

example project: project zero, i2chdc2010(simplelink sensor and actuator plugin example)

copy Uartlog.c, Uartlog.h to project i2chdc2010 do display temperature and humidity using Uartlog

but the code does show any float data as 0.0000

        Log_info2("%.2f DegC(Temp), %.2f %%RH(Humidity)", g_actualTemp, g_actualHumity);

to show the data correctly have to do workaround as the following:

int     i_actualTemp   = 0;
int     i_actualHumity = 0;
i_actualTemp = g_actualTemp;
i_actualHumity = g_actualHumity;
Log_info4("%d.%2d DegC(Temp), %d.%2d %%RH(Humidity)", g_actualTemp, (g_actualTemp - i_actualTemp) * 100, g_actualHumity, (g_actualHumity - i_actualHumity) * 100);

  • Hey,
    Assigning this to a fellow good at numbers..
  • Hi,

    Have you enabled floating point support for System_print? This is the string "rendering" backend for the uart log formatting. This must be done in the .cfg file.

    Please see dev.ti.com/.../node and go to xdc -> runtime -> System -> System.extendedFormats.

    It should be sufficient to add System.extendedFormats = "%f"; to the cfg file or ensure that %f is part of this string.

    Best regards,
    Aslak
  • On second thought, since you already see 0.000 and not just %f, this is probably not your problem.

    The UartLog records store only 4 bytes / 32 bits per argument. I suspect that this could be an issue with floating point arguments, it's not impossible that it's represented as a 64-bit value. You could pre-format your number into a globally accessible string and use %s, or you could give the integer and fractional parts as separate print arguments.

    Best regards,
    Aslak