public void EnhancedSerialConnection_OpenAndDoubleClose()
        {
            var connection = new EnhancedSerialConnection();

            connection.Open();
            connection.Close();
            connection.Close();
        }
        public void EnhancedSerialConnection_OpenAndDoubleClose()
        {
            if (!AreSerialPortsAvailable())
            {
                return;
            }

            var connection = new EnhancedSerialConnection();

            connection.Open();
            connection.Close();
            connection.Close();
        }
Esempio n. 3
0
        static public ArduinoDeviceManager Connect(String port, SerialBaudRate bps, int timeOut, Action <ADMMessage, ArduinoDeviceManager> listener)
        {
            ISerialConnection connection = new EnhancedSerialConnection(port, bps);

            if (connection != null)
            {
                var session = new ArduinoSession(connection, timeOut);
                try
                {
                    var mgr = new ArduinoDeviceManager(session, listener, port);
                    return(mgr);
                } catch (Exception e)
                {
                    if (connection.IsOpen)
                    {
                        connection.Close();
                    }
                    throw e;
                }
            }

            return(null);
        }