Unfortunately Espruino doesn't have a callback when something is finished sending, but you could try:
Setting the timeout based on the length of the string that you send:
var s = "@01STOP\r";
digitalWrite(B8, 1);
Serial1.print(s);
setTimeout(function() {digitalWrite(B8, 0);}, s.length/0.96); // chars * 10 bits / 9600 baud
Clearing the enable when you get data back
I don't know if this'll work for you (it depends on the controller), but if it sends a reply when you send the command (and not anything else before), then you can use the reply to turn the enable off?
Serial1.on('data', function (data) { digitalWrite(B8, 0);print("<Serial1> "+data); });
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.
Sounds like an interesting project...
Unfortunately Espruino doesn't have a callback when something is finished sending, but you could try:
Setting the timeout based on the length of the string that you send:
Clearing the enable when you get data back
I don't know if this'll work for you (it depends on the controller), but if it sends a reply when you send the command (and not anything else before), then you can use the reply to turn the enable off?