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

Modbus TCP/RTU adapter for mcp_io. Implements AdapterBase (4-Primitive Contract) with FC01/03/05/06/15/16 support.

mcp_io_modbus #

Modbus adapter for mcp_io — full Modbus TCP / RTU / ASCII over a single 4-Primitive surface, with industrial PLC mappings and a vendor profile catalog.

Capability matrix #

Area Support
Wire TCP (MBAP), RTU (CRC-16), ASCII (LRC), RTU-over-TCP gateway
Function codes FC01-06, FC15, FC16 + exception responses 0x01..0x0B
Data types BOOL, INT16/UINT16, INT32/UINT32, INT64/UINT64, FLOAT32, FLOAT64, STRING, BCD
Byte order ABCD / DCBA / BADC / CDAB (full matrix)
Tag mapping TagDefinition (name → area + offset + dataType + byteOrder + scaling + unit + access)
Bulk read Adjacent registers auto-coalesced (≤ 125 register/call)
Subscribe Polling (interval / change-of-value)
Vendor catalog Siemens S7 · Mitsubishi MELSEC · Schneider Modicon · WAGO 750 · Beckhoff TwinCAT · Rockwell ControlLogix · ABB AC500

Modbus TCP #

import 'package:mcp_io_modbus/mcp_io_modbus.dart';

final adapter = ModbusTcpAdapter(
  deviceId: 'plc-1',
  unitId: 1,
  transport: TcpModbusTransport(host: 'plc.local', port: 502),
);
adapter.tags.register(const TagDefinition(
  name: 'temperature',
  area: ModbusArea.holding,
  offset: 1001,
  dataType: ModbusDataType.float32,
  byteOrder: ByteOrder.cdab,
  unit: '°C',
));
await adapter.connect();

final r = await adapter.read(const ReadSpec(targets: ['/tag/temperature']));
print(r.items.first.envelope?.payload.value);

Modbus RTU / ASCII #

ModbusRtuClient mirrors the half-duplex serial-line semantics over any ModbusByteTransport. ModbusRtuAdapter exposes the same 4-Primitive surface as the TCP adapter (capabilities, tag mapping, bulk read, polling) — only the wire framing differs.

import 'package:mcp_io_modbus/mcp_io_modbus.dart';
import 'package:mcp_io_modbus/io.dart'; // TcpModbusByteTransport

// Option A — Modbus RTU over a TCP gateway (Moxa NPort, ICP DAS, ...).
final transport = TcpModbusByteTransport(host: '10.1.2.3', port: 502);
final client = ModbusRtuClient(transport: transport);
final adapter = ModbusRtuAdapter(deviceId: 'plc-2', unitId: 1, client: client);

// Option B — Modbus RTU over a real serial port: bridge a SerialTransport
// from `mcp_io_serial` into a ModbusByteTransport (a few-line adapter).

PLC vendor profiles #

Pre-built profiles bundle a vendor's default byte order, named memory-area resolver (Mitsubishi D{n} / M{n} / Schneider %MW{n} / ...), and helpers:

final profile = ModbusPlcProfiles.mitsubishiMelsec;
adapter.tags.register(buildTagFromNamedAddress(
  profile: profile,
  tagName: 'flowRate',
  namedAddress: 'D100',
  dataType: ModbusDataType.float32,
)!);
// Profile's default BADC byte order is applied automatically.

Heuristic vendor matching: ModbusPlcProfiles.fromVendorString('Siemens S7-1500')siemensS7 profile.

License #

MIT — see LICENSE.

0
likes
150
points
213
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Modbus TCP/RTU adapter for mcp_io. Implements AdapterBase (4-Primitive Contract) with FC01/03/05/06/15/16 support.

Homepage
Repository (GitHub)
View/report issues

Topics

#io #mcp #modbus #industrial #adapter

License

MIT (license)

Dependencies

mcp_bundle, mcp_io, meta

More

Packages that depend on mcp_io_modbus