PRINTF in KDS (fixed width fields no joy)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PRINTF in KDS (fixed width fields no joy)

7,636 Views
aerodame
Contributor III

Hi I'm noticing that in KDS 2.0 the PRINTF in "fsl_debug_console" is still missing some features.  Namely the %.wx does not properly print a formatted output of fixed width.

 

For example...

for(i=0; i < 16; i++) {

    PRINTF("[%.2d : %.2x]",i,i);

}

 

Yields:

[0 : 0][1 : 1][2 : 2][3 : 3]...[14 : e][15 : f]

 

Whereas is should print:

[00 : 00][01 : 01][02 : 02][03 : 03]...[14 : 0e][15 : 0f]

 

Did someone forgot to implement the "dot" formatting for fixed width output formats?

 

Labels (1)
0 Kudos
4 Replies

1,173 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Stephen,

When use this form,  %2d,if the data i  = 3;  it can print one black space and  3.

Like this :

pastedImage_0.png

My Code is like this , i use KDS v3.2 , KSDK v2.0 .

pastedImage_1.png

Does this can meet your demand ?

Hope it helps

Alice

0 Kudos

1,173 Views
aerodame
Contributor III

I don't think you completely understood the bug that I am reporting.  Please compile the following code on a GCC compiler so you can see what the proper formatting result is (as shown below).  If you run this code in the fsl_debug_console (using the PRINTF) it doesn't faithfully implement the 'dot' syntax for %d or %x formats.

=================== GCC TEST CODE ======================

#include <stdio.h>

int main(int argc, char **argv) {

    int i;

    for(i=0; i < 256; i++) {

        if((i % 8) == 0)  printf("\r\n");

        printf("[%.3d : %.2x]",i,i);

    }

    printf("\r\n");

}

=================== OUTPUT RESULT ======================

[000 : 00][001 : 01][002 : 02][003 : 03][004 : 04][005 : 05][006 : 06][007 : 07]

[008 : 08][009 : 09][010 : 0a][011 : 0b][012 : 0c][013 : 0d][014 : 0e][015 : 0f]

[016 : 10][017 : 11][018 : 12][019 : 13][020 : 14][021 : 15][022 : 16][023 : 17]

[024 : 18][025 : 19][026 : 1a][027 : 1b][028 : 1c][029 : 1d][030 : 1e][031 : 1f]

[032 : 20][033 : 21][034 : 22][035 : 23][036 : 24][037 : 25][038 : 26][039 : 27]

[040 : 28][041 : 29][042 : 2a][043 : 2b][044 : 2c][045 : 2d][046 : 2e][047 : 2f]

[048 : 30][049 : 31][050 : 32][051 : 33][052 : 34][053 : 35][054 : 36][055 : 37]

[056 : 38][057 : 39][058 : 3a][059 : 3b][060 : 3c][061 : 3d][062 : 3e][063 : 3f]

[064 : 40][065 : 41][066 : 42][067 : 43][068 : 44][069 : 45][070 : 46][071 : 47]

[072 : 48][073 : 49][074 : 4a][075 : 4b][076 : 4c][077 : 4d][078 : 4e][079 : 4f]

[080 : 50][081 : 51][082 : 52][083 : 53][084 : 54][085 : 55][086 : 56][087 : 57]

[088 : 58][089 : 59][090 : 5a][091 : 5b][092 : 5c][093 : 5d][094 : 5e][095 : 5f]

[096 : 60][097 : 61][098 : 62][099 : 63][100 : 64][101 : 65][102 : 66][103 : 67]

[104 : 68][105 : 69][106 : 6a][107 : 6b][108 : 6c][109 : 6d][110 : 6e][111 : 6f]

[112 : 70][113 : 71][114 : 72][115 : 73][116 : 74][117 : 75][118 : 76][119 : 77]

[120 : 78][121 : 79][122 : 7a][123 : 7b][124 : 7c][125 : 7d][126 : 7e][127 : 7f]

[128 : 80][129 : 81][130 : 82][131 : 83][132 : 84][133 : 85][134 : 86][135 : 87]

[136 : 88][137 : 89][138 : 8a][139 : 8b][140 : 8c][141 : 8d][142 : 8e][143 : 8f]

[144 : 90][145 : 91][146 : 92][147 : 93][148 : 94][149 : 95][150 : 96][151 : 97]

[152 : 98][153 : 99][154 : 9a][155 : 9b][156 : 9c][157 : 9d][158 : 9e][159 : 9f]

[160 : a0][161 : a1][162 : a2][163 : a3][164 : a4][165 : a5][166 : a6][167 : a7]

[168 : a8][169 : a9][170 : aa][171 : ab][172 : ac][173 : ad][174 : ae][175 : af]

[176 : b0][177 : b1][178 : b2][179 : b3][180 : b4][181 : b5][182 : b6][183 : b7]

[184 : b8][185 : b9][186 : ba][187 : bb][188 : bc][189 : bd][190 : be][191 : bf]

[192 : c0][193 : c1][194 : c2][195 : c3][196 : c4][197 : c5][198 : c6][199 : c7]

[200 : c8][201 : c9][202 : ca][203 : cb][204 : cc][205 : cd][206 : ce][207 : cf]

[208 : d0][209 : d1][210 : d2][211 : d3][212 : d4][213 : d5][214 : d6][215 : d7]

[216 : d8][217 : d9][218 : da][219 : db][220 : dc][221 : dd][222 : de][223 : df]

[224 : e0][225 : e1][226 : e2][227 : e3][228 : e4][229 : e5][230 : e6][231 : e7]

[232 : e8][233 : e9][234 : ea][235 : eb][236 : ec][237 : ed][238 : ee][239 : ef]

[240 : f0][241 : f1][242 : f2][243 : f3][244 : f4][245 : f5][246 : f6][247 : f7]

[248 : f8][249 : f9][250 : fa][251 : fb][252 : fc][253 : fd][254 : fe][255 : ff]

0 Kudos

1,173 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Stephen,

Sorry for reply you late .

Please use %02 instead of %.2

eg:

for(i=0; i < 16; i++) { PRINTF("[%02d : %02x]",i,i);


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,173 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Stephen,

I know your meaning,  i have reported it to  KDSK team,

i will tell you when get reply .ASAP .

BR

Alice

0 Kudos