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_print1( "%f", floatVar) logs only only 'f'



Hello,

Log_print1( Diags_USER1, "A = %f\n", floatToArg( fA ) );

This prints only "f", even if I add this to my config:

System.extendedFormats = "%f%$S";

SYS/BIOS 6.33.05.46

XDC 3.23.03.53

What am I doing wrong?

cu

Markus

  • Markus,

    I tried creating an app with your settings. I was not able to reproduce the problem.

    It should work if System.extendedFormats = "%f%$S"; is used in the config file. Can you please give it another try? Clean and rebuild your app.

    If you are still stuck after rebuilding your app,  share your config file and .c file. I will give it another try.

    Vikram

  • Hello Vikram,

    nothing changes after a clean rebuild. I can send you my .cfg file (attahed), but a single .c file will be difficult :(

    I use log_printn for float for example like this:

    /** <!-------------------------------------------------------------------------------------------->
     * Prints an fpga message header to the console
     *
     * @param   rsMessageHeader (i) message header to print
     <!--------------------------------------------------------------------------------------------> */
    void debugMessageHeader( const FpgaMessageHeader_t& rsMessageHeader )
    {
    	Log_print1( Diags_USER1, "rsMessageHeader.fSOF                  = %f\n",   floatToArg( rsMessageHeader.fSOF ) );
    	Log_print1( Diags_USER1, "rsMessageHeader.u32TimestampLo        = 0x%x\n", rsMessageHeader.sTimeStamp.sLoHi.u32Hi );
    	Log_print1( Diags_USER1, "rsMessageHeader.u32TimestampHi        = 0x%x\n", rsMessageHeader.sTimeStamp.sLoHi.u32Lo );
    	Log_print1( Diags_USER1, "rsMessageHeader.u4Channel             = %d\n",   rsMessageHeader.u4Channel );
    	Log_print1( Diags_USER1, "rsMessageHeader.u5SampleRateExponent  = %d\n",   rsMessageHeader.u5SampleRateExponent );
    	Log_print1( Diags_USER1, "rsMessageHeader.u7TBD                 = %d\n",   rsMessageHeader.u7TBD );
    	Log_print1( Diags_USER1, "rsMessageHeader.u16PayloadLength      = %d\n",   rsMessageHeader.u16PayloadLength );
    } // END DebugMessageHeader
    

    Seems if something's weird, I'll have to live with it…

    ti81xx_dsp.cfg
  • I forgot: I added the "floatToArg()" in line eight only recently, after I noticed that %f didn't work. Not using it doesn't change anything.

  • Markus,

    You may need to add this line to the .cfg file:

    LoggerBuf.enableFlush = true;

    Hope it helps!

    Vikram


  • Sorry, no, it didn't help :(

  • Markus,
    the output you are seeing indicates that the extended formats spec is not working. You can check that if you open a C file inside your Debug/configPkg/package/cfg directory. The file name is of the format <yourappname>_pe674.c.
    Please, open that file and search for the string "(c == 'f')". You should find that string as a condition of an IF statement. That IF statement should be long, around 60 lines of code, while if the extended format spec is not working correctly, there will be only 5 or 6 lines.

    The only scenario that I can come up with to explain what you are seeing is that some of the packages you are loading is changing the value of System.extendedFormats, after you already specified it. You can put that statement at the end of your script and see if it helps, or try commenting out parts of your config script until you see the long IF statements in the generated C file in Debug/configPkg/package/cfg directory.

  • Hello Sasha,

    I've found the if statement that you described and it's 61 lines long. Still, I get only 'f' as output ;(

    cu

    Markus

  • Markus,
    I wasn't able to replicate that. But before I ask for some more help, I would like to know where are you looking for the content of the log. In the test case I am using, this is what's in my C code:
    float p = 24.7;
    Log_print1(Diags_USER1, "p: %f\n", floatToArg(p));

    Then, my console output looks like this:

    #0000000001 [t=0x0191a4c9] xdc.runtime.Main: p: 24.7000

    And, when I look at the content of the LoggerBuf instance in ROV, I see

    serial  timestampRaw   modName            text      eventId ...
    1       26469272       xdc.runtime.Main   p: f      0       ...

    As you can see, it's normal to see 'f' in ROV. The actual number is displayed only when the content of the log is printed. So, are you seeing an unexpected output in the console output window?

    If you are not seeing any output in the console window, you need to do one more thing in addition to enabling exitFlush. You need to call LoggerBuf_flushAll() at the end of your runtime code.

    If you did all that, and the console output is still wrong, can you put a breakpoint at the end of that long IF statement we already discussed? The statement where you should add a breakpoint is

    found = TRUE;

    Let me know if you ever reach that long IF statement, and then if you reach this last statement in it.

  • Hello Sasha,

    You solved my problem -- thank you!

    But this means I misunderstood the sense of the LOG-Module. I had the impression that the whole sense was the ROV-output of the log? I didn't see that the contents of the log buffer can (or should?) be directed to the console and that I have to take care myself to send it there with LoggerBuf_flushAll()…

    For me, the ROV-output is much more practical than the console. So I'll live with its limited output of floats for now. Maybe some time the ROV will be able to log floats, too?

    Thanks again,

    Markus

  • Markus,
    Log module is specifically designed to be a very generic interface to logging. It is left to the underlying ILogger that you configure in your CFG script to determine what to do with Log entries. LoggerBuf documentation states that events are kept in a buffer unformatted, and it is up to some other client to consume the raw data. LoggerBuf_flushAll() function is just a quick hack that lets you see your events in the console window. The right thing to do, if you want to see events in the console window, is to switch from LoggerBuf to LoggerSys. That change happens in your CFG script, you don't have to call any flush() function in your C code, so your C code can stay independent from any specific ILogger.

    As for ROV, the current amount of work that ROV needs to do to display "float: f" string is relatively low - read an index from a LOG record, use index to find a string in the table of strings, and print the string but skip '%'. If we wanted to generate the same output in ROV as you can get in the console window, we would have to implement System_printf in ROV. It's not that difficult to do, but I am not aware of any plans to do so.