RS-232/485
This article is a work in progress.
For immediate help integrating serial protocols, please reach out to us.
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.
Parameter | Type | Default | Description |
---|---|---|---|
path | String | The system path of the serial port you want to open. For example, | |
baudRate | Integer |
| The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as |
dataBits | Integer |
| Must be one of these: |
lock | Boolean |
| Prevent other processes from opening the port. Windows does not currently support |
stopBits | Number |
| Must be |
parity | String |
| Must be one of these: |
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
Parameter | Type | Default | Description |
---|---|---|---|
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 |
| 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