Node-Red to Espruino

Posted on
  • I'm starting to develop a Node-Red [NR] node for use with the Espruino
    Even with echo(0); as the last command in my JS I'm getting some Echo back from the interpreter. I'm wondering what I might be doing wrong as this isn't the behavior of the IDE?

    In attached image 1. I'm calling a Espruino function from NR be sending "getAna(0);\n" The interpreter echos the function name, followed by the JSON I want back plus return val and Cursor > 2. Espruino calls a function is every min which prints the JSON I want again followed by the Cursor >.

    I still want \n back from the interpreter but not function name called or cursor symbol.

    Lawrence


    1 Attachment

    • NR-Espruino.png
  • It does look a lot like the echo(0); didn't get through the first time. Perhaps you could somehow dump the code you're sending to Espruino (eg connect 2x USB-TTL modules together, and then listen on one while using the other with Espruino?).

    It should be something like:

    echo(0);\n
    
    console.log({my:1,json:2})\n
    console.log({my:3,json:4})\n
    console.log({my:5,json:6})\n
    

    There could also be garbage in Espruino's input line when you connect, so you can try sending Ctrl-C (char code 0x03) before the echo(0) just in case?

  • Thanks will try that, but sending crtl-c helps. I found node-red/node.js hates the espruino reset button being pressed takes 90% cpu & stays there! Have to ctrl-c node.js then press reset as ttyACM0 gets permission locked.

    That said NR & espruino work so well together! I wish I started down this route a year ago, even evil eval works a treat "eval(\"function foo() { console.log('foo'); }\");foo();save()\n"; then call foo().

    Am planing an industrial IO board for the PICO.

    Lawrence

  • Hi Lawrence,

    Glad it's working now! Because Espruino executes the code directly, 'eval' actually works particularly well :)

    I'd also added the ability to do an 'inline echo off'. If you send character code 16 on a blank line, and then your command, then you won't need to use echo(0). However having tried it just now it looks like there's still an issue with the trailing > character

    An industrial IO board would be great! Hopefully I'll be releasing an Eagle CAD part outline for it in the next few weeks, which should help a lot!

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

Node-Red to Espruino

Posted by Avatar for LawrenceG @LawrenceG

Actions