Skip to content

Commit d835073

Browse files
marcuschangarmevedon
authored andcommitted
Add support for fprintf and vfprintf (#21)
Debug print is routed to stderr which relies on [v]fprintf. This change adds support for overwriting the build-in [v]fprintf.
1 parent 96b5c1d commit d835073

File tree

14 files changed

+295
-77
lines changed

14 files changed

+295
-77
lines changed

features/minimal-printf/Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def buildStep(target, compilerLabel, toolchain) {
7676
sh "mbed new ."
7777

7878
// use default release profile for ARM and IAR.
79-
sh "mbed test -vv --compile -m ${target} -t ${toolchain} -n '*minimal-printf*' --build ci --stats-depth 10"
79+
sh "mbed test -vv --compile -m ${target} -t ${toolchain} -n '*minimal-printf*' --build ci --stats-depth 10 --app-config ./TESTS/minimal-printf/compliance/test_app.json"
8080

8181
// stash build directory for testins step.
8282
stash name: "minimal-printf-greentea-${target}-${toolchain}", includes: "ci/**"

features/minimal-printf/README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22

33
Library supports both printf and snprintf in 1252 bytes of flash.
44

5-
Prints directly to stdio/UART without using malloc. All flags and precision modifiers are ignored. Floating point is disabled by default.
5+
Prints directly to stdio/UART without using malloc. All flags and precision modifiers are ignored.
6+
Floating point is disabled by default.
7+
Printing to a FILE stream is enabled by default.
68

79
Supports:
810
* %d: signed integer [h, hh, (none), l, ll, z, j, t].
911
* %i: signed integer [h, hh, (none), l, ll, z, j, t].
1012
* %u: unsigned integer [h, hh, (none), l, ll, z, j, t].
11-
* %x: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., FF).
13+
* %x: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., ff).
1214
* %X: unsigned integer [h, hh, (none), l, ll, z, j, t], printed as hexadecimal number (e.g., FF).
1315
* %f: floating point (disabled by default).
14-
* %F: floating point (disabled by default).
15-
* %g: floating point (disabled by default).
16-
* %G: floating point (disabled by default).
16+
* %F: floating point (disabled by default, treated as %f).
17+
* %g: floating point (disabled by default, treated as %f).
18+
* %G: floating point (disabled by default, treated as %f).
1719
* %c: character.
1820
* %s: string.
1921
* %p: pointer (e.g. 0x00123456).
2022

23+
Unrecognized format specifiers are treated as ordinary characters.
24+
25+
Floating point support:
26+
* Floating point is disabled by default.
27+
* All floating points are treated as %f.
28+
* No support for inf, infinity or nan
29+
2130
To replace the standard implementations of the printf functions with the ones in this library:
2231

2332
* Add the library to your project.
@@ -28,7 +37,7 @@ To replace the standard implementations of the printf functions with the ones in
2837
$ mbed compile -t <toolchain> -m <target> --profile mbed-printf/profiles/release.json
2938
```
3039

31-
## Enabling floating point, 64 bit integers, new line conversion, and setting baud rate
40+
## Enabling floating point, FILE stream, 64 bit integers, new line conversion, and setting baud rate
3241

3342
In mbed_app.json:
3443

@@ -37,7 +46,8 @@ In mbed_app.json:
3746
"*": {
3847
"platform.stdio-baud-rate": 115200,
3948
"platform.stdio-convert-newlines": false,
40-
"minimal-printf.enable-floating-point": false,
49+
"minimal-printf.enable-file-stream": true,
50+
"minimal-printf.enable-floating-point": true,
4151
"minimal-printf.set-floating-point-max-decimals": 6,
4252
"minimal-printf.enable-64-bit": true
4353
}

0 commit comments

Comments
 (0)