This function is used in Python Scripting.

Description

Configure a serial port for use in a later call. This only needs to be done once unless the configuration has changed after the initial call. All access to constants must be prefixed by " system.serial.".

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

This function accepts keyword arguments.

system.serial. configureSerialPort(port, [bitRate], [dataBits], [handshake], [hardwareFlowControl], [parity], [stopBits])

  • Parameters 

String port - The name of the serial port (e.g., "COM1" or "/dev/ttyS0"). This parameter is required.

Integer bitRate  Configure the bit rate. Valid values are defined by the following constants [optional]: 

system.serial.BIT_RATE_110, system.serial.BIT_RATE_150, system.serial.BIT_RATE_300, system.serial.BIT_RATE_600, system.serial.BIT_RATE_1200, system.serial.BIT_RATE_2400, system.serial.BIT_RATE_4800, system.serial.BIT_RATE_9600, system.serial.BIT_RATE_19200, system.serial.BIT_RATE_38400, system.serial.BIT_RATE_57600, system.serial.BIT_RATE_115200, system.serial.BIT_RATE_230400, system.serial.BIT_RATE_460800, system.serial.BIT_RATE_921600

Integer dataBits Configure the data bits. Valid values are defined by the following constants [optional]:

system.serial.DATA_BITS_5, system.serial.DATA_BITS_6, system.serial.DATA_BITS_7, system.serial.DATA_BITS_8

Integer handshake - Configure the handshake. Valid values are defined by the following constants [optional]:

system.serial.HANDSHAKE_CTS_DTR, system.serial.HANDSHAKE_CTS_RTS, system.serial.HANDSHAKE_DSR_DTR, system.serial.HANDSHAKE_HARD_IN, system.serial.HANDSHAKE_HARD_OUT, system.serial.HANDSHAKE_NONE, system.serial.HANDSHAKE_SOFT_IN, system.serial.HANDSHAKE_SOFT_OUT, system.serial.HANDSHAKE_SPLIT_MASK, system.serial.HANDSHAKE_XON_XOFF

Boolean hardwareFlowControl - Configure hardware flow control. On or off. [optional]

Integer parity Configure parity. Valid values are defined by the following constants [optional]:

system.serial.PARITY_EVEN, system.serial.PARITY_ODD, system.serial.PARITY_MARK, system.serial.PARITY_SPACE, system.serial.PARITY_NONE

Integer stopBits - Configure stop bits. Valid values are defined by the following constants [optional]:

system.serial.STOP_BITS_1, system.serial.STOP_BITS_2

  • Returns

SerialConfigurator A SerialConfigurator object with exposed functions that can be used to configure the serial port instead of, or in addition to, the arguments passed to configureSerialPort.

  • Scope

Gateway, Vision Client, Perspective Session

SerialConfigurator Methods

Below is a listing of methods on the SerialConfigurator object. All methods return the original SerialConfigurator object, but with a modified parameter value. For a list of possible values, see the appropriate parameter on the function description above. 

Method
setBitRateSets the bit rate on the SerialConfigurator.
setDataBitsSets the data bits on the SerialConfigurator.
setParitySets the parity on the SerialConfigurator.
setStopBitsSets the stop bits on the SerialConfigurator.
setFlowControlSets the flow control on the SerialConfigurator.
setHandshakeSets the handshake on the SerialConfigurator.
setHardwareFlowControlSets the hardware flow control on the SerialConfigurator.
Code Examples
Code Snippet - Configuring Serial Port
# Configure a serial port using keyword args.
# The "port" keyword is mandatory.
 
system.serial.configureSerialPort(\
port="COM1",\
bitRate=system.serial.BIT_RATE_9600,\
dataBits=system.serial.DATA_BITS_8,\
handshake=system.serial.HANDSHAKE_NONE,\
hardwareFlowControl=False,\
parity=system.serial.PARITY_NONE,\
stopBits=system.serial.STOP_BITS_1)
Code Snippet - Configuring Serial Port
# Configure a serial port using a SerialConfigurator (returned by configureSerialPort()):
 
system.serial.configureSerialPort("COM1")\
.setBitRate(system.serial.BIT_RATE_9600)\
.setDataBits(system.serial.DATA_BITS_8)\
.setHandshake(system.serial.HANDSHAKE_NONE)\
.setHardwareFlowControl(False)\
.setParity(system.serial.PARITY_NONE)\
.setStopBits(system.serial.STOP_BITS_1)
Keywords

system serial configureSerialPort, serial.configureSerialPort