You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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:

    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); });
    
About

Avatar for Gordon @Gordon started