private void fetchCom() { String[] ports = System.IO.Ports.SerialPort.GetPortNames(); foreach (String port in ports) { comboBox1.Items.Add(port); } if (ports.Length < 1) { comboBox1.Items.Add("No ports available"); } comboBox1.SelectedItem = ports[0]; ArduinoClass.makePort(comboBox1.SelectedItem.ToString()); StartButton.Visible = true; }
private void button1_Click(object sender, EventArgs e) { try { if (ArduinoClass.makePort(comboBox1.SelectedItem.ToString()) == true) { StatusText.ForeColor = Color.Green; StatusText.Text = "ARDUINO CONNECTED"; StartButton.Visible = true; } else { StatusText.ForeColor = Color.Red; StatusText.Text = "NO CONNECTION"; } } catch (Exception) { Error.show("No port selected", "Error"); } }
private void Extraladen() { ArduinoClass bootup = new ArduinoClass(); if (!config) { bootup.makePort("COM6"); config = true; } PinInvoer pinInvoer = new PinInvoer(); Home home = new Home(); ArduinoData arduino = new ArduinoData(); Hash security = new Hash(); Executer executer; Boolean reset = false; Boolean pinCorrect; String[] pasInformation; bool EE = true; try { while (true) { pinCorrect = false; pasInformation = new String[4]; reset = false; executer = null; String KlantID; String rekeningID; String pasID; HTTPget httpget = new HTTPget(); HTTPpost httppost = new HTTPpost(); while (true) { //String emu = ("AAAAAA\n11248649\n1004\n,NEWUID"); String s = arduino.getFirstString(); if (s.Contains("NEWUID")) { pasInformation = s.Split('\n', '\n', '\n'); KlantID = pasInformation[2]; rekeningID = pasInformation[1]; pasID = pasInformation[0]; //Error.show(rekeningID + "," + KlantID + "," + pasID); //Error.show("PasID: " + pasID + "\nRekID: " + rekeningID + "\nKlantID: " + KlantID); pinInvoer.giveInfo(pasInformation); home.giveInfo(pasInformation); //Error.show(KlantID); //Error.show(rekeningID); //Error.show(pasID); executer = new Executer(rekeningID, KlantID, arduino, pasID); break; } } pinInvoer.Show(); Thread.Sleep(1); this.Close(); break; } } catch (Exception) { OutOfOrder error = new OutOfOrder(); error.Show(); error.Refresh(); List <Form> openForms = new List <Form>(); foreach (Form f in Application.OpenForms) { openForms.Add(f); } foreach (Form f in openForms) { if (f.Name != "OutOfOrder") { f.Close(); } } while (true) { } //Loop forever :) } }