Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Serial monitor : handling control codes, specifically BACKSPACE. (Read 2058 times)
Asmodyne
Newbies
*
Offline


Posts: 7
Location: Fr
Joined: Nov 1st, 2019
Serial monitor : handling control codes, specifically BACKSPACE.
Dec 2nd, 2021 at 7:15pm
Print Post  
Hi there.

Is there a way to enable handling of ASCII control codes such as backspace in the serial monitor (i.e, '\b') ?   Roll Eyes

This would greatly improve the readability when monitoring long iterations and such.  Cheesy

Best regards. 
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2704
Joined: Feb 13th, 2019
Re: Serial monitor : handling control codes, specifically BACKSPACE.
Reply #1 - Dec 3rd, 2021 at 11:54am
Print Post  
Outbound Data From Serial Monitor
If this is for sending to the board as outbound data, the "Cstr" button can be enabled at the top right of the Serial Monitor.

Inbound Data to Serial Monitor
At present the inbound data does not handle the \b or Serial.Write(8) codes and just produces a square.  The line terminator (\n) and tab (\t) escapes for example work correctly.

If it is for inbound data to the monitor, can you describe a simple scenario where you would want to remove the char from the monitor in this way? (instead of remove it from the buffer before sending to the PC).

Other applications can be used for the inbound data (e.g. CoolTerm, with Terminal>Handle BS and DEL Enabled), and we can investigate this for a future release once we understand it further.

  
Back to top
IP Logged
 
Asmodyne
Newbies
*
Offline


Posts: 7
Location: Fr
Joined: Nov 1st, 2019
Re: Serial monitor : handling control codes, specifically BACKSPACE.
Reply #2 - Dec 3rd, 2021 at 4:54pm
Print Post  
Hello Simon, thanks for the fast reply.

Yes, it is for inbound data. 
Here, i'll write a naive little arduino stub, on the fly, as an example.

Code
Select All
void loop()
{
   float value = sensor.getCurrentValue();
   if(!isNan(value)){
      printf("\b\b\b\b%01.2f units", value);      
  }
  delay(20);
}
 



( Yes, in this example, the "backspace" codes could be replace by a carriage return, but that's not the point )

Of course, the actual usage of backspace would appear in a much more format-and-values-heavy inbound trace, but you get the gist of it. Backspace is here to roll back on the previous value text and write a new one at the same text index.


« Last Edit: Dec 3rd, 2021 at 4:55pm by Asmodyne »  
Back to top
 
IP Logged
 
Cong Quyen Knight
Junior Member
**
Offline


Posts: 22
Joined: Nov 29th, 2021
Re: Serial monitor : handling control codes, specifically BACKSPACE.
Reply #3 - Dec 9th, 2021 at 12:11am
Print Post  
As I understand, you wanna remove '\b' as a garbage in recv buffer of serial monitor, right?
For hardware serial, receiving data is handle by a interrupt handle.
You could ignore that '\b' directly inside it.

Please refer function HardwareSerial::_rx_complete_irq in C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial_private.h
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor : handling control codes, specifically BACKSPACE.
Reply #4 - Dec 9th, 2021 at 12:38am
Print Post  
I think it is the read of string and display in std. windows textbox control that strips escape chars.

We are going to look at something but it will have to be enabled by users, for example Terminal Mode.
  
Back to top
IP Logged
 
Asmodyne
Newbies
*
Offline


Posts: 7
Location: Fr
Joined: Nov 1st, 2019
Re: Serial monitor : handling control codes, specifically BACKSPACE.
Reply #5 - Dec 15th, 2021 at 1:51am
Print Post  
Tim@Visual Micro wrote on Dec 9th, 2021 at 12:38am:
We are going to look at something but it will have to be enabled by users, for example Terminal Mode.

Indeed Tim, the behavior I'm expecting from the serial monitor is akin to terminal emulation.
This would be very handy, as a tty-capable terminal would produce format-rich and data-packed outputs, without the hassle of scrolling up and down the entire textbox to find pertinent information (as it did on old tty systems).

That is, if the device output isn't garbage due to bad programming, but that's another story (for the users & yours truly to deal with, once they enable this "Terminal Mode."). 

Some kind of upload-aware "putty" terminal, I guess ?

Cong Quyen Knight wrote on Dec 9th, 2021 at 12:11am:
remove '\b' as a garbage in recv buffer

Nope Cong Quyen Knight , that's not what I was talking about at all, sorry.  Undecided
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint