请到我的个人博客查看
modbus-tcp (整理的学习材料加免费的案例)
使用示例
//1、实例化客户端 - 输入正确的IP和端口
ModBusTcpClient client = new ModBusTcpClient(“192.168.3.199”, 502);
//2、写操作 - 参数依次是:地址 、值 、站号 、功能码
//var result = client.Write("0", (short)1, 0, 16);
//client.Write("5", (short)1, 1, 16);
var result = client.ReadInt16("5",1,3);
//var value = client.ReadInt16("4",1,3).Value;
//Console.WriteLine(result.Value);
Console.WriteLine(result.Response);
Console.WriteLine(result.Requst);
Console.WriteLine(result.Err);
Console.WriteLine(result.IsSucceed);