- expand single-line Javadocs to multi-line blocks, rewrap Markdown prose, and reflow POM, YAML, and TypeScript formatting - formatting only: no Java code lines changed, no build-file semantics changed - verified: backend compile and check_documentation.py pass, pnpm check and pnpm lint:check pass, and the dc3 YAML files parse
4.2 KiB
DC3 Driver Serial
Overview
dc3-driver-serial is the generic serial port driver of the IoT DC3 platform. It communicates with RS232/RS485/RS422
devices over a serial port using the jSerialComm library, caching one serial connection per device. For each point it
sends a configured HEX command, reads back the raw response, and parses it according to frame header/footer, checksum,
data offset/length, data format (HEX/ASCII/BINARY/FLOAT), and byte order. Write commands send a HEX command template
with the ${value} placeholder substituted.
Module Information
- Group ID: io.github.pnoker
- Artifact ID: dc3-driver-serial
- Driver Name: Serial Port Driver
Driver Attributes (Device-level)
| Attribute | Code | Type | Default | Description |
|---|---|---|---|---|
| Serial Port | port | STRING | /dev/ttyUSB0 | Serial port device path |
| Baud Rate | baudRate | INT | 9600 | Baud rate (1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200) |
| Data Bits | dataBits | INT | 8 | Data bits (5, 6, 7, 8) |
| Stop Bits | stopBits | INT | 1 | Stop bits (1, 2) |
| Parity | parity | INT | 0 | Parity (0=None, 1=Odd, 2=Even) |
| Timeout | timeout | INT | 1000 | Read timeout in milliseconds |
Point Attributes
| Attribute | Code | Type | Default | Description |
|---|---|---|---|---|
| Send Command | sendCommand | STRING | HEX command to send (e.g. 01 03 00 00 00 0A C5 CD) | |
| Receive Length | receiveLength | INT | 0 | Expected response length in bytes (0=auto detect) |
| Frame Header | frameHeader | STRING | Frame header in HEX (e.g. 01 03) | |
| Frame Footer | frameFooter | STRING | Frame footer in HEX (e.g. 0D 0A) | |
| Data Offset | dataOffset | INT | 0 | Data region offset from frame start |
| Data Length | dataLength | INT | 0 | Data region length in bytes (0=until frame footer) |
| Checksum Type | checksumType | STRING | NONE | Checksum type: NONE, CRC16, XOR |
| Data Format | dataFormat | STRING | HEX | Data format: HEX, ASCII, BINARY, FLOAT |
| Byte Order | byteOrder | STRING | BIG | Byte order: BIG, LITTLE |
Command Attributes (write)
| Attribute | Code | Type | Default | Description |
|---|---|---|---|---|
| Send Command | sendCommand | STRING | ${value} | HEX command template with ${value} placeholder |
| Byte Order | byteOrder | STRING | BIG | Byte order for encoding value: BIG, LITTLE |
The module application.yml is authoritative for attribute codes, types, default values, scheduling, health, and local
buffering. Keep this README aligned when those user-facing settings change.
Prerequisites
A serial device connected to a serial port reachable from the host running the driver (e.g. /dev/ttyUSB0). The port
path and line parameters (baud rate, data/stop bits, parity, timeout) are supplied through the driver attributes above.
Running Locally
1. Start Infrastructure and Center Services
make up-db
make up-dev GROUP=core
2. Build and Run
mvn -s .mvn/settings.xml -pl dc3-driver/dc3-driver-serial -am package
java -jar dc3-driver/dc3-driver-serial/target/dc3-driver-serial.jar
Testing
Run the module tests from the repository root:
mvn -s .mvn/settings.xml -pl dc3-driver/dc3-driver-serial -am test
Related Modules
dc3-common-driver— Driver SDK for registration, scheduling, and RabbitMQ integration