public void Dispose() { var s = serial; serial = null; datec = null; if (s.IsOpen) { s.Close(); } s.Dispose(); }
public string[] InitDp25(string portName) { try { serial = new SerialPort(portName, 115200, Parity.None, 8, StopBits.One) { ReadTimeout = 1500, WriteTimeout = 1500 }; serial.Open(); datec = new DatecProtocol(serial.Write, serial.Read); return(datec.Exec(74)); } catch (Exception ex) { Dispose(); return(new string[] { ex.Message, "" }); } }