![hyperterminal serial hyperterminal serial](https://images.sftcdn.net/images/t_app-cover-l,f_auto/p/b09f7c90-96d3-11e6-acdb-00163ed833e7/1310064320/hyperterminal-private-edition-htpe-screenshot.jpg)
Converts an array of bytes into a formatted string of hex digits (example: E1 FF 1B) Private byte HexStringToByteArray(string s)īuffer = (byte)Convert.ToByte(s.Substring(i, 2), 16) The string containing the hex digits (with or without spaces) convert a string of hex digits (example: E1 FF 1B) to a byte array. If (error) MessageBox.Show(this, "Not properly formatted hex string: " + txtSend.Text + "\n", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Stop) if there is an error yuor program will not display a message instead of freezing.Ĭatch (UnauthorizedAccessException) Try //always try to use this try and catch method to open your port. If (cmbPortName.SelectedIndex != -1 & cmbBaudeRate.SelectedIndex != -1 & cmbParity.SelectedIndex != -1 &ĬmbDataBits.SelectedIndex != -1 & cmbStopBits.SelectedIndex != -1)ĬomPort.BaudRate = int.Parse(cmbBaudeRate.Text) //convert Text to integerĬomPort.Parity = (Parity)Enum.Parse(typeof(Parity), cmbParity.Text) //convert text to parityĬomPort.DataBits = int.Parse(cmbDataBits.Text) //convert text to stop bitsĬomPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), cmbStopBits.Text) //convert text to stopbits check if all settings have been selected Private SerialPort ComPort = new SerialPort() //Initialise ComPort Variable as SerialPort String ports = SerialPort.GetPortNames() Retrieve the list of all COM ports on your computer UpdatePorts() //Call this function everytime the page load Private void Form1_Load(object sender, EventArgs e) I tried searching but to no avail, really need this help. Thanks! I have these C# codes, but I want to let the C# to read through the HyperTerminal and send/receive data to the circuit.