private void button25_Click(object sender, EventArgs e) { try { OperateResult <byte[]> read = melsecSerial.Read(textBox6.Text, ushort.Parse(textBox9.Text)); if (read.IsSuccess) { textBox10.Text = "结果:" + HslCommunication.BasicFramework.SoftBasic.ByteToHexString(read.Content); } else { MessageBox.Show("读取失败:" + read.ToMessageShowString( )); } } catch (Exception ex) { MessageBox.Show("读取失败:" + ex.Message); } }
private void test5( ) { OperateResult <byte[]> read = melsecSerial.Read("D100", 10); if (read.IsSuccess) { int count = melsecSerial.ByteTransform.TransInt32(read.Content, 0); float temp = melsecSerial.ByteTransform.TransSingle(read.Content, 4); short name1 = melsecSerial.ByteTransform.TransInt16(read.Content, 8); string barcode = Encoding.ASCII.GetString(read.Content, 10, 10); } }