This function is used in Python Scripting.

Description

Write a string to a serial port using the platforms default character encoding.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.serial.write(port, toWrite, [timeout], [encoding])

  • Parameters

String port - The previously configured serial port to use.

String toWrite - The string to write.

Integer timeout - A timeout, in milliseconds. Writes exceeding this period will . Defaults to 5000 [optional]

String encoding -Encoding to decode the string with, for example: UTF-8. Default is the platform default character set. [optional] 

  • Returns

Nothing

  • 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
Code Snippet
# This example will write a string to a port called "COM1".
port = "COM1"
toWrite = "I am a string"

system.serial.write(port,toWrite)
Keywords

system serial write, serial.write