• Hi guys,

    I am sniffing data coming from the Espruino Pico through virtual COM port (Windows, Python), and I ran into a problem. It seems that each print(X) adds the special "Backspace" character before X, and finally adds "carriage return" +"Line feed".
    I wonder if this "Backspace" character is really useful for anything? I am using the serial port for long time, I never had to use this "Backspace" character. If anyone could explain why it is so important, that would be great!

    I am a beginner with Python, and I had to find a trick to remove this "BS" character. I tried this one:

    myData=comPort.readline()
        myData=myData[2:]
    
    

    Why "2" characters removed? I don't really understand, I thought only had to be removed, but Espruino seems to send another useless character in front of the printed string, maybe '>' ?

    If anyone has a better idea on how to keep only the useful data, do not hesitate to post it :-)

    Have a nice day.

  • The issue you have is that you have the console on USB, with echo turned on. For instance you usually get a prompt at the beginning of the line like >.

    So if you print something, Espruino must delete that > character, then print what you told it to with a newline, then eventually put the > character back.

    To avoid it, either:

    • Call echo(0) to disable echoing
    • Move the console away from USB (for example with Serial1.setConsole()). You can then use USB.print(...) to print exactly what you want to USB - no backspaces or deletes. However as the console will be gone, you'll have to reset the Espruino in order to write more code to it.
  • Thank you Gordon, calling "echo(0)" is exactly what I needed.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

(0x08) ASCII character before every print() message?

Posted by Avatar for Jean-Philippe_Rey @Jean-Philippe_Rey

Actions