Exemplo n.º 1
0
        public static bool Open()
        {
            try
            {
                if (serial.IsOpen)
                {
                    serial.Close();
                }
                serial.Open();


                if (thread != null)
                {
                    threadExit = true;
                    thread.Join();
                    thread.Abort();
                    thread = null;
                }
                thread = new Thread(new ThreadStart(ProcessData));
                thread.IsBackground = true;
                thread.Start();

                serial.DtrEnable      = true;
                serial.ErrorReceived += Serial_ErrorReceived;
                serial.DataReceived  += Serial_DataReceived;

                return(true);
            }
            catch (Exception e)
            {
                ClsMessageBox.Exception(e.Message);
            }

            return(false);
        }
Exemplo n.º 2
0
 public static void Close()
 {
     try
     {
         if (thread != null)
         {
             threadExit = true;
             thread.Join();
             thread.Abort();
             thread = null;
         }
         serial.Close();
     }
     catch (Exception e)
     {
         ClsMessageBox.Exception(e.Message);
     }
 }
Exemplo n.º 3
0
 private static void Serial_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     ClsMessageBox.Error(e.ToString());
 }