protected USB2LCD.VersionInfo GetCOMVersion(string port) { COM c = null; USB2LCD.VersionInfo v = new USB2LCD.VersionInfo(); try { c = new COM(port, 9600); v.version = c.ReadByte(USB2LCD.Command.ReadVersion); v.module = c.ReadByte(USB2LCD.Command.ReadModuleType); v.serialnumber = c.ReadShort(USB2LCD.Command.ReadSerialNum);; c.Close(); } catch (COMException ex) { ex.Show(this); } catch (Exception ex) { MessageBox.Show(this, "The COM port caused an error:\n"+ex.Message, "COM Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (c != null) c.Close(); } return v; }
protected USB2LCD.VersionInfo GetVersion() { COM c = null; USB2LCD.VersionInfo v = new USB2LCD.VersionInfo(); try { c = new COM(port, Baud); v.version = c.ReadByte(USB2LCD.Command.ReadVersion); v.module = c.ReadByte(USB2LCD.Command.ReadModuleType); v.serialnumber = c.ReadShort(USB2LCD.Command.ReadSerialNum); c.Close(); } catch (COMException ex) { ex.Show(this); } catch (Exception ex) { ShowErrorMessage("The COM port caused an error:\n"+ex.Message, "COM Error"); } finally { if (c != null) { c.Close(); } } return v; }