Skip to main content
Version: 8.1

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

TypeParameterDescription
StringportThe previously configured serial port to use.
IntegertimeoutMaximum amount of time, in milliseconds, to block before returning. Default is 5000. [optional]
StringencodingThe 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)

Keywords

system serial readLine, serial.readLine