Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Scripting_function


Panel
titleDescription

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

Client permissions restrictions


Panel
titleSyntax

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

Panel
titleThe 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
Panel
titleCode Examples
Code Block
languagepy
titleCode Snippet
# This example will write a string to a port called "COM1".
port = "COM1"
toWrite = "I am a string"

system.serial.write(port,toWrite)
Panel
titleKeywords

system serial write, serial.write