private void userButton23_Click(object sender, EventArgs e) { byte[] buffer = HslCommunication.BasicFramework.SoftBasic.HexStringToBytes("50 00 00 FF FF 03 00 0D 00 0A 00 01 14 01 00 64 00 00 90 01 00 10"); // 直接使用报文进行 OperateResult <byte[]> operate = melsec_net.ReadFromServerCore(buffer); if (operate.IsSuccess) { // 返回PLC的报文反馈,需要自己对报文进行结果分析 MessageBox.Show(HslCommunication.BasicFramework.SoftBasic.ByteToHexString(operate.Content)); } else { // 网络原因导致的失败 MessageBox.Show(operate.ToMessageShowString()); } }
private void button26_Click(object sender, EventArgs e) { try { OperateResult <byte[]> read = melsec_net.ReadFromServerCore(HslCommunication.BasicFramework.SoftBasic.HexStringToBytes(textBox13.Text)); if (read.IsSuccess) { textBox11.Text = "结果:" + HslCommunication.BasicFramework.SoftBasic.ByteToHexString(read.Content); } else { MessageBox.Show("读取失败:" + read.ToMessageShowString( )); } } catch (Exception ex) { MessageBox.Show("读取失败:" + ex.Message); } }