public ArduinoCom(int baudrate, Parity parity, int startBits, StopBits stopBits) { try { arduinoSerialPort = new SerialPort(dbRead.GetComPort(1), baudrate, parity, startBits, stopBits); string port = dbRead.GetComPort(1);//leser comport fra database arduinoSerialPort.PortName = port; arduinoSerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); arduinoSerialPort.Open(); tmrCom.Tick += new EventHandler(timer_Tick); } catch (Exception) { MessageBox.Show("Could not open selected COM port. Make sure that the MySQL-server is running!"); } }
public frmSettings() { InitializeComponent(); FillTextBoxes(); //show list of valid com ports foreach (string s in SerialPort.GetPortNames()) { cboCOMPort.Items.Add(s); } cboCOMPort.Text = dbRead.GetComPort(1); //Fill cbo with current COM-port on start. }