@allObjects personally I think that's just complicating matters.
@Coder2012 Basically you have the 'console' - the thing on the Espruino that lets you enter code on the left-hand side of the Web IDE. When you're connected to a PC via USB, it's moved to USB, and when you're not it's moved to Serial1 (bluetooth).
You can force it to be on one or the other using the commands Serial1.setConsole(); or USB.setConsole();.
So now, the thing that really messes you up: When the console is on a device (like Serial1), the on('data',...) handler doesn't work.
For what you want, I'd suggest you actually just use everything the console gives you. So, if you've written a bunch of functions then you can just execute one of them by sending the text myFunction(some,args);\n.
When you do that you'll get the characters you send echo'd back to you, but you can fix that by sending echo(0)\n - you need to send 1 to turn echo back on though.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@allObjects personally I think that's just complicating matters.
@Coder2012 Basically you have the 'console' - the thing on the Espruino that lets you enter code on the left-hand side of the Web IDE. When you're connected to a PC via USB, it's moved to USB, and when you're not it's moved to Serial1 (bluetooth).
You can force it to be on one or the other using the commands
Serial1.setConsole();
orUSB.setConsole();
.So now, the thing that really messes you up: When the console is on a device (like Serial1), the
on('data',...)
handler doesn't work.For what you want, I'd suggest you actually just use everything the console gives you. So, if you've written a bunch of functions then you can just execute one of them by sending the text
myFunction(some,args);\n
.When you do that you'll get the characters you send echo'd back to you, but you can fix that by sending
echo(0)\n
- you need to send1
to turn echo back on though.Hope that helps!