PLCcom for Modbus SDK class library documentation

PLCcom logo


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.

Start with normal Modbus TCP when you need a simple connection.
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.

MB 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.

PLCcom for Modbus provides these building blocks as a Java SDK, so application code can work with readable requests and typed results instead of raw telegram assembly.

SDK 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.

Master applications
TCP, SecureTCP, UDP, RTU over TCP, RTU, and ASCII with typed request and result objects.
Slave applications
Multiple listeners can run side by side, for example TCP on port 502 and SecureTCP on port 802.
Diagnostics
Telegram logging, connection state changes, read collections, and clear operation results for application logs.
Register handling
16-bit, 32-bit, and 64-bit register modes with byte-order conversion for device-specific layouts.
Function coverage
Read, write, read/write, diagnostics, mask-write, report-server-ID, and CANopen-style access.
SecureTCP
Modbus Security with PKI store, certificate validation, and authorization hooks.

JAVA 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.

GET How do I obtain PLCcom for Modbus?

You can reference the SDK from Maven Central:

Maven
<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.

KEY 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

TCP 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.

M 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.

Master integration flow

1. Create the master. Pass the license user and serial once, then reuse the instance for the required requests.
2. Select the connector. TCP is the easiest starting point. Other transports use the same request/result model.
3. Build and execute requests. The request describes slave id, function, start address, datatype, and amount.

Create and initialize the master

Java
ModbusMaster master = new ModbusMaster("user", "serial");
master.setConnector_TCP("192.168.1.21", 502);

Build and execute a read request

Java
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());
    }
}

S 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.

Slave integration flow

1. Create the slave. The constructor receives the license information and the default slave id.
2. Add listeners. A single slave can expose several transports at once, for example TCP and SecureTCP.
3. Fill the data store. Incoming read requests use the configured register, coil, and input values.

Create the slave and add listeners

Java
ModbusSlave slave = new ModbusSlave("user", "serial", 1);
slave.addOrReplaceListener_TCP("tcp_502", 502);
slave.setValue(
    UBuilder.createUShort(100),
    eModbusRegion.HoldingRegister,
    UBuilder.createUShort(1234));

64 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.

NEXT 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 Packages PLCcom for Modbus SDK Other Packages 
Package Description
com.indian.plccom.modbus  
com.indian.plccom.modbus.Enums  
com.indian.plccom.modbus.PduLimitationParameters  
com.indian.plccom.modbus.UnsignedDatatypes