system.serial.readLine
This function is used in Python Scripting.
Descriptionβ
Attempts to read a line from a serial port. A "line" is considered to be terminated by either a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a line feed.
The function will wait until the timeout period for a terminator. If the timeout is reached before the line is properly terminated, then the buffer will be dumped, possibly resulting in data loss.
Client Permission Restrictionsβ
This scripting function has no Client Permission restrictions.
Syntaxβ
system.serial.readLine(port [, timeout] [, encoding])
Parametersβ
| Type | Parameter | Description |
|---|---|---|
| String | port | The previously configured serial port to use. |
| Integer | timeout | Maximum amount of time, in milliseconds, to block before returning. Default is 5000. [optional] |
| String | encoding | The String encoding to use. Default is UTF8. [optional] |
Returnsβ
String - A line of text.
Scopeβ
Gateway, Vision Client, Perspective Session
Code Exampleβ
Code Snippet
# This example will read from the "COM1" port and set the timeout to 10000 milliseconds.
port = "COM1"
timeout = 10000
system.serial.readLine(port,timeout)