Mon. Nov 29th, 2021
GitHub - zgkxzx/Modbus4Android: Modbus for android

Modbus For Android

Introduce

This is a Modbus library for Android.

How to make use of

1.Add the library to your venture

compile recordsdata('libs/modbus4Android-1.0.jar')

Copy the jar to the lib listing of your venture and add the config to construct.gradle.

2.Create and init ModbusReq occasion

() {
@Override
public void onSuccess(String s) {
Log.d(TAG, “onSuccess ” + s);
}

@Override
public void onFailed(String msg) {
Log.d(TAG, “onFailed ” + msg);
}
});
“>

ModbusReq.getInstance().setParam(new ModbusParam()
                .setHost("192.168.0.105")
                .setPort(502)
                .setEncapsulated(false)
                .setKeepAlive(true)
                .setTimeout(2000)
                .setRetries(0))
                .init(new OnRequestBack() {
            @Override
            public void onSuccess(String s) {
                Log.d(TAG, "onSuccess " + s);
            }

            @Override
            public void onFailed(String msg) {
                Log.d(TAG, "onFailed " + msg);
            }
        });

Init ModbusReq occasion by means of setting the modbus param.

3.Read Coil

截屏

4.Read DiscreteInput

截屏

5.Read HoldingRegisters

截屏

6.Read EnterRegisters(Child Thread)

截屏

7.Write Coil

截屏

8.Write Register

截屏

9.Write Registers

截屏

10.Destroy Modbus Instance

ModbusReq.getInstance().destroy();

Extends

when you use RTU Mode with SerialPort,it’s best to do :

    1. Create a category to implement SerialPortWrapper interface.
    1. Create a ModbusGrasp occasion with createRtuMaster mothod of ModbusManufacturing facility class.

Feedback

You have any inquiries to ship e mail to me.Thanks.

Me & Throught

Simplicity is just not easy.

By admin