Exemple #1
0
        public bool openPortCom(string _name, int _baud)
        {
            try
            {
                if (port != null)
                {
                    closePortCom();
                }
                this.port = new PortCOM(_name, _baud, serialPort1_DataReceived);

                if (!port.IsOpen)
                {
                    port = null;
                    return(false);
                }


                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                port = null;
                return(false);
            }
        }
Exemple #2
0
        public bool closePortCom()
        {
            port.ReadExisting();
            port.Close();
            port.Dispose();
            this.port = null;

            return(false);
        }