• Yes, @DrAzzy's right. fs.read will block, but when you send data it's stuck in an output buffer. That buffer is 128 characters, so as long as you send less than that, Espruino won't block.

    I don't think there are any functions to tell how full that output buffer is though, so you'll need to use setTimeout between calls to Serial.write to make sure you don't send data faster than the UART can take it.

    eg.

    function sendData() {
      var moreData = getMoreData();
      Serial1.write(moreData);
      setTimeout(sendData, moreData.length*10000/baudRate);
    }
    
About

Avatar for Gordon @Gordon started