McpX is a library for communicating with Mitsubishi Electric PLCs using the MC protocol.
It features a simple and easy-to-use API, allowing you to communicate without worrying about MC protocol details.
It runs on various platforms, including Linux, Windows, and macOS.
dotnet add package McpXPM> NuGet\Install-Package McpXusing McpXLib;
using McpXLib.Enums;
// Connect to PLC by specifying IP and port
using (var mcpx = new McpX("192.168.12.88", 10000))
{
// Read 7000 points starting from M0
bool[] mArr = mcpx.BatchRead<bool>(Prefix.M, "0", 7000);
// Read 7000 words starting from D1000
short[] dArr = mcpx.BatchRead<short>(Prefix.D, "1000", 7000);
// Write 1234 to D0 and 5678 to D1 as signed 32-bit integers
mcpx.BatchWrite<int>(Prefix.D, "0", [1234, 5678]);
}C# and Visual Basic samples are available here.
| Name | Description | Synchronous Method | Asynchronous Method |
|---|---|---|---|
| Single Read | Reads a single value from the specified device. | Read<T>(Prefix prefix, string address) |
ReadAsync<T>(Prefix prefix, string address) |
| Single Write | Writes a single value to the specified device. | Write<T>(Prefix prefix, string address, T value) |
WriteAsync<T>(Prefix prefix, string address, T value) |
| Batch Read | Reads multiple consecutive values starting from the specified address. | BatchRead<T>(Prefix prefix, string address, ushort length) |
BatchReadAsync<T>(Prefix prefix, string address, ushort length) |
| Batch Write | Writes an array of values to consecutive device addresses. | BatchWrite<T>(Prefix prefix, string address, T[] values) |
BatchWriteAsync<T>(Prefix prefix, string address, T[] values) |
| Random Read | Reads values from non-consecutive devices (bit / word / double-word). | RandomRead(Action<RandomReadBuilder> build) |
RandomReadAsync(Action<RandomReadBuilder> build) |
| Random Write | Writes values to non-consecutive devices (bit / word / double-word). | RandomWrite(Action<RandomWriteBuilder> build) |
RandomWriteAsync(Action<RandomWriteBuilder> build) |
| Monitor Registration | Registers devices to monitor and returns a MonitorSession. |
MonitorRegist(Action<MonitorBuilder> build) |
MonitorRegistAsync(Action<MonitorBuilder> build) |
| Monitor Read | Reads the latest values of registered devices via the returned session. | MonitorSession.Read() |
MonitorSession.ReadAsync() |
| Remote Password Lock/Unlock | Automatically locks the PLC with the specified remote password when the instance is created and unlocks it when disposed. | McpX(string ip, int port, string? password = null) |
– |
- TCP
- UDP
- 3E frame (binary code)
- 3E frame (ASCII code)
- 4E frame (binary code)
- 4E frame (ASCII code)
-
3E frame (ASCII code) support -
4E frame (binary code) support -
4E frame (ASCII code) support -
UDP support - GX Simulator support – In progress
- mcpx-mcp-server An MCP(Model Context Protocol) server that enables real-time access to Mitsubishi Electric PLC devices from generative AI.
