Coder Social home page Coder Social logo

modbustcpkiss's Introduction

ModbusTcpKiss

A ModbusTCP implementation that follows the KISS principles.

Usage

Its very simple to use. Just set the Hostname and Port and connect. Nothing more.

  AbstractModbusTCPClient client = new ModbusTCPClient("SERVERNAME", 1502);
  client.connect();
  String manufacturer = client.readString(40004, 16);  //Example for SolarEdge Inverter
  int status = client.readUInt16(40107);

Read data

There are predefined methods to decode data like

  • int readInt16(int address)
  • int readUInt16(int address)
  • int readInt32(int address)
  • long readUInt32(int address)
  • BigInteger readUInt64(int address)
  • float readFloat16(int address)
  • float readFloat32(int address) These methods don't need a length information, they just read the correct number of registers. These methods return the register contents as data type, that is sufficiant for the requested information.

If you have special needs, you could always use the basic method:

  • byte[] readRegister(int address, int numberOfRegisters) You will get a plain, undecoded byte[] of size "numberOfRegsiters * 2", because each register has 16 bit.

Write data

There are predefined methods which will encode data like

  • void writeUInt16(int address, int value)

If you have special needs, you could always use the basic method:

  • void writeRegisters(int address, byte[] data) The data array must be a multiple of 2, because each register has 16 bit. It's up to you to encode the data as required by your device.

Additional Features

We added an optional Proxy, that allows us to make more then 1 connection to a device, that otherwise would only accept on connection (like SolarEdge Inverters). The ModbusTCPClient can be connected to the Proxy like to a real Modbus Server. The ModbusTCPProxy must be created and started before connecting.

  ModbusTCPClient client = new ModbusTCPClient("SERVERNAME", 1502);
  ModbusTCPProxy proxy = new ModbusTCPProxyServer(client, 5502);
  proxy.connect();
  ModbusTCPClient proxyClient = new ModbusTCPClient("localhost", 5502);
  proxyClient.readString(57600, 16);

In this case proxyClient.readString(57600, 16); and client.readString(57600, 16); should produce the same results.

modbustcpkiss's People

Contributors

keinhaar avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.