public void Connect() { _comms.CommPort = SelectedPort; _comms.BaudRate = SelectedBaudRate; // Todo: check the status of this call success/failure if (!_comms.Connect()) { ConnectionState = SessionStates.Disconnected; ApmVersion = "Error"; return; } ConnectionState = SessionStates.Connecting; _connectionAttemptsTimer = new Timer(); _connectionAttemptsTimer.Tick += _connectionAttemptsTimer_Tick; _connectionAttemptsTimer.Interval = 1000; //milliseconds _connectionAttemptsTimer.Start(); }
private void btnHID_Click(object sender, EventArgs e) { HidDetailsForm f = new HidDetailsForm(); // load default settings f.VendorId = Settings.Default.VendorID; f.ProductId = Settings.Default.ProductID; f.UsagePage = Settings.Default.UsagePage; f.Usage = Settings.Default.Usage; f.ReportId = Settings.Default.ReportID; f.ReportPrefix = Convert.FromBase64String(Settings.Default.ReportPrefix); f.ReportSize = Settings.Default.ReportSize; if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // save default settings Settings.Default.VendorID = f.VendorId; Settings.Default.ProductID = f.ProductId; Settings.Default.UsagePage = f.UsagePage; Settings.Default.Usage = f.Usage; Settings.Default.ReportID = f.ReportId; Settings.Default.ReportPrefix = Convert.ToBase64String(f.ReportPrefix); Settings.Default.ReportSize = f.ReportSize; Settings.Default.Save(); string path = HidAPI.GetDevicePath(f.VendorId, f.ProductId, f.UsagePage, f.Usage); comms = new Hid(path, f.ReportId, f.ReportPrefix, f.ReportSize); if (comms.Connect()) KowhaiConnected(); else ConnectionFailed(); } }
private void btnSocket_Click(object sender, EventArgs e) { comms = new Sock(); if (comms.Connect()) KowhaiConnected(); else ConnectionFailed(); }