serial.rx()

serial.rx(port,[bytes],[timeout]) → {data,ovf}

Read the current serial receive buffer contents.

After initialization, the serial ports are asynchronously read in the background.

This method allows you to read the buffer contents or optionally wait (timeout) for requested bytes to be available.

Alternatively the listen() method is also available which executes a callback following a specified character.

Arguments

NameTypeRequiredDefaultDescription
port yes Serial Port #
bytes optional 0 Number of bytes to wait for
timeout optional 1000 Milliseconds: How long to wait for the requested data

Returns

object {data:"hello world",ovf:false}

Example

let rxData = serial.rx(0); // Returns immediately with the current serial receive buffer contents. Useful for clearing the receive buffer

let rxData = serial.rx(0,24,1000); // Wait up to 1000mS for 24 bytes of data.