Exemple #1
0
        private void FillSerialPortList(StringBuilder builder)
        {
            this.serialPortList.Items.Add(string.Empty);

            this.serialPortList.Items.Add(SsmUtility.MockEcuDisplayName);

            if (SsmUtility.OpenPort20Exists())
            {
                this.serialPortList.Items.Add(SsmUtility.OpenPort20DisplayName);
            }

            foreach (string portName in System.IO.Ports.SerialPort.GetPortNames())
            {
                this.serialPortList.Items.Add(portName);
                builder.AppendLine("Added serial port " + portName);
            }
        }
Exemple #2
0
        private void serialPortList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.stream != null)
            {
                this.stream.Dispose();
                this.stream = null;
            }

            if (this.port != null)
            {
                this.port.Dispose();
                this.port = null;
            }

            try
            {
                if ((this.serialPortList.SelectedItem == null) ||
                    this.serialPortList.SelectedItem.ToString() == string.Empty)
                {
                    this.summary.Text = "No serial port selected";
                    return;
                }

                string portName = this.serialPortList.SelectedItem.ToString();
                int    baudRate = int.Parse(this.bitRates.SelectedItem.ToString());
                this.stream = SsmUtility.GetDataStream(
                    portName,
                    baudRate,
                    ref this.port,
                    delegate(string line) { });

                this.summary.Text = "Opened " + portName;
            }
            catch (Exception ex)
            {
                this.summary.Text = ex.ToString();
            }
        }
Exemple #3
0
        /// <summary>
        /// Initialize the list of available serial ports.
        /// </summary>
        private void InitializeSerialPortList()
        {
            ignoreSerialPortChangeNotifications = true;

            if (SsmUtility.OpenPort20Exists())
            {
                Trace("Lumberjack.OpenPort20Exists: OpenPort 2.0 found.");
                this.ui.AddSsmSerialPort(SsmUtility.OpenPort20DisplayName);
            }
            else
            {
                Trace("Lumberjack.OpenPort20Exists: OpenPort 2.0 not found.");
            }

            this.ui.AddSsmSerialPort(MockEcuStream.PortName);
            this.ui.AddPlxSerialPort(ExternalSensors.NullSerialPortName);
            foreach (string name in System.IO.Ports.SerialPort.GetPortNames())
            {
                this.ui.AddSsmSerialPort(name);
                this.ui.AddPlxSerialPort(name);
            }

            ignoreSerialPortChangeNotifications = false;
        }