PlatformIO Community

Serial Monitor adding escape char

Hi all,

I am trying to send a message over serial monitor that contains:

something\nsomething

My issue is the serial monitor seems to detect the escape char and escapes it again as the message received is:

something\\nsomething

I have tried adding the monitor flags below:

monitor_flags
    default
    direct
    nocontrol

image

Nothing seems prevent the additional \ being added…

Thanks.

And without any monitor_flags and setting monitor_eol = LF?

Hi Max,

image

Same result…
If I manually press enter to send the LF in simulation (meaning using monitor in PIO), instead of using the LF char, it works… but the program I am working with is being sent a string in the format shown in screenshot (minus the additional \). So, when I attempt to send the string in their format (in simulation, again) this extra escape char is being added.

Ah, I missed this in the documentation:
image

This is really weird, if tempUserInput just comes from e.g. Serial.readString(); then it should have all the original characters, and pressing enter in the device monitor should send an actual 0x0a (=’\n’) character, not backslash followed by ASCII n.

How do you fill tempUserInput with data?

while (Serial.available())
    {
        receiving = Serial.read();
...
}

I turned on debug for the serial port and it looks like miniterm itself is adding the extra \ to the stream:
image

If I just type the escape char it seems to be automatically escaped and sent:
image