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β
| Type | Parameter | Description |
|---|---|---|
| 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 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)