Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: mbed-os/features/unsupported/tests/mbed/freopen/main.cpp
- Revision:
- 0:6bf0743ece18
diff -r 000000000000 -r 6bf0743ece18 mbed-os/features/unsupported/tests/mbed/freopen/main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os/features/unsupported/tests/mbed/freopen/main.cpp Sat Mar 28 15:28:19 2020 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+
+#if !DEVICE_LOCALFILESYSTEM
+ #error [NOT_SUPPORTED] LocalFileSystem not supported
+#endif
+
+#include "TextLCD.h"
+
+int main() {
+ printf("printf to stdout\n");
+
+ // printf to specific peripherals
+ Serial pc(USBTX, USBRX);
+ pc.printf("Serial(USBTX, USBRX).printf\n");
+
+ TextLCD lcd(p14, p15, p16, p17, p18, p19, p20, "lcd"); // rs, rw, e, d0-d3, name
+ lcd.printf("TextLCD.printf\n");
+
+ // change stdout to file
+ LocalFileSystem local("local");
+ freopen("/local/output.txt", "w", stdout);
+ printf("printf redirected to LocalFileSystem\n");
+ fclose(stdout);
+
+ // change stdout to LCD
+ freopen("/lcd", "w", stdout);
+ printf("printf redirected to TextLCD\n");
+ fclose(stdout);
+
+ DigitalOut led(LED1);
+ while (true) {
+ led = !led;
+ wait(1);
+ }
+}