private void ZeroBTN_Click(object sender, EventArgs e) { Port.Dispose(); Port = new SerialPort("COM" + COM.Value, int.Parse(baudRateCB.SelectedItem.ToString()), Parity.None, 8, StopBits.One); Code = (int)HexaInterface.Message_Codes.CODE_H26R0_ZEROCAL; //HexaInterface HexInter = new HexaInterface(COM.Value.ToString()); byte[] Payload = { channel }; DOT_NET_COMS_LIB.Message Buff = new DOT_NET_COMS_LIB.Message(DestinationID, SourceID, Options, Code, Payload); AllBuffer = Buff.GetAll(); // We get the whole buffer bytes to be sent to the Hexabitz modules. try { Port.Open(); } catch { } try { Port.Write(AllBuffer, 0, AllBuffer.Length); } catch { MessageBox.Show("Connection Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { Port.Close(); } catch { } //HexInter.SendMessage(Destination, Source, Options, Code, Message); connectionLBL.Text = "Zero Calibrated"; }
private void StopBTN_Click(object sender, EventArgs e) { Port.Dispose(); Port = new SerialPort("COM" + COM.Value, int.Parse(baudRateCB.SelectedItem.ToString()), Parity.None, 8, StopBits.One); Code = (int)HexaInterface.Message_Codes.CODE_H26R0_STOP; HexaInterface HexInter = new HexaInterface(COM.Value.ToString(), int.Parse(baudRateCB.SelectedItem.ToString())); byte[] Payload = new byte[0]; DOT_NET_COMS_LIB.Message Buff = new DOT_NET_COMS_LIB.Message(DestinationID, SourceID, Options, Code, Payload); AllBuffer = Buff.GetAll(); // We get the whole buffer bytes to be sent to the Hexabitz modules. // Here we call the platform sending protocol. // C# Example: try { Port.Open(); } catch { } try { Port.Write(AllBuffer, 0, AllBuffer.Length); } catch { MessageBox.Show("Connection Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { Port.Close(); } catch { } //HexInter.SendMessage(Destination, Source, Options, Code, Message); sevenSegmentArray1.Value = "STOP"; connectionLBL.Text = "Stopped"; }