#49 vTaskList() and vTaskGetRunTimeStats() formatting

v1.0 (example)
closed-wont-fix
nobody
None
5
2014-04-24
2012-07-02
No

The formatting in vTaskList() and vTaskGetRunTimeStats() is done with tabs, which does not work good when you have tasks with both short and long names. To have everything in columns use width specifier of printf function. The width is taken from configMAX_TASK_NAME_LEN. If configMAX_TASK_NAME_LEN would not have paranethesis it could even be used directly in the format string, but it does (in every demo) so it cannot be quoted (or I don't know how to do it).

Patch attached.

Discussion

  • Freddie Chopin

    Freddie Chopin - 2012-07-02
     
    Attachments
  • Freddie Chopin

    Freddie Chopin - 2012-07-02

    updated patch that's better - all fields (but last one) have width specifiers, so that columns never break. I have some doubts about this line:
    sprintf( pcStatsString, ( char * ) "%-*s\t0\t\t0%%\r\n", configMAX_TASK_NAME_LEN, pxNextTCB->pcTaskName );
    my terminal prints tab as 8 spaces, so two tabs are necessary between the zeroes. maybe using 10 spaces (something like -11 width specifier with 0) and one tab would be a more generic solution?

     
  • Freddie Chopin

    Freddie Chopin - 2012-07-02

    version with 10 spaces and 1 tab for "double 0"

     
    Attachments
  • Freddie Chopin

    Freddie Chopin - 2012-07-02

    I've uploaded a v1 patch that has 10 spaces and 1 tab in this line

     
  • Richard

    Richard - 2012-07-02
    • status: open --> pending
     
  • Richard

    Richard - 2012-07-02

    I think the reason it is not done like this is because not all of the 20 or so libraries used with FreeRTOS support extended formatting, and instead just print out the characters.

    I will look at it all the same. It might be a goer if the cut down super stack friendly sprintf() that is used in lots of the FreeRTOS demos can cope with it, although previous attempts to change the formatting have been abandoned.

     
  • Freddie Chopin

    Freddie Chopin - 2012-07-02
    • status: pending --> open
     
  • Freddie Chopin

    Freddie Chopin - 2012-07-02
    • status: open --> pending
     
  • Freddie Chopin

    Freddie Chopin - 2012-07-02

    The cutdown printf does support width, padding and alignment:

    ...
    if (*format == '-') {
    ++format;
    pad = PAD_RIGHT;
    }
    while (*format == '0') {
    ++format;
    pad |= PAD_ZERO;
    }
    for ( ; *format >= '0' && *format <= '9'; ++format) {
    width *= 10;
    width += *format - '0';
    ...

    (taken from LPC1768 GCC Rowley demo)

    The problem is that it does not support '*' to pass the width, and you cannot do QUOTEME() with the macro from FreeRTOSConfig.h, as it has paranethesis... /;

     
  • Freddie Chopin

    Freddie Chopin - 2012-07-02

    so... maybe use fixed width for names? 16 chars? "%15s\t"? it would work with longer names, but then these will not be "in line" with shorter names, so pretty much the same as now...

     
  • Freddie Chopin

    Freddie Chopin - 2012-07-02

    on the other hand - adding support for '*' is just adding this:

    if (*format == '*') {
    ++format;
    width = va_arg( args, int );
    }

    below this:

    for ( ; *format >= '0' && *format <= '9'; ++format) {
    width *= 10;
    width += *format - '0';
    }

    in
    static int print(char **out, const char *format, va_list args )

     
  • Real Time Engineers ltd.

    This is a good suggestion, but its not going to be taken up due to the overhead of testing with so many different library implementations. Also the end user has the ability to manually adjust name lengths, or truncate the number of characters used to force alignment. Finally the function in question is a 'helper' function rather than part of the real time kernel's functionality itself.

     
  • Real Time Engineers ltd.

    • status: pending --> closed-wont-fix
    • Group: --> v1.0 (example)
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks