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.

Log_info form Float number format

Other Parts Discussed in Thread: SYSBIOS

Hi, 

i've the necessity to Log a float number with Log_info function.

I'm use Log_info for %d and it work correctly but for %f or %s it NOT log the value but "%f".

I'm try to set the extendedFormats in System but wit Log_info NOT produce the float output.

How i can make this?

Thanks and Regards

Fabio

  • I believe this should work.

    To support the floating point %f conversion characters, you must add this to your config script:

    var System = xdc.useModule('xdc.runtime.System');
    System.extendedFormats += "%f";

    I hope this works for you.

    Alan

  • Hi Alan, these additional strings, permit to use Log_info("%f");?

    i've tryed

    but the Log_info1("prova float %f",(float 1.5); produce the string "prova float %f" on the screen.

    Sure that this works with Log_info()?

    Fabio

  • Fabio,

    This should work. I can't even get Log_print1() to work either. I'll check into it and report back ASAP.

    Alan

  • Fabio,

    I was misinterpreting my results. When I flushed the logs to the console, both Log_info1() and Log_print1() prints were as expected.

    Here are my .cfg file settings:

      var System = xdc.useModule('xdc.runtime.System');
      System.extendedFormats += "%f";
      var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
      var Diags = xdc.useModule('xdc.runtime.Diags');
      var Defaults = xdc.useModule('xdc.runtime.Defaults');
      var Main = xdc.useModule('xdc.runtime.Main');


      // Configure LoggerBuf to flush logs
      LoggerBuf.enableFlush = true;

      // Create default logger for the whole system.
      var LoggerBufParams = new LoggerBuf.Params();
      LoggerBufParams.exitFlush = true;
      Defaults.common$.logger = LoggerBuf.create(LoggerBufParams);

      // Turn on Info logs in Main module (all non-modules)
      Main.common$.diags_INFO = Diags.RUNTIME_ON;

    Here are my Log_info1() and Log_print1() call sites in the C code:

      Log_info1("Hello %f", floatToArg(129.72));
      Log_print1(Diags_INFO, "Hello %f", floatToArg(129.72));

    And here are the resulting console outputs:

      #0000000002 [t=0x0000d9f3] xdc.runtime.Main: "FloatTest1.c", line 163: Hello 129.7200
      #0000000003 [t=0x0000db6b] xdc.runtime.Main: Hello 129.7200

    Alan

  • Hi Alan, 

    thanks for your indications. 

    So i try it, but i use UIA and then a must use the LoggingSetup in order to configure the System Analyzer, end point, etc.

    So this is my .cfg:

    var System = xdc.useModule('xdc.runtime.System');
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    var Log = xdc.useModule('xdc.runtime.Log');
    var LoggingSetup = xdc.useModule('ti.uia.sysbios.LoggingSetup');
    System.extendedFormats += "%f";
    var Diags = xdc.useModule('xdc.runtime.Diags');
    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Main = xdc.useModule('xdc.runtime.Main');
    var Task = xdc.useModule('ti.sysbios.knl.Task');

    var taskInitParams = new Task.Params();
    taskInitParams.instance.name = "taskInit";
    taskInitParams.priority = 15;
    taskInitParams.stackSize = 32768;
    Program.global.taskInit = Task.create("&taskBootUpFnx", taskInitParams);

    // Turn on Info logs in Main module (all non-modules)
    Main.common$.diags_INFO = Diags.RUNTIME_ON;
    BIOS.libType = BIOS.LibType_Instrumented;
    LoggingSetup.eventUploadMode = LoggingSetup.UploadMode_JTAGRUNMODE;

    and when i use 

    Log_info1(" Log_info1 Hello %f", floatToArg(129.72));

    the result is  Log_info1 Hello %f". And The same for Log_print.

    So without LoggingSetup how i can see the Log_info Result that you have try? You use Uia in Debugger?

    Can you give me some indications?

    Thanks

    Fabio

  • Good morning,

    is there someone that can support me to use Log_info for float (%f) number using UIA Logging? with CCS and DSP C6457?.

    Thanks in advance.

    Fabio

  • Hi Fabio,

    I don't think System Analyzer will format the %f correctly, at least I couldn't get it to work.  However, there is a way around this problem using LogSnapshot.  Here is an example of how I did this using the UIA stairstep example:

    In the stairstep.c file, additions are in red:

    #include <ti/uia/runtime/LogSnapshot.h>

    static char floatString[256];  /* An array large enough to hold your float string */

    /*
     *  ======== hwiLoad ========
     */
    Void hwiLoad(Void)
    {
        static ULong oldLoad = ~0;
        float hwiLoad = 0.0;

        /* display confirmation of load changes */
        if (oldLoad != hwiLoadVal ) {
            oldLoad = hwiLoadVal;
            Log_print1(Diags_USER1, "Hwi load: new load = %d%%",
                    hwiLoadPercent[loadIndex]);

            hwiLoad = (float)hwiLoadPercent[loadIndex] / 100.0;
            System_sprintf(floatString, "New hwi load: %f\n", hwiLoad);

            /* This string will be displayed incorrectly in System Analyzer */
            Log_print1(Diags_USER1, "Hwi load percent: %f", floatToArg(hwiLoad));

            LogSnapshot_writeString(0, "floatString", floatString, strlen(floatString));

            /* This string should have the correct format */
            Log_print1(Diags_USER1, "floatSting = %s", (IArg)floatString);
        }

        if (hwiLoadVal) {

            doLoad(hwiLoadVal);
        }
    }

    Then in the .cfg file, add

    var LogSnapshot = xdc.useModule('ti.uia.runtime.LogSnapshot');

    This is what I got in System Analyzer:

    I'm assuming your using a UIA 1.x version.  If you are using UIA 2.0, the changes you need to make to the .cfg file are a little different.

    Best regards,

        Janet

  • Hi Janet,

    This looks like a bug in System Analyser (the floating point support works in XDC logger, but not for UIA, which is supposed to be superior).

    Is there any plan to fix it?

    In any case, many thanks for the proposed workaround.

    Regards,
    Vasili

  • Hi Vasili,

    Which XDC logger are you referring too?  Are you viewing it with ROV or System Analyzer?

    Thanks,

        Janet

  • Hi Janet,

    My setup is:

    CCS 6.0.0.00190
    XDCtools 3.25.05.94
    BIOS 6.37.02.27
    UIA 1.04.00.06

    The project uses UIA:

    var System = xdc.useModule('xdc.runtime.System');
    var LoggingSetup = xdc.useModule('ti.uia.sysbios.LoggingSetup');
    var LogSnapshot = xdc.useModule('ti.uia.runtime.LogSnapshot');
    System.extendedFormats += "%f";

    And in CCS I use "Tools->RTOS Analyser->Printf and Error Logs" which opens a "Live Session" pane. AFAIU, it is part System Analyser, right?

    In this pane I see "%f" where I would expect the floating point numbers (for comparison, integer work fine).


    As you can see in Alan's post above, the floating number printing works fine for him when using:

    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');

    Best,
    Vasili

  • Hi Vasili,

    What target are you using?  I found that this did not work with C28 floating point, although for M4F it worked fine.  When running on a Piccolo F28069 control stick, I got this output in System Analyzer:

    The address of the string was correct, but for some reason it didn't display it.  Was this the sort of failure you are seeing?

    Best regards,

        Janet

  • Hi Janet,

    My apologies for the late answer, i was away for some time...

    I'm using somehow customized A8 target with gcc compiler. But I doubt that my customizations can be the cause for the problem here.

    Here is how I see in "Live section" pane:


    Best,
    Vasili

  • Hi Vasili,

    I doubt also that this has anything to do with the A8 and gcc compiler.  Are you seeing the Snapshot event in the Live Session window?  This is what I see:


    I'm also attaching the test that I generated the output with:

    5543.logSnapshotFloat.c

    8463.logSnapshotFloat.cfg

    Best regards,

        Janet

  • Hi Janet,

    I'm failing to build your code. Getting the following error:

    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
      configuring logSnapshotFloat.x from package/cfg/logSnapshotFloat_p.cfg ...
      js: "D:/Dev/trunk/Src/Firmware/Sitara/Products/logSnapshotFloat/logSnapshotFloat.cfg", line 130: XDC runtime error: ti.uia.sysbios.LoggingSetup: no element named 'snapshotLogging'
          "./package/cfg/logSnapshotFloat_p.cfg", line 184
      gmake.exe: *** [package/cfg/logSnapshotFloat_p.xdl] Error 1

    Maybe I shall update UIA or something?

    Best,
    Vasili

  • Hi Vasili,

    The .cfg file I posted was from a test I made for UIA 2.0.  To get this to build for UIA 1.04, you should be able to just remove the line:

    LoggingSetup.snapshotLogging = true;

    from the .cfg file.

    Best regards,

        Janet

  • Hi Janet,

    I've updated my tools to the latest available versions and succeeded in running your example on A8 target.

    xdctools_3_30_04_52
    bios_6_40_03_39
    uia_2_00_01_34
    CCS 6.0.1.00040

    The output I see matches what you've seen (as posted above). Namely:

    1. Log_print1 with %d argument works fine (as expected).
    2. Using intermediate string buffer works fine:
      1. Print floating number using System_sprintf with %f argument
      2. Save buffer using LogSnapshot_writeString
      3. Use Log_print1 with %s argument
    3. However, Log_print1 with %f argument does not work. CCS just shows %f as you can see in your screenshot.

    Of course, (2) provides a workaround, but does TI plan on fixing (3)?

    Best regards,
    Vasili

  • Hi Vasili,

    Sorry I missed this one!  I'm not sure when/if this will be available in CCS, but I'm still waiting to hear back on this.  In the meantime, maybe you could post this question to the CCS forum.

    Thanks,

        Janet