Serial Port
Communication over a serial port (RS-232, RS-485, or a USB adapter presenting itself as one).
Transport syntax
{name of the serial port}
The name depends on the operating system:
-
Windows:
COM1 -
Linux:
/dev/ttyS0,/dev/ttyUSB0 -
macOS:
/dev/tty.usbserial-XXXX
modbus-rtu://COM1?serial.baud-rate=19200
modbus-rtu:serial:///dev/ttyUSB0?serial.baud-rate=9600&serial.parity=even
Name |
Type |
Default Value |
Required |
Description |
Name |
Serial |
|||
Code |
|
|||
Maven Dependency |
<dependency> <groupId>org.apache.plc4x</groupId> <artifactId>plc4j-transports-serial</artifactId> <version>1.0.0</version> </dependency> |
|||
Config options: |
||||
|
INT |
9600 |
Baud rate (bits per second) |
|
|
INT |
8 |
Number of data bits (5, 6, 7, or 8) |
|
|
INT |
1 |
Number of stop bits (1 or 2) |
|
|
STRING |
none |
Parity: none, odd, even, mark, space (case-insensitive) |
|
|
STRING |
none |
Flow control: none, rts-cts, xon-xoff (case-insensitive) |
|
|
INT |
1000 |
Read timeout in milliseconds. 0 means blocking read. |
|
|
INT |
1000 |
Write timeout in milliseconds. |
|
|
BOOLEAN |
false |
Enable DTR (Data Terminal Ready) signal |
|
|
BOOLEAN |
false |
Enable RTS (Request To Send) signal |
|
|
BOOLEAN |
false |
Reuse the underlying serial port across multiple transport instances. When true, instances with the same port will share a connection. This is useful for protocols where multiple logical connections share one serial port. Connections sharing a port must target distinct unit ids; Modbus RTU responses carry no transaction ids, so same-unit traffic from multiple connections cannot be told apart. |
|
|
INT |
0 |
Interframe delay in milliseconds for protocols that need spacing between messages. Applies to shared and dedicated ports; the gap is measured from the last write or received data. |
|
On an RS-485 bus several devices share one physical port. serial.reuse-port=true lets several
PLC4X connections share a single open port for that case - read the warning on that option before
using it.