Skip to content

Commit 6e0a63d

Browse files
author
Amanda Butler
authored
Add suppressing output content to FileHandle.md
Apply changes from PR #1167 to avoid merge conflicts.
1 parent 94389ea commit 6e0a63d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/api/platform/FileHandle.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ namespace
130130

131131
Alternatively, an application could use the standard C `freopen` function to redirect `stdout` to a named file or device while running. However there is no `fdreopen` analog to redirect to an unnamed device by file descriptor or `FileHandle` pointer.
132132

133+
#### Suppressing console output
134+
135+
To always suppress output, you can provide an `mbed_override_console` that returns a sink class that discards output. (For UART console targets, you can simply set `target.console-uart` to `false` in your `mbed_app.json`.)
136+
137+
To temporarily suppress output, `mbed_override_console` can return a class that acts as a switchable mux between a sink and the real output.
138+
139+
More portably, you could ensure all your code uses your own `FILE *output_stream` rather than `stdout`, and you could dynamically change that between `stdout` and `fdopen(Sink)`. That then doesn't rely on "under C library" retargeting of `stdout`. Instead, you must switch streams at the application level.
140+
133141
### Polling and nonblocking
134142

135143
By default, `FileHandle`s conventionally block until a `read` or `write` operation completes. This is the only behavior supported by normal `File`s, and is expected by the C library's `stdio` functions.

0 commit comments

Comments
 (0)