serial.read

serial.read

serial.read

Function

Read data from the opened serial port. This method retains historical compatibility behavior: a String is returned when valid UTF-8 is read, otherwise a byte array is returned.

Syntax

Parameters

No parameters.

Return value

TypeDescription
String/ArrayReturns String when legal UTF-8 is read; otherwise returns byte array.

Example

Notes

  • Throws an underlying device error when the read fails.
  • The new binary protocol uses read_bytes() first to avoid the return type changing with the content.