platformio/platformio-core

PIO device monitor adds \r before echoed \n automatically

Open

#5097 opened on Mar 3, 2025

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Python (7,329 stars) (791 forks)batch import
device managementhelp wanted

Description

Hello!

Thank you all for your hard work on this project!

I was curious about whether a certain behavior was intended with regards to the serial monitor on PlatformIO. I have a STM32 attached via a USB-UART adapter to my Linux (Ubuntu 24.04) machine. When I run:

pio device monitor --port /dev/ttyUSB0 --baud 115200 --eol LF --raw

I'm expecting that only \n gets sent to the remote device when I press Enter, which I can confirm when I step through our code for the UART that receives and echoes back the same characters. However, in the terminal, it appears to print a \r automatically when an \n is transmitted from the STM32. I am quite sure that the STM32 does not transmit anything other than what it receives, so there's probably some issue with how I'm invoking the device monitor, or maybe there's a bug.

I have also tried:

pio device monitor --port /dev/ttyUSB0 --baud 115200 --eol LF --filter direct pio device monitor --port /dev/ttyUSB0 --baud 115200 --eol LF --filter default pio device monitor --port /dev/ttyUSB0 --baud 115200 --eol LF --filter nocontrol pio device monitor --port /dev/ttyUSB0 --baud 115200 --eol LF --filter printable

And even just:

pio device monitor --port /dev/ttyUSB0 --baud 115200 --eol LF

But none of them prevent a \r being added. To clarify, the behavior I'm looking for when I hit Enter to send an LF is as follows:

Typing this long string...
                          ^     <--- pressed Enter here
                          |     <--- cursor appears here

But what happens is this:

Typing this long string...
                          ^     <--- pressed Enter here
| <--- cursor appears here

How can I filter out the \r from being added before \n using the device monitor options? Will I have to specify a custom filter as seems to be described here? Or is this a possible bug?

Contributor guide