예제 #1
0
 public Program()
 {
     var port = ConfigurationManager.AppSettings["PORT"];
     var ports = SerialPort.GetPortNames();
     if (ports.Length == 0)
     {
         Console.WriteLine("No available comm port!");
         return;
     }
     if (port == "AUTO")
         port = ports[0];
     if (ports.All(p => p != port))
     {
         Console.WriteLine("No available comm port!");
         return;
     }
     comm = new SerialComm(port);
     comm.DataArrivalEvent += CommandResponse;
 }
예제 #2
0
        public Program()
        {
            var port  = ConfigurationManager.AppSettings["PORT"];
            var ports = SerialPort.GetPortNames();

            if (ports.Length == 0)
            {
                Console.WriteLine("No available comm port!");
                return;
            }
            if (port == "AUTO")
            {
                port = ports[0];
            }
            if (ports.All(p => p != port))
            {
                Console.WriteLine("No available comm port!");
                return;
            }
            comm = new SerialComm(port);
            comm.DataArrivalEvent += CommandResponse;
        }