Managing Serial port output and saving log file

Hi - wondering is there a way to get more out of the Serial port output:

  1. Is it logged to a file (or is there an option to do so ?)
  2. Is an option to adjust the max buffer size …I’d like it to be able to store a lot before it starts to loose the old logged shown data and it begins to automatically scroll (which can be annoying :frowning:
  3. Can I turn on and off the auto scroll (something simple like Arduino IDE Serial check box) would be great :wink:

BTW: really enjoying transition from Arduino IDE to PlatformIO — its a powerful tool !

Hi mars,

the serial monitor that is used by pio just uses your base console/terminal (whichever OS you are using). That means you can achieve

  1. by redirecting the stream to a file with the base-tools of your console/terminal. Under windows this can be achieved with >. An example, start the serial monitor in the console with pio device monitor and redirect the output to a file named test.txt by typing pio device monitor > test.txt.
  2. This is also something that is connected to your console/terminal settings so just google how to increase its buffer.
  3. Once again, a setting that can be set for most terminals/consoles… google should help too.
3 Likes

Hi,
Thanks for this very good hint.
To make it totally clear to beginners (I am one), in the Mac OSX environment, that means:

  • launch terminal from within PlatformIO
  • type: pio device monitor > logFile.txt
    To exit : ctrl + C
    The file logFile.txt will be in the same folder as the files related to the project opened at the time of Terminal launch.

That is VERY convenient.

3 Likes

Hi everyone!
I’d like to add something to François’s first point:

  • In PlatformIO, go to “PIO Home” > “Quick Access” > “Miscellaneous” > “New Terminal” and THEN input the pio device monitor > logFile.txt or platformio device monitor > logFile.txt command.
  • BEWARE, that terminal should have "PlatformIO"as a title (not “powershell”) /!\

I missunderstood your first point initially, thinking that the command should be in put in the powershell or cmd terminal, I was getting the infamous " platformio (or pio) is not recognized as an internal or external command ".

Cheers…

… and [solved] :slight_smile:

PS: On another note, one can use software like Baretail to follow the monitor, it will display the logs dynamically!

I was looking for something built in so it “just worked” the docs here tell you how!

https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html

key part is add to platform.ini this code

[env:log_output_to_file]

platform = …
monitor_filters = default, log2file

2 Likes