This function is used in Python Scripting.

Description

Read numberOfBytes bytes from a serial port and convert them to a String. If a specific encoding is needed to match the source of the data, use system.serial.readBytes and use the desired encoding to decode the byte array returned.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.serial.readBytesAsString(port, numberOfBytes, [timeout], [encoding])

  • Parameters

String port - The previously configured serial port to use.

Integer numberOfBytes - The number of bytes to read.

Integer timeout - Maximum amount of time, in milliseconds, to block before returning. Default is 5000. [optional]

String encoding- Encoding to use when constructing the string. Defaults to the platform's default character set. [optional]

  • Returns

String - A String created from the bytes read.

  • Scope

Gateway, Vision Client, Perspective Session

The Encoding Parameter

The encoding parameter can be used to decode a string with any of the possible encoding character sets that are available. By default, the following character sets are provided by the Java platform (dash characters and underscores are interchangeable). Dashed examples are shown below:

  • ISO-8859-1
  • US-ASCII
  • UTF-16
  • UTF-16BE
  • UTF-16LE
  • UTF-8
Code Examples

There are no code examples for this function.

Keywords

system serial readBytesAsString, serial.readBytesAsString