private void button4_Click(object sender, EventArgs e) { // SetBar(0, 100); byte[] RxBuffer = new byte[100]; textBox11.Text = null; GetBoxToStruct(ref ModBus); byte[] Buf = new byte[ModBus.MsgLength + 9]; ModBusClass.ModBus_CreatBuf(ref ModBus, ref Buf); bool R = Usart.SendData(serialPort1, Buf, Buf.Length, ref RxBuffer, 100); if (ModBus.TargetAddr != ModBusClass.BroadAddr & R) { textBox11.Text = Tools.HexToString(RxBuffer); } ModBusClass.ModBus_CreatStruct(ref ModBus, RxBuffer); }
private float GetValue(byte OffSet) { MB TempMB = new MB(); byte[] Buf = new byte[100]; ModBus.TargetAddr = ModBusClass.TargetAddr; ModBus.HostAddr = ModBusClass.HostAddr; ModBus.MsgFlag = 0x13; ModBus.MsgNum = 1; ModBus.DataLength = 0; ModBus.DataFlag = OffSet; ModBus.MsgLength = ModBus.DataLength + 3; ModBus.Data = Tools.StringToHex(textBox8.Text); ModBusClass.ModBus_CreatBuf(ref ModBus, ref Buf); SetBoxFromStruct(ModBus); button3_Click(null, null); button4_Click(null, null); ModBusClass.ModBus_CreatStruct(ref TempMB, Tools.StringToHex(textBox11.Text)); float TempF = Tools.ByteToFloat(TempMB.Data, 0, 1); byte[] Fbuf = new byte[4]; return(TempF); }