# serial.read_text ## 功能 从已打开串口读取数据,并按 UTF-8 严格转换为字符串。 ## 语法 ```bt device.open(config).read_text() ``` ## 参数 无参数。 ## 返回值 | 类型 | 说明 | |------|------| | String/Null | 合法 UTF-8 返回 String;非法 UTF-8 返回 `null`。 | ## 代码示例 ```bt port = device.open({type: 'serial', port: 'COM3'}) text = port.read_text() // 输出:String print type(text) ``` ## 注意事项 - `read_text()` 不使用 lossy 转换;工业协议报文请使用 `read_bytes()`。