private void OnConnectButtonClick(object sender, EventArgs e) { try { var selectedItem = comPortComboBox.SelectedItem; if (selectedItem == null) { MessageBox.Show(Resources.NoComPortSelected); return; } ChangeInteractionState(false); var configurator = SerialConfigurator.GetInstance(selectedItem.ToString(), 57600, saveLogCheckBox.Checked); _controllerBase = new ThinkGearController(); _controllerBase.DataReceived += OnThinkGearDataReceived; if (_controllerBase.Connect(configurator)) { return; } MessageBox.Show(Resources.ConnectionFailureMessage); ChangeInteractionState(true); } catch (Exception exception) { MessageBox.Show(exception.ToString()); ChangeInteractionState(true); } }
public override bool Connect(SerialConfigurator configurator) { try { _serialPort = new SerialPort(configurator.ComPort, configurator.BaudRate, Parity.Even); _serialPort.DataReceived += (sender, args) => DataReceived(sender, args); _serialPort.Open(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
private void OnArduinoConnectClick(object sender, EventArgs e) { var selectedItem = arduinoPortsComboBox.SelectedItem; if (selectedItem == null) { MessageBox.Show(Resources.NoComPortSelected); return; } ChangeInteractionState(false); var configurator = SerialConfigurator.GetInstance(selectedItem.ToString(), 9600, saveLogCheckBox.Checked); _controllerBase = new ArduinoController(); _controllerBase.DataReceived += OnThinkGearDataReceived; if (_controllerBase.Connect(configurator)) { return; } MessageBox.Show(Resources.ConnectionFailureMessage); ChangeInteractionState(true); }
public override bool Connect(SerialConfigurator configurator) { return(_gearWrapper.Connect(configurator.ComPort, configurator.BaudRate, true, configurator.SaveLog)); }
public abstract bool Connect(SerialConfigurator configurator);