private void writeBtn_Click(object sender, EventArgs e) { ushort w1 = 0; ushort w2 = 0; try { ulong u = ConvertFuncs.StrToULong(longTextBox.Text); FloatStruct fs = new FloatStruct(); fs.ULong = u; w1 = fs.Word1; w2 = fs.Word2; } catch { ErrorMessage(texts[9]); return; } ushort Addr = 0; if (!CheckAddr(out Addr)) { ErrorMessage(texts[6]); return; } serialPort.SetDataRTU(Addr, WriteDataRecieved, RequestPriority.Normal, w1, w2); }
private void textBox2_TextChanged(object sender, EventArgs e) { if ((!longTextBox.Focused) || nowReading) { return; } try { ulong u = ConvertFuncs.StrToULong(longTextBox.Text); FloatStruct fs = new FloatStruct(); fs.ULong = u; floatTextBox.Text = fs.Float.ToString(); } catch { } }