Receive

Data can be received from the other party by calling the onreceive function. In that function, “data” and “text” are passed as arguments. “data” is the received byte sequence and “text” is the data converted to a string as much as possible. If conversion to text fails, text will be “undefined”.

var uart = obniz.getFreeUart();
uart.start({tx:0, rx:1})
uart.onreceive = function(data, text) {
  console.log(data);
  console.log(text);
}

The UART has no “length” information in the data. Sending 100 bytes of information does not guarantee that 100 bytes will be received. It may be divided into 20 bytes and 80 bytes twice.

Overflow

When the communication speed of the device is insufficient, the received UART data may not be sent. In such a case, no error occurs and the received data will be lost.