I have an ESP3S3 chip connected to my laptop through its USB. I want to see the output of the board on the esp-idf-cmd terminal while also being able to save the terminal output (say as a .txt file) while it's still running. ( I have a few tests that I want to do on the board output with some .py scripts I have on my pc)
idf.py -p PORT flash monitor > log.txt
this does not do what I want, it only saves AFTER the program stops running, I don't have that guarantee, the program might crash, but I still want that log up until that point, also if I do this I won't be able to use the ctrl+] to exit my esp-program.
idf.py -p PORT flash monitor | tee log.txt
this causes encoding issues and several attempts to go around this seem not to work.
"encodings\cp1252.py", line 19, in encodeUnicodeEncodeError: 'charmap' codec can't encode character '\ufffd' in position 0: character maps to <undefined>
I'm not sure what direction I should even take this.
Looking at idf.py documentation it seems like the shortcut Ctrl-T
Ctrl-L
enables logging to file.
Dumping output of monitor into a file with tee
is fine as well, you just have to remember that this is not a text file, but raw data stream from UART. It includes console escape sequences for coloured text. You can dump it to your terminal as is with cat logfile.txt
. If you don't want coloured output, look at this post on how to remove the escape sequences.
As an alternative you can build your ESP32 project to output log without colour.