# serial.read

## 功能

从已打开串口读取数据。

## 语法

```bt
device.open(config).read()
```

## 参数

无参数。

## 返回值

| 类型 | 说明 |
| ------ | ------ |
| String/Array | 读取到合法 UTF-8 时返回 String；否则返回字节数组。 |

## 示例

```bt
port = device.open({type: 'serial', port: 'COM3'})
result = port.read()

// 输出：String
echo(type(result))
```

## 注意事项

- 读取失败时抛出底层设备错误。
