Skip to content

Instantly share code, notes, and snippets.

Created November 13, 2017 04:19
try
{
// Stop the data receive thread.
readThreadStop();
// Close the opened serial port.
m_clserial.SerialClose();
// Attempt to open the designated port.
m_clserial.SerialInit(index);
string manufacturer = "", portID = "";
uint version = 0;
CLAllSerial.GetPortInfo(index, ref manufacturer, ref portID, ref version);
// Set the GUI as necessary.
serialPortDropDown.Text = manufacturer + ", " + portID;
populateBaudRateDropDown();
// Restart the data receive thread.
m_readThread = new Thread(new ThreadStart(serialReadThreadFunc));
m_readThreadContinue = true;
m_readThread.Start();
}
catch (ApplicationException err)
{
MessageBox.Show("Serial port initialization failed: " + err.Message, "CLSerial Initialization Error");
Close();
Application.Exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment