serial.read_text
serial.read_text
Function
Read data from the open serial port and convert it to a string strictly according to UTF-8.
Syntax
device.open(config).read_text()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| String/Null | Legal UTF-8 returns String; illegal UTF-8 returns null. |
Code Example
port = device.open({type: 'serial', port: 'COM3'}) text = port.read_text() // Output: String print type(text)
Notes
-
read_text()does not use lossy conversion; please useread_bytes()for industrial protocol messages.