使用c#读取PLC数据失败,返回错误:S7.Net.PlcException: Received 12 bytes: '32-02-00-00-00-00-00-00-00-00-81-04', expected 19 bytes. ,大神帮忙看下是什么回事:
代码如下,PLC下面定义了数据块DB12
private void btnConnect_Click(object sender, System.EventArgs e)
{
using (var plc = new Plc(CpuType.S71200, "192.168.1.2", 0, 1))
{
try
{
plc.Open();
bool dbbool1 = (bool)plc.Read("DB12.DBX0.1");
var IntVa= (ushort)plc.Read("DB12.DBW2.0");
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}