Some bizare characters prints on serial monitor with ESP-IDF hello world example

I noticed another strange output of non-printable characters to the serial port
2019-12-20_08-49-41
For verification, I received normal output in MINGW32

# python C:/msys32/home/Alexander/esp/esp-idf/tools/idf_monitor.py --port com5 --baud 115200 build/KaRadio32.elf

2019-12-20_08-49-07
as well in PuTTY
2019-12-20_08-48-51
What could be the problem?
Thanks.

What character encoding does the firmware use when sending out this string?

1 Like

All character in UTF-8

fwiw, I used “monitor_filters = direct” in platformio.ini.

2 Likes

After setting platformio.ini

monitor_filters = colorize, log2file

I got this:

(67434) J2S: Body read binaryFileLengtn 987115
[0;32mI (67452) J2S: Body read binaryFileLengtn 987970
[0;32mI (67472) J2S: Body read binaryFileLengtn 988995
I (67492) J2S: Body read binaryFileLengtn 990020
[0;32mI (67512) J2S: Body read binaryFileLengtn 991045
I (67530) J2S: Body read binaryFileLengtn 992070
I (67549) J2S: Body read binaryFileLengtn 993095
[0;32mI (67562) J2S: Body read binaryFileLengtn 993730
I (67582) J2S: Body read binaryFileLengtn 994755

Some lines are Ok with colors, others still get the ANSI esc.
Of course, before the monitor_filters I got always the Esc chars.

I am on WIN10

any ideas?

Thanks

At first I was going to say I think that colorize doesn’t do what you think it does… according to the docs:

Apply different colors for received and echo

… but, now that I’ve gotten it to mostly consistently colour print, it does actually do the ANSI colour code colours also! :man_facepalming:

Anyway, I was thinking there was nothing about ANSI colour codes there. Looking at the list of possible filters, printable sounds closer, but isn’t. I only had luck using monitor_filters = direct or monitor_flags = --raw, but that still broke after a couple of lines. For some weird reason, since it looked like the escape character itself was been eaten, I put a space before it, and now it consistently colour prints (using the direct or colorize filter).

I know this isn’t the ESP-IDF, but the issue appears to be in the monitor, not the framework used. AS you can see, something goofy happened on the second line of the program, with the indent, and then it was fine after that.

This is my paltformio.ini

; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; Redirecting...

[env:esp32dev]
;[env:stable]
;[env:esp32stable]
;platform = espressif32
;framework = espidf, arduino
framework = espidf
;platform = espressif32@1.11.2
platform = GitHub - platformio/platform-espressif32: Espressif 32: development platform for PlatformIO
board = esp32dev
;platform_packages =
; use a special branch
;framework-arduinoespressif32 @ GitHub - espressif/arduino-esp32: Arduino core for the ESP32
build_flags = -fexceptions
build_unflags = -fno-exceptions
; evaluate C/C++ Preprocessor conditional syntax
lib_extra_dirs = D:\PLATFORM_IO\WS_PIO\ESP32_OPP_OTA\lib
lib_ldf_mode = deep
board_build.partitions = partitions_two_ota_1100k.csv
;board_build.partitions = partitions_two_ota.csv

monitor_port = COM20
monitor_speed = 115200
upload_port = COM20
upload_speed = 115200

monitor_filters = colorize
;monitor_filters = colorize, log2file

And those is a pet of what I get in terminal:

Please fill free to draw your attention to other matters that do not enable to work with Platformio.
This is a minor problem. I am working even with this view!!!

Thanks for your nice job.

1 Like

Hm… that is looking exactly the same as mine was… the line before it plays up, there is a gap, almost as if the monitor thought there was a \t tab character, and then the next line looks like the esc character was dropped, thus losing the formatting. Your output it least recovered on the next line… mine stayed broken from then onwards.

In your output routine, are you able to put a space, or some other character before the esc character/code? As that is what has settled mine down. It’s as if sometimes it just drops the leading character from the line, which happens to be the esc character.

1 Like

I thanks for your suggestion.
I will do it next time.
It is not the most important feature.
Does not cause any trouble, but, of course it will be nice.
The lack of the possibility to send commands via terminal it was more important.
I have to use a third part one but it is not the best!
Thanks again for your suggestion.

1 Like

I have in my latest version of PlatoformIO’s platformio,ini file:

; Serial Monitor options    
monitor_speed = 115200
monitor_flags = --raw

and that now works in the PlatformIO monitor in VSCode in Linux.

image

Raw does work for getting rid of the unwanted whitespace!
Sadly we can’t do

monitor_filters = esp32_exception_decoder
monitor_flags = --raw

(i.e. setting --raw disables the exception decoder)

Which is bad since the unwanted white space tends to break the exception decoder, but to fix it you also have to disable the exception decoder.

Setting

monitor_filters = direct, esp32_exception_decoder

also doesn’t help (from docs)?

@maxgerhardt
Wow! quick response

Sadly that’s invalid:

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
Error: 'raw'
The terminal process "C:\Users\kimchips\.platformio\penv\Scripts\platformio.exe 'device', 'monitor'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

raw seems only valid as a flag not a filter

Sorry I meant direct instead of raw. monitor_filters = direct, esp32_exception_decoder

3 Likes

oh that does work!
fantastic. thank you!!

i feel like this should be the default behaviour for this platform

And the esp32_exception_decoder in PlatformIO is absolutely fantastic.
throwing some props around the house

Adding a space before the escape sequence seems to make the ansi decoding more reliable in VSC terminal.
I have documented it here

You can find additional info by the link1 and link2
My variety with platformio.ini file:

[env:core2foraws]
platform = espressif32@3.2.1
framework = espidf
board = m5stack-core2
monitor_speed = 115200
monitor_raw = yes

For those with win 10 and just scrolled to the end, this is what I did.

@Thomseeen mentions steps, but this is a slightly shorten version.

  1. Change your powershell to support ansi encoding globally by running in power shell:
    Set-ItemProperty HKCU:\Console VirtualTerminalLevel -Type DWORD 1
    See this link for alternatives to this “global” change, here
  2. Add this line/setting to you platformio.ini file:
    monitor_raw=yes

Make sure to you restart that monitor.