Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic printf does not show messages in the monitor (Read 300 times)
RichardK
Junior Member
**
Offline


Posts: 62
Joined: Jul 11th, 2023
printf does not show messages in the monitor
Dec 25th, 2024 at 9:43pm
Print Post  
Since some time printf messages are not shown in the monitor window for my Raspberry (Pico W, Pico 2) projects any more. Some time ago this worked fine. Serial.print* works fine all the time.

Since I found no documentation to all the debug settings: Does any of the following settings do affect the usability of printf?

  Debug/Release on the Visual Studio Symbols
  Debug: (Serial/Arduino/Hardware/Off) on the Visual Studio Symbols
  vMicro Icon: Option 8 (Debug Port)
  vMicro Icon: Option 9 (Debug Level)

Which combinations of these settings should be used/not be used?

Is there a link to the documentation of all the various VisualMicro settings in Visual Studio?

Thanks
Richard
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2626
Joined: Feb 13th, 2019
Re: printf does not show messages in the monitor
Reply #1 - Jan 2nd, 2025 at 12:58pm
Print Post  
Thanks for the report.

When using the vMicro "Debug: Serial" option, any lines you print to the serial monitor must have a line terminator (\n) present otherwise they will not be displayed.

When using "Debug: Off" or "Debug: Hardware" the Serial output should be unaffected by the line terminators.

Do you have some simple example code we can replicate the issue with? (Please attach as a text file)

Also have you upgraded the RP2040 Board Package since it worked in the past?
  
Back to top
IP Logged
 
RichardK
Junior Member
**
Offline


Posts: 62
Joined: Jul 11th, 2023
Re: printf does not show messages in the monitor
Reply #2 - Jan 2nd, 2025 at 1:42pm
Print Post  
Yes, I have updated to the latest RP2040 board package - I used RP20040/RP2350 4.4.0, and after updating to 4.4.1 the problem remains.

I use
Code (C++)
Select All
void show_gcc_version()
{
  Serial.println("Examples: Various ways to print the GCC Version ");
  Serial.print("1. Serial.println GCC Version: ");
  Serial.print(__GNUC__); Serial.print(".");
  Serial.print(__GNUC_MINOR__); Serial.print(".");
  Serial.println(__GNUC_PATCHLEVEL__);
  // the same with printf in the C way
  printf("2. Printf GCC Version: %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
  // the same with std::cout, requires #include <iostream>
  // and a board with enough memory (see section 3.2.1.1)
#ifndef SMALL_MEMORY // A board with not enough memory for std::cout
  std::cout << "3. std::cout GCC Version: " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << std::endl;
#endif
  std::string vs = "std::string GCC Version: " +
    std::to_string(__GNUC__) +
    "." + std::to_string(__GNUC_MINOR__) +
    "." + std::to_string(__GNUC_PATCHLEVEL__);
  printf("%s\n", ("4. printf " + vs).c_str()); // printf in the C++ way
  Serial.println(("5. Serial.println " + vs).c_str());
  // 5. Serial.println accepts char* arguments, but not std::string
                                                     // arguments
  Serial.printf("6. Serial.printf %s\n", vs.c_str());
}
 



and get only (2., 3. and 4. are not shown in the monitor window)
Code
Select All
Examples: Various ways to print the GCC Version
1. Serial.println GCC Version: 14.2.0
5. Serial.println std::string GCC Version: 14.2.0
6. Serial.printf std::string GCC Version: 14.2.0
 



Best
Richard
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2626
Joined: Feb 13th, 2019
Re: printf does not show messages in the monitor
Reply #3 - Jan 2nd, 2025 at 3:15pm
Print Post  
Thanks for the code snippet.

Testing between different board package versions on the RPi Piico 2 Board (and checking in external Serial Monitors and Arduino 2 IDE):

4.1.1 -- pqt-gcc\4.0.1-8ec9d6f -- Fails for printf()
4.0.3 - pqt-gcc\2.3.0-dfd82b2 -- Fails for printf()
4.0.2 - pqt-gcc\2.2.0-d04e724 -- Fails for printf()
(same as 4.0.2 back to 4.0.0 where Pico2 is added)

Is there any reason not to use the Serial.printf() function as you have in entry #6 in the code snippet, as this works in all cases?

It may be best to contact the board package creator, as they produce the compiler and toolchain in use.
  
Back to top
IP Logged
 
RichardK
Junior Member
**
Offline


Posts: 62
Joined: Jul 11th, 2023
Re: printf does not show messages in the monitor
Reply #4 - Jan 3rd, 2025 at 2:23pm
Print Post  
Hi Simon,

my reason to prefer std::printf over Serial.printf() is to use C++ standard library features in my lectures.

I have asked Earle Philhower in the meantime.

Thanks
Richard 
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint