PLCcom for Modbus SDK class library documentation
First steps with PLCcom for Modbus Java
A practical starting point for building Modbus master and slave applications with PLCcom. This page gives you the orientation:
what the SDK provides, which transports are available, and where the first lines of code belong.
Use it as a map before you dive into the API reference.
Move to SecureTCP when certificates, TLS, and controlled trust are required.
The public API keeps both paths close to each other, so applications can grow from a small test tool into a secured production integration.
What is Modbus?
Modbus is a compact industrial communication protocol for exchanging coils, discrete inputs, input registers, and holding registers between automation devices.
It is widely used because the protocol is simple, well understood, and supported by many controllers, meters, drives, gateways, and SCADA systems.
The protocol itself is intentionally small. Real applications still need connection handling, correctly built requests, conversion between Java values and register bytes, diagnostics, error handling, and often a slave implementation for simulation or integration testing.
What does PLCcom for Modbus provide?
PLCcom for Modbus equips Java developers to build Modbus master and slave applications without manually assembling telegrams.
The SDK exposes typed request and result objects, master connectors, slave listeners, value conversion, diagnostic logging, and ready-to-use validation applications.
TCP, SecureTCP, UDP, RTU over TCP, RTU, and ASCII with typed request and result objects.
Multiple listeners can run side by side, for example TCP on port 502 and SecureTCP on port 802.
Telegram logging, connection state changes, read collections, and clear operation results for application logs.
16-bit, 32-bit, and 64-bit register modes with byte-order conversion for device-specific layouts.
Read, write, read/write, diagnostics, mask-write, report-server-ID, and CANopen-style access.
Modbus Security with PKI store, certificate validation, and authorization hooks.
System requirements
PLCcom for Modbus requires Java 1.8 and is tested up to Java 26.
For development, use a Java IDE that supports the Java level selected by your application.
Serial communication requires access to the configured serial port.
SecureTCP requires certificate material or a writable PKI folder so PLCcom can create or load the local endpoint certificate.
How do I obtain PLCcom for Modbus?
You can reference the SDK from Maven Central:
<dependency>
<groupId>com.indi-an.plccom</groupId>
<artifactId>plccom-for-modbus</artifactId>
<version>9.x.x</version>
</dependency>
Alternatively, download packages and examples are available on the PLCcom for Modbus download page.
Additional Java examples are available in the Indi-An/PLCcom-modbus-example-java repository.
Licensing
Before using the library, the license data – user name and serial number – is passed to the constructor of the master or slave instance.
Evaluation mode: If both fields are left empty, the library runs during a debug session for 15 minutes with the full feature set – enough to open a connection and read values. This lets you try out the library before you register. For uninterrupted work, generate a free trial license (14 days).
Note: License data does not belong in source code. Use configuration files, environment variables, or a secret manager to load it at runtime.
Free trial license: → PLCcom for Modbus download page
Communication options at a glance
| Communication type | Typical use | PLCcom entry point |
|---|---|---|
| TCP | Classic Modbus TCP on port 502. | setConnector_TCP and addOrReplaceListener_TCP. |
| SecureTCP | Modbus Security over TLS, usually on port 802. | setConnector_SecureTCP and addOrReplaceListener_SecureTCP. |
| UDP | Connectionless Modbus datagrams where supported by the device. | setConnector_UDP and addOrReplaceListener_UDP. |
| RTU, RTU over TCP, ASCII | Serial and serial-style Modbus communication. | The corresponding RTU, RTU over TCP, and ASCII connector and listener methods. |
First steps: Modbus master
A master application is the active side of the communication.
It connects to a Modbus device, sends a request, and evaluates the returned values.
In PLCcom this usually follows the same small sequence.
Create and initialize the master
ModbusMaster master = new ModbusMaster("user", "serial");
master.setConnector_TCP("192.168.1.21", 502);
Build and execute a read request
ReadRequest request = RequestBuilder.ReadRequestBuilder.create(
1,
eReadFunction.F03_Read_Holding_Registers,
100,
eDataType.SHORT,
10);
ReadResult result = master.read(request);
if (result.getQuality() == OperationResult.eQuality.GOOD) {
for (ReadValue value : result.fetchValues()) {
System.out.println(value.toString());
}
}
First steps: Modbus slave
A slave application is the passive side.
It listens for incoming Modbus requests and provides values from its internal data store.
This is useful for real server implementations, device simulation, integration tests, and manual validation tools.
Create the slave and add listeners
ModbusSlave slave = new ModbusSlave("user", "serial", 1);
slave.addOrReplaceListener_TCP("tcp_502", 502);
slave.setValue(
UBuilder.createUShort(100),
eModbusRegion.HoldingRegister,
UBuilder.createUShort(1234));
Register modes and byte order
PLCcom supports 16-bit, 32-bit, and 64-bit register modes.
Wider register modes are not generic modes for all datatypes. They are valid only for
datatypes that actually require the configured width, following the established 32-bit register behavior.
Byte order remains configurable because Modbus devices differ in how they arrange bytes and words for multi-register values.
Use the byte-order setting that matches the target device documentation, then keep the request and response code independent from the device-specific wire layout.
Where to go next
- Use com.indian.plccom.modbus.ModbusMaster for master applications and request collections.
- Use com.indian.plccom.modbus.ModbusSlave for slave applications, listeners, and data-store events.
- Use com.indian.plccom.modbus.UnsignedDatatypes for unsigned values that exceed signed Java primitive ranges.
- Use the Java examples repository as runnable companion material while the API reference provides the exact member-level details.
All product names or other names or brands to which reference is made in this documentation are trademarks or registered trademarks of their respective owners and are the property of their respective owners. There is no connection between the mentioned brand or the brand owner and Indi.An GmbH. Any mention of brands is only an indication for the use and purpose.