Skip to content

fa-yoshinobu/plc-comm-slmp-dotnet

Repository files navigation

CI Documentation

.NET 9.0 License: MIT

A modern .NET SLMP client for Mitsubishi PLC communication over Binary 3E/4E frames.

Why This Library

  • Fast binary 3E/4E transport with auto profile resolution
  • End-user friendly API + CLI for quick validation
  • Single-connection queue (QueuedSlmpClient) for unstable TCP environments
  • Clear device-code support list (see below)

Quick Start (Copy/Paste)

dotnet build PlcComm.Slmp.sln
dotnet run --project samples/PlcComm.Slmp.Cli -- connection-check --host 192.168.250.101 --series auto --frame-type auto

Optional UDP check:

dotnet run --project samples/PlcComm.Slmp.Cli -- connection-check --host 192.168.250.101 --port 1027 --transport udp --series auto --frame-type auto

Core Features

  • TCP / UDP transport
  • Binary 3E / 4E request-response framing
  • Compatibility mode (legacy / iqr)
  • Device parser (D100, X10, etc.)
  • Read/Write words and bits
  • Read type name
  • Remote controls (run/stop/pause/latch clear/reset) and clear error
  • Auto profile resolution (3E/4E + legacy/iqr) with simple probing
  • Target parser (SELF, SELF-CPU1..4, NWx-STy, NAME,NETWORK,STATION,MODULE_IO,MULTIDROP)
  • Compatibility probe CLI report output (markdown + json)
  • Compatibility matrix renderer (compatibility-matrix-render)
  • G/HG Extended Specification coverage CLI (read/write-check)
  • Appendix1 device recheck + read-soak + mixed-read-load + tcp-concurrency probes
  • QueuedSlmpClient for single-connection serialized app-side reuse

Device Support (PLC Device Codes)

This list reflects device codes accepted by the parser and typed APIs. Actual availability depends on PLC model, firmware, and access settings.

Group Codes Status Notes
Bit devices (direct) SM, X, Y, M, L, F, V, B, TS, TC, STS, STC, CS, CC, SB, DX, DY Supported X/Y/B/SB/DX/DY use hexadecimal numbering.
Word devices (direct) SD, D, W, SW, TN, STN, CN, Z, LZ, R, ZR, RD Supported W/SW use hexadecimal numbering.
Long timer / counter families LTS, LTC, LTN, LSTS, LSTC, LSTN, LCS, LCC, LCN Supported (direct) Some PLCs reject direct access; validate on the target.
Extended Specification qualified devices Uxx\\Gyy, Uxx\\HGyy Supported via Extended Specification APIs Direct G/HG access is not supported.
Link direct devices J□\\device (e.g. J2\\SW10, J1\\X10) Supported via Extended Specification APIs CC-Link IE network device access. Use ReadWordsExtendedAsync / ReadBitsExtendedAsync.
Not supported S Not supported Step relay (S) is intentionally disabled.

Use Cases

  • Quick on-site health check of PLCs (SM/D reads, type name when supported).
  • Gateway services that normalize SLMP data for MES/SCADA or data lakes.
  • Multi-station diagnostics with a single shared connection (QueuedSlmpClient) for unstable TCP environments.

TCP concurrency practical note (current environment): direct multi-connection TCP is unstable beyond one connection on TCP/1025. Prefer single-connection sharing. Auto profile resolution is cached per process, so --series auto --frame-type auto no longer adds repeated probe overhead within one run.

Library Auto-Recommend Example

using var client = new SlmpClient("192.168.250.101", 1025, SlmpTransportMode.Tcp)
{
    TargetAddress = SlmpTargetParser.ParseNamed("SELF").Target,
};

await client.OpenAsync();
var profile = await client.ResolveProfileAsync();
Console.WriteLine($"frame={profile.FrameType}, series={profile.CompatibilityMode}, class={profile.ProfileClass}");

Library Single-Connection Queue Example

using var client = new SlmpClient("192.168.250.101", 1025, SlmpTransportMode.Tcp)
{
    TargetAddress = SlmpTargetParser.ParseNamed("SELF").Target,
};
await using var queued = new QueuedSlmpClient(client);

var profile = await queued.ResolveProfileAsync();
queued.FrameType = profile.FrameType;
queued.CompatibilityMode = profile.CompatibilityMode;
await queued.OpenAsync();

var workers = Enumerable.Range(0, 4).Select(async _ =>
{
    var sm400 = await queued.ReadBitsAsync(new SlmpDeviceAddress(SlmpDeviceCode.SM, 400), 1);
    var d1000 = await queued.ReadWordsRawAsync(new SlmpDeviceAddress(SlmpDeviceCode.D, 1000), 1);
});
await Task.WhenAll(workers);

Documentation

Parity Status

Target is parity with plc-comm-slmp-python. Current implementation is a functional core subset. Remaining parity work is tracked in TODO.md.

License

Distributed under the MIT License.

About

Modern .NET client for Mitsubishi SLMP. Optimized for iQ-R and Q series via Binary 3E/4E communication.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors