modbus 0.1.0
modbus: ^0.1.0 copied to clipboard

MODBUS dart library.

modbus-dart #

MODBUS client library

pub package

Usage #

Single slave (MODBUS/TCP) #

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/TCP) #

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

11
likes
70
pub points
65%
popularity

Publisher

Unknown

MODBUS dart library.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

logging

More

Packages that depend on modbus