Hello,
I do not know what steps, but you can use library what is mentioned here
Br, Jan
Hello,
I do not know what steps, but you can use library what is mentioned here
Br, Jan
Thank you for the response. I tried that as well. It got rid of the errors, but outputs strange question mark symbols. I am unsure as to why. No actual output. Just question mark symbols.
Are you just trying to print to the console? Or are you trying to talk to an external device?
If you are trying to use the console, you just need to use the printf()
function, and not create any BufferedSerial objects. It’s possible that having two serial objects created at the same time is causing your issues.
Hmm. Is this an official Mbed board, or a custom one? If it’s an official board, doing
#include <mbed.h>
int main()
{
printf("Hello World\n");
while(true) {}
return 0;
}
should cause text to show up in the console, without any special configuration in mbed_app.json. What board are you using?
You cannot expect anyone to fix this is you have not told us the basics. Namely:
What Mbed version are you using?
What board are you using?
Then next time stick to asking the same question in one place on the forum… you’ve asked it in two different places.
I just saw this and tried it. It just ran the program, with no errors, and then disconnected from the device with no output.
When I tried running in debug mode, it stops on the printf line and then when I try to step forward, it just gets stuck processing. I know that must be strange. I am trying my best to explain what I am seeing. I must apologize for my lack of knowledge as it seems some are bothered by it. I am learning.
I am using a Nucleo L47RG and mbed 6.15.1.
Edit: Here is the exact message I receive:
Reset completed
Add Flash Algorithm…
‘STM32L4xx 1MB Flash’ (0x08000000 - 0x080fffff)
Load application…
Erase sectors…
Sectors erased in 0.926 seconds
Program flash…
Flash programmed in 1.794 seconds
Verify flash download…
Flash download verified in 1.242 seconds
Reset & run target…
Disconnect from device…
Disconnect from debug unit…
Best option would be create a new topic and try to describe your issue. If you have problems with description of your problem, then one picture is more than thousands words.
So stay with this simple project and try to solve it until you get a positive result. This have to work!
If you expect an output “Hello World”, then that is the problem. Here you will see only output from the KSC.
You need to install a Serial terminal application like, Puty or Termite or YAT or TeraTerm. Then Open a COM port of your ST-link (driver need to be installed from ST websides) and then you will see the output “Hello World”
BR, Jan
Good news! It works on the MBED Studio IDE, but not with the online Keil Studio version. I will now try with my humidity sensor and try to see if it will print the information on that. Thank you!
Thank you. Will do.
Both (MbedStudio and Keil Studio Cloud) have built in Serial Monitor window, however only with MbedStudio it will work automatically for you. In the KSC it is working only for targets with DAP-Link (i think), but definitely not with ST-Link targets. That is why you need external app.
BR, Jan
This article is a goldmine of information! Thank you for taking the time to research and share your work.
I really struggled for some time to get my mbed OS2 programs, with serial comms code, to run under OS6. (to the extent that I gave up for a while, reverting to Arduino IDE for STM32 rapid prototyping).
Although I have a background in embedded C , I’m not confident with C++. I find the mbed OS6 documentation absolutely awful; it may have all functions and methods neatly listed, but I find it very terse and there are very few example code snippets or beginners guides on how to use in practice.
Your article should be held up as a perfect example for new starters to mbed OS6 serial comms.
Based on this, arduino mbed framework which is also used by PlatformIo provides a macro to redirect
stdout/stderr/stdnin to the “Serial” class.
The default serial speed is defined in :
.platformio/packages/framework-arduino-mbed/variants/OPTA/conf/mbed_app.json
The header file ‘macro.h’ could be found at:
.platformio/packages/framework-arduino-mbed/cores/arduino/macros.h
#include <macros.h>
REDIRECT_STDOUT_TO(Serial);
Then simply use printf()
other functions that would output to stdout/stderr (read from stdin).