🚧RS-232/485 (WIP)

RS-232 and RS-485 are both serial communication protocols used for data transfer between devices. RS-232 is commonly employed for short-distance communication, typically under 50 feet, and supports point-to-point connections at lower speeds. Conversely, RS-485 is designed for longer distances, up to 4000 feet, and supports multi-point configurations with higher data rates. The key differences include their physical wiring setups, signal voltage levels, and maximum distance capabilities.

RS-232 is often found in older computer serial ports, connections to modems, and in certain industrial applications where simple point-to-point communication is sufficient. For example, connecting a computer to a printer or a microcontroller to a GPS module.

RS-485 is widely used in industrial automation systems, such as connecting PLCs (Programmable Logic Controllers) to various sensors and actuators. It is also common in building management systems (BMS), where multiple devices like HVAC systems, lighting controls, and other peripherals need to communicate over long distances in a multi-drop network configuration.

Functions

create

Instantiates a serial connection to a specific port.

In the options box, insert as an object the necessary parameters.

ParameterTypeDefaultDescription

path

String

The system path of the serial port you want to open. For example, /dev/tty.XXX on Mac/Linux, or COM1 on Windows

baudRate

Integer

9600

The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600 or 115200. Custom rates are supported as a best effort per platform. The device connected to the serial port is not guaranteed to support the requested baud rate, even if the port itself supports that baud rate.

dataBits

Integer

8

Must be one of these: 5, 6, 7, or 8

lock

Boolean

true

Prevent other processes from opening the port. Windows does not currently support false.

stopBits

Number

1

Must be 1, 1.5 or 2

parity

String

'none'

Must be one of these: 'none', 'even', 'mark', 'odd', 'space'

rtscts

Boolean

false

Flow control Setting.

xon

Boolean

false

Flow control Setting.

xoff

Boolean

false

Flow control Setting.

xany

Boolean

false

Flow control Setting.

hupcl

Boolean

true

Drop DTR on close.

list

Lists all serial ports found on the system.

open

Opens the connection of the given serial port.

isOpen

getBinding

changeBaudRate

Changes the baud rate for an open port. Parameter baudRate can be set as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, or 115200.

write

Writes data to the given serial port and waits until all output data is transmitted to the serial port. Use the input box for data to insert the data you want to write. You can also use suffix to always add specific information at the end of the data you want to write.

If you need to transport a carriage return use <CR>, for linefeed use <LF> and for both together use <CRLF>.

read

Read data from a port.

close

Closes an open connection. If there are in-progress writes when the port is closed the writes will error.

onError

Reports about any errors

onData

Listens to data events

ParameterTypeDefaultDescription

name

String

Name of the handler

handler

Function

Function to run as the handler

parserOptions

Object

Object that contains the following parser options.

parserOptions.

delimiter

String

'\n'

Emits data after the delimiter is hit.

parserOptions.

timeout

Integer

Timeout in ms after which data is emitted

parserOptions.

byteLength

Integer

Number of bytes that must have been received until data is emitted.

Last updated

#355:

Change request updated