Modjn
Modbus Implementation in Java with Netty
Install / Use
/learn @klymenek/ModjnREADME
modjn
Modbus TCP client/server implementation in Java with Netty 4.x
Currently implemented modbus functions
- READ COILS | 0x01
- READ DISCRETE INPUTS | 0x02
- READ HOLDING REGISTERS | 0x03
- READ INPUT REGISTERS | 0x04
- WRITE SINGLE COIL | 0x05
- WRITE SINGLE REGISTER | 0x06
- WRITE MULTIPLE COILS | 0x0F
- WRITE MULTIPLE REGISTERS | 0x10
Usage
Server
implement ModbusRequestHandler for server business logic, example here...
ModbusServer modbusServer = new ModbusServer(502);
try {
modbusServer.setup(new ModbusRequestHandler());
} catch(ConnectionException ex) {
System.out.println(ex.getLocalizedMessage());
}
modbusServer.close();
Client
switch to async requests by passing an instance of ModbusResponseHandler to the setup function and handle responses by yourself
ModbusClient modbusClient = new ModbusClient("localhost"; 502);
try {
modbusClient.setup();
ReadCoilsResponse readCoils = modbusClient.readCoils(12321, 10);
//modbusClient.[other functions] ...
System.out.println(readCoils);
} catch (NoResponseException | ErrorResponseException | ConnectionException ex) {
System.out.println(ex.getLocalizedMessage());
}
modbusClient.close();
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR
