PlatformIO Community

How do I get the text printed to the Terminal to a file?


#1

I have a balancing robot running, but it needs tweaking. I can print values to the Terminal faster than I can read. So, after a program run, how do I get the text to a file to see what happened?

Currently, I am using Copy(Ctrl-C). And that works fine for a little data. But, it does not scale up.

Usually, “Select All” is Ctrl-A. But in PlatformIO Terminal, Ctrl-A closes the window. If I scroll down, the cursor reference is lost. So, Shift-Click does not work. Page-Down has no effect. End has no effect.

Loop, Angle Now, Angle Desired, Angle Error, Angle tIntegral, dif, Angle Output, Left power, Right power, (nchuk.joyY(), (nchuk.joyY()-127), Speed Desired, Filtered, Speed Now, Speed Error, Speed tIntegral, Costrained Intergral, Speed Output, Constrained Output
691, 2.59, 0.00, 2.59, 2.59, -38.76, 46.53, 46.53, -46.53, 127, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
693, 1.79, 0.00, 1.79, 4.38, -37.24, 32.82, 32.82, -32.82, 127, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
695, 1.07, 0.00, 1.07, 5.44, -31.59, 20.43, 20.43, -20.43, 127, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
696, 0.62, 0.00, 0.62, 6.07, -31.63, 12.19, 12.19, -12.19, 127, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
698, 0.03, 0.00, 0.03, 6.09, -25.79, 1.44, 1.44, -1.44, 127, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
699, -0.31, 0.00, -0.31, 5.79, -24.41, -5.24, -5.24, 5.24, 127, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00

Once the data is in a file, I can plot it in Excel or a better graphing package to try to understand the sequence of events.

Does anyone have an idea of how I can do this?

PS: Copy is Ctrl-C. But, In PlatformIO Terminal, Ctrl-C is also used to stop execution.


#2

I haven’t got PIO for VSCode but for simplicity I’d recommend to just open hterm, let it run, then save the output text to a file.


#3

Right click and ‘Select All’ and then either right click and 'Copy or ‘Ctrl+Shift+C’? The shift keyboard modifier would have been added since this is a terminal, and Ctrl+C is normally used to signal the running program to exit.


#4

Because of this issue, I have switched to External Xterm. Now . . . When in PlatformIO, if I compile a program then load that program, then I can click the A/C plug and I go to the Terminal window. At that point the right-click has no function.

I have switched back to the default renderer Type AUTO.


#5

Control+C to stop execution only works if the Terminal window is active. Obviously, if another window is active, Control+C will not stop execution of the Terminal window.

Right+click in the Terminal window does not do anything on my machine. However, mouse select and Control+C does copy the text.

Control+A =?


#6

Hm… Might only be on Linux (pretty sure that’s where I was when I gave the shortcuts before)… my windows install doesn’t seem to have a right-click menu… it instead behaves likes a Linux terminal and pastes whatever text is in the clipboard… :-/

The VSCode shortcuts reference guide only admits to a handful of keyboard shortcuts for the terminal, and none are of any help…

I would either do what max suggested and use an external serial monitor… hterm, putty, minicom, etc… and then either do a save as or use their integrated logging (i.e. minicom can be set the log to file as well as output to screen, putty has a copy all to clipboard allowing you to paste it into a file, etc) … or perhaps run pio device monitor manually (pio device monitor -- help for details on parameters) and do a ‘>’ or ‘>>’ to redirect output to a file (can probably have output on screen and saved to file if piped via tee if you are on Linux).


#7

I am currently using Windows 7. While in the PlatformIO Terminal window, Control+A seems to close the window. In general, I have moved on to hterm. It has a "Save output" button. I print my variable values in CSV form, then I can see the text of the data in Excel and/or charts of the data in Veusz.