Top | Previous | Next |
system.serial.configureSerialPort |
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.". Syntax 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: BIT_RATE_110, BIT_RATE_150, BIT_RATE_300, BIT_RATE_600, BIT_RATE_1200, BIT_RATE_2400, BIT_RATE_4800, BIT_RATE_9600, BIT_RATE_19200, BIT_RATE_38400, BIT_RATE_57600, BIT_RATE_115200, BIT_RATE_230400, BIT_RATE_460800, BIT_RATE_921600. Integer dataBits - Configure the data bits.Valid values are defined by the following constants: DATA_BITS_5, DATA_BITS_6, DATA_BITS_7, DATA_BITS_8. Integer handshake - Configure the handshake.Valid values are defined by the following constants: HANDSHAKE_CTS_DTR, HANDSHAKE_CTS_RTS, HANDSHAKE_DSR_DTR, HANDSHAKE_HARD_IN, HANDSHAKE_HARD_OUT, HANDSHAKE_NONE, HANDSHAKE_SOFT_IN, HANDSHAKE_SOFT_OUT, HANDSHAKE_SPLIT_MASK, HANDSHAKE_XON_XOFF. Boolean hardwareFlowControl - Configure hardware flow control. On or off. Integer parity - Configure parity.Valid values are defined by the following constants: PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE, PARITY_NONE. Integer stopBits - Configure stop bits.Valid values are defined by the following constants: STOP_BITS_1, STOP_BITS_2. Returns SerialConfigurator - A SerialConfigurator that can be used to configure the serial port instead of or in addition to the given keyword arguments. Scope All Examples Configure a serial port using keyword args:
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)
The "port" keyword is mandatory.
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) |