示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArduinoSession"/> class.
        /// </summary>
        /// <param name="connection">The serial port connection</param>
        /// <exception cref="System.ArgumentNullException">connection</exception>
        public ArduinoSession(ISerialConnection connection)
        {
            _connection        = connection ?? throw new ArgumentNullException(nameof(connection));
            _gotOpenConnection = connection.IsOpen;

            if (!connection.IsOpen)
            {
                connection.Open();
            }

            _connection.DataReceived += SerialDataReceived;
        }
 public void OpenConnection(string serialPortNumber, int baudRate, Parity parity, StopBits stopBits, int dataBits, Handshake handshake, NewLine newLine, ReadMode readMode)
 {
     _serialConnection.Open(serialPortNumber, baudRate, parity, stopBits, dataBits, handshake, newLine, readMode);
     _serialConnection.PortDataRead += DataReceived;
 }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArduinoSession"/> class.
        /// </summary>
        /// <param name="connection">The serial port connection</param>
        /// <exception cref="System.ArgumentNullException">connection</exception>
        public ArduinoSession(ISerialConnection connection)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");

            _connection = connection;
            _gotOpenConnection = connection.IsOpen;

            if (!connection.IsOpen)
                connection.Open();

            _connection.DataReceived += SerialDataReceived;
        }
 public Gemini2000ClockReader(int clockAddress, string portName)
 {
     this.clockAddress = clockAddress;
     serialConnection  = SerialConnectionFactory.GetSerialConnection(portName, baudRate, parity, dataBits, stopBits, isOverlappedRead);
     serialConnection.Open();
 }