Skip to main content
Version: 8.1

system.serial.write

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​

TypeParameterDescription
StringportThe previously configured serial port to use.
StringtoWriteThe String to write.
IntegertimeoutA timeout, in milliseconds. Writes exceeding this period will . Defaults to 5000 [optional]
StringencodingEncoding 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 Example​

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