Skip to content
pubscout

modbus_client_tcp

1.2.3, released 2 years ago by cabella.net

Sends Modbus requests to remote devices via TCP/IP connections.

$ flutter pub add modbus_client_tcp
Source repository

What it does

Implements the Modbus TCP protocol for sending requests to remote devices over ethernet networks. It provides various Modbus element types like registers, coils, and discrete inputs, alongside auto-connection modes, timeout settings, and server discovery.

AI-written summary of version 1.2.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to communicate with industrial devices or servers using Modbus TCP/IP.
  • You want support for various data element types like numeric registers, bit masks, enums, and file records.

Skip it when

  • You are communicating over Serial ports or UDP instead of TCP/IP (use companion packages instead).
  • You do not need industrial Modbus protocol support.

Strengths

  • Includes built-in server discovery and connection timeout features for TCP.
  • Offers a rich variety of typed Modbus elements with built-in byte endianness and scaling support.

Weaknesses

  • Limited specifically to TCP/IP; requires separate packages for UDP or Serial communications.
  • Relies heavily on external Modbus server implementations and proper network configurations.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3

Add the package to pubspec.yaml and configure network permissions for TCP/IP socket access on target platforms.

import 'package:modbus_client/modbus_client.dart';
import 'package:modbus_client_tcp/modbus_client_tcp.dart';

void main() async {
  var batteryTemperature = ModbusInt16Register(
      name: "BatteryTemperature",
      type: ModbusElementType.inputRegister,
      address: 22,
      uom: "°C",
      multiplier: 0.1,
      onUpdate: (self) => print(self));

  var serverIp = await ModbusClientTcp.discover("192.168.0.0");
  if (serverIp == null) return;
  
  var modbusClient = ModbusClientTcp(serverIp, unitId: 1);
  await modbusClient.send(batteryTemperature.getReadRequest());
  modbusClient.disconnect();
}

Alternatives

Packages that do the same job and could replace modbus_client_tcp.

  • native_dio_adapter

    A Dio HTTP client adapter that uses native platform HTTP stacks via cupertino_http and cronet_http.

  • modbus

    Simple Modbus TCP client library for Dart.

  • nm

    Client for interacting with Linux NetworkManager via D-Bus

  • sse

    Bidirectional Server Sent Events client and server for Dart.

Works with

Packages commonly used together with modbus_client_tcp: ones it builds on, ones built on it, and its own family.