问题描述
您好,
您如何将信息从C#发送到特定的PLC寄存器以及如何识别该注册表?
我正在使用EASYbodbus库
你给我一个错误我希望你能帮我看看它的含义:
EasyModbus.Exceptions.FunctionCodeNotSupportedException:
'主人不支持的功能代码'
我尝试过:
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Threading.Tasks;
使用EasyModbus;
namespace comunicacion_tcp
{
class program
{
private string IpAddress =192.168.178.111;
private int port = 502;
private ushort startAd dres = 0;
私人ushort数量= 2;
私人ModbusClient modbustcp;
公共计划()
{
modbustcp = new ModbusClient(IpAddress,port);
modbustcp.Connect();
int [] response = modbustcp.ReadInputRegisters( startAddres,quantity);
modbustcp.Disconnect();
Console.WriteLine(输入寄存器1的值+响应[0] .ToString());
Console.WriteLine(输入寄存器2的值+响应[1] .ToString());
}
static void Main( string [] args)
{
Program _program = new Program();
Console.ReadKey();
}
}
}
Hello,
How would you send the information to a specific PLC register from C # and how to identify that registry?
I'm using the EASYbodbus library
You are giving me an error I would like you to help me to what it refers to:
EasyModbus.Exceptions.FunctionCodeNotSupportedException:
'Function code not supported by master'
What I have tried:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EasyModbus;
namespace comunicacion_tcp
{
class Program
{
private string IpAddress = "192.168.178.111";
private int port = 502;
private ushort startAddres = 0;
private ushort quantity = 2;
private ModbusClient modbustcp;
public Program()
{
modbustcp = new ModbusClient(IpAddress, port);
modbustcp.Connect();
int[] response = modbustcp.ReadInputRegisters(startAddres, quantity);
modbustcp.Disconnect();
Console.WriteLine("value of input register 1" + response[0].ToString());
Console.WriteLine("value of input register 2" + response[1].ToString());
}
static void Main(string[] args)
{
Program _program = new Program();
Console.ReadKey();
}
}
}
推荐答案
这篇关于Comunicacion进入Visual Studio C#y un PLC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!