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/66AK2H12: Log_info1( %s)

Part Number: 66AK2H12

Tool/software: TI-RTOS

Hi. I'm trying to use the Log functions such as Log_infoX, Log_warnX and Log_errorX. When I try to use a %s print specification I am getting a compile error:

C:/ti/xdctools_3_50_02_20_core/packages/xdc/runtime/Log__epilogue.h:129:73: error: invalid conversion from 'const char*' to 'xdc_IArg {aka int}' [-fpermissive]
Module__LOGFXN4(Module__LOGOBJ, (evt), (mid), (a1), (a2), (a3), (a4))

My line of code for testing is:

Log_error1( "System start failed: %s\n", "test");//e.what() );

The xdctools documentation isn't 100% clear to me as to which conversion characters are support by the various Log functions. The only place the specifiers are listed is after Log_print6()

What might I be doing wrong?

XDCtools 3.50.02.20, SYS/BIOS 6.50.01.12

Mike

  • Hi Mike,

    I've forwarded your query to the software experts. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • Hi Mike,

    Sorry this just got moved to us....
    I'm surprised it's a compiler error. I tried it on a CortexM device, so it's a different compiler, but I just got a warning. Can you try this?
    Log_error1( "System start failed: %s\n", (IArg)"test");

    Todd
  • Hi Todd.

    Your suggestion of casting with IArg worked.

    Yes I am also surprised to get a compiler error and not a warning but I just tested again and I do get the error. I am using GNU 4.9.3 (I can't seem to get 6.3.1 to work for me due to multiple defines - another issue). The error I get is:

    error: invalid conversion from 'const char*' to 'xdc_IArg {aka int}' [-fpermissive]

    I'll use the cast mark this as resolved.

    Thank you.
    Mike
  • Upon further review -Todd you were correct. I was getting a warning not an error. The compiled code did produce the desired output to the LogBuffer. Casting to IArg got rid of the warning but also broke the outout; the string data was not included at %s in the buffer output. Thanks again for your help.
    Mike
  • Good grief. Back again - A complete rebuild gives me the compile warning as before but an error on linking (I incorrectly said it was a compile error in my initial post). So I am still unable to log string variables. Casting to IArg removes compile warning and link error but no data gets logged.
    This is the line of code:
    Log_info1("%s", "test");
    Again the link error is:
    C:/ti/xdctools_3_50_02_20_core/packages/xdc/runtime/Log__epilogue.h:129:73: error: invalid conversion from 'const char*' to 'xdc_IArg {aka int}' [-fpermissive]

    I'm baffled as to why it linked and worked once...
  • And a simple, new test application works. Compile warning, no link error, string data logged for %s.
  • Mike,

    What was displayed with the cast? The cast should not change the behavior. What compiler (and version) are you using?

    Todd
  • My project linker variables are:
    'Invoking: GNU Linker'
    "C:/ti/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc.exe" -mtune=cortex-a15 -marm -DSOC_K2H -DDEVICE_K2H -D_LITTLE_ENDIAN=1 -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -mfloat-abi=hard -Wl,-Map,"controller.map" -nostartfiles -static -Wl,--gc-sections -L"C:/ti/bios_6_50_01_12/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/fpu" -L"/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/fpu" -L"C:/ti/ndk_2_25_01_11/packages/ti/ndk/os/lib" "--specs=rdimon.specs" -o"controller.out"
  • char text[236];
    strcpy(text, "test" );
    Log_info1("%s", (IArg) text );
    Log_info1("%s", (IArg) "test" );

    The first line results in the logbuffer having no data for the message. The second line contains the word test as I would have expected and hoped the first would have.
  • Mike,

    The first one will not work. Log is just storing memory addresses not actual ASCII characters (so it's much faster than things like printf). When System Analyzer (or ROV) tries to decode the address of text, it looks in the .out file and looks at that address and it's not a string. Whereas for the address "test", on the second, can be resolved to the const string "test" in the .out file.

    Does that make sense?

    Todd
  • I suppose it makes sense but what good is the %s specifier for Log_info#(), Log_error#() etc if it can't format data from a char *? Maybe I'm still missing something? I mean the second case is pretty useless.

  • I agree it's an annoying limitation. You can use a pointer that points to one of several strings

    if (blah0) { ptr = "foo";}
    else if (blah1) {ptr = "bar";}
    else {ptr = "zoo";}
    Log_info2(Diags_USER1, "Count = %d, string is %s", count, ptr);

    A little cumbersome but it gives some flexibility.

    To support dynamic strings (e.g. ones on a stack or from allocated memory) would significantly change the Log module. It would have to handle ASCII characters then and this would completely violate the intent of Log which is software tracing with minimal realtime and footprint impact.

    Todd