# 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 ```bt device.open(config).read() ``` ## Parameters No parameters. ## Return value | Type | Description | | ------ | ------ | | String/Array | Returns String when legal UTF-8 is read; otherwise returns byte array. | ## Example ```bt port = device.open({type: 'serial', port: 'COM3'}) result = port.read() // Output: String echo(type(result)) ``` ## 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.