Beispiel #1
0
 private void SerialPort_StatusChanged(System.IO.Ports.SerialPort serialPort, SerialPort.Status status)
 {
     //throw new NotImplementedException();
     Debug.WriteLine(status);
 }
Beispiel #2
0
        private static void _port_StatusChanged(System.IO.Ports.SerialPort serialPort, SerialPort.Status status)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("{0} Status: ", _serialPort.PortName);

            switch (status)
            {
            case SerialPort.Status.OpenError:
                Console.ForegroundColor = ConsoleColor.Red;
                break;

            case SerialPort.Status.CloseError:
                Console.ForegroundColor = ConsoleColor.Red;
                break;

            case SerialPort.Status.Opened:
                Console.ForegroundColor = ConsoleColor.Green;

                _serialPort.Send(_modBus.BuildText(1, 0, 4, ""));

                break;

            default:
                Console.ForegroundColor = ConsoleColor.White;
                break;
            }

            Console.WriteLine("{0}", status);
            Console.ForegroundColor = ConsoleColor.White;
        }