You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I'm not sure I really understand the question...

    There isn't anything built in to Espruino that separates specific commands in the output stream - it is just a sequence of characters (as would go to a VT100 terminal app).

    You may be seeing char code 8 which is a delete, because normally the console outputs > as a prompt, but to print something it must first delete that, write the text, and then re-add it.

    To avoid that you can run echo(0) which will turn off the console echoing back what you write (and the > prompt). When you type in the IDE the device will appear to be unresponsive, but it will still output the text you send it

  • I just wanted to say that when I catch console logs and answers from interactive console with code like this

    USB.on('data', data => {
      inbuf.Push(data);
    });
    
    setTimeout(() => {E.setConsole(LoopbackA);}, 200);
    
    LoopbackB.on('data', data => {
      outLogs.push(data);
      USB.write(data);
    });
    
    setTimeout(() => {
      console.log('some text');
    }, 500);
    
    setTimeout(() => {
      LoopbackB.write('2+3\r');
    }, 1500);
    

    I get logs like this:

    [
      "<- USB\r\n>",
      "\r\x1B[Jsome text\r\n>",
      "2+3\r\n=5\r\n>",
      "10+3\r\n=13\r\n>",
      "\r\x1B[J-> USB\r\n"
     ]
    

    That looks quite readable, but some situations lead to logs like this:

    "outLogs\r\n=[ \r\n  \"" ... "\\n ]\\r\\n>\"\r\n ]\r\n>"
    

    So I have to remove all special symbols somehow. Yeah, it's not hard at all to write a simple parser on regexps for those exact types of logs, but as I don't know how exactly IDE is formatting logs, I may easily trap into using code that doesnt work correctly for some cases. So, what would you advice?

About

Avatar for Gordon @Gordon started