modbus 0.2.0 copy "modbus: ^0.2.0" to clipboard
modbus: ^0.2.0 copied to clipboard

Simple Modbus client library for dart. Currently only the TCP connection is supported.

modbus-dart #

Simple Modbus client library for dart. Currently only the TCP connection is supported.

pub package

Usage #

Single slave (Modbus RTU) #

import 'package:modbus/modbus.dart' as modbus;


main(List<String> arguments) async {
    
  var client = modbus.createTcpClient(
    '10.170.1.20',
    port: 1001,
    mode: modbus.ModbusMode.rtu,
  );
    
  try {
    await client.connect();
    
    var slaveIdResponse = await client.reportSlaveId();
    
    print("Slave ID: " + slaveIdResponse);
  } finally {
    client.close();
  }
}

Multi slaves with one connection (Modbus RTU) #

import 'package:modbus/modbus.dart' as modbus;


main(List<String> arguments) async {
    
  var client = modbus.createTcpClient(
    '10.170.1.20',
    port: 1001,
    mode: modbus.ModbusMode.rtu,
  );
    
  try {
    await client.connect();
    
    client.setUnitId(100);
    var slaveIdResponse = await client.reportSlaveId();
    
    print("Slave ID: " + slaveIdResponse);

    client.setUnitId(150);
    var slaveIdResponse = await client.reportSlaveId();

    print("Slave ID: " + slaveIdResponse);
  } finally {
    client.close();
  }
}

Limitations #

SerialConnector is not implemented yet.

36
likes
140
points
354
downloads

Publisher

unverified uploader

Weekly Downloads

Simple Modbus client library for dart. Currently only the TCP connection is supported.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

logging

More

Packages that depend on modbus