modbus_client_tcp
1.2.3, released 2 years ago by cabella.net
Sends Modbus requests to remote devices via TCP/IP connections.
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.
87Compare - modbus
Simple Modbus TCP client library for Dart.
45Compare - nm
Client for interacting with Linux NetworkManager via D-Bus
81Compare - sse
Bidirectional Server Sent Events client and server for Dart.
80Compare
Works with
Packages commonly used together with modbus_client_tcp: ones it builds on, ones built on it, and its own family.
- loggingmodbus_client_tcp depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- synchronizedmodbus_client_tcp depends on itLock mechanism to prevent concurrent access to asynchronous code.
- modbus_clientmodbus_client_tcp depends on itBase Modbus client package for sending requests via Serial and TCP/IP.