Quantcast
Channel: Embedded Software (Read Only)
Viewing all articles
Browse latest Browse all 25965

Forum Post: RE: Log_info form Float number format

$
0
0

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


Viewing all articles
Browse latest Browse all 25965

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>