/// <summary> /// Sending the array of delays to arduino, and recive data from arduino when done operation /// </summary> /// <param name="stackPanel">Stack panel with selected combination of speed</param> private void sendData() { try { if (isReConnectNeed) { connection = new ConnectionToArduino(); } isReConnectNeed = false; foreach (var item in delay) { if (!connection.myPort.IsOpen) { connection.myPort.Open(); } connection.myPort.Write(item); connection.myPort.ReadLine(); } } catch (IOException portEx) { MessageBox.Show("Connection problem, can`t find device", "Information", MessageBoxButton.OK, MessageBoxImage.Warning); isReConnectNeed = true; } catch (Exception ex) { MessageBox.Show("Something goes wrong ...", "Information", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void ConnectionToArduinoShouldInit() { ConnectionToArduino con = new ConnectionToArduino(); Assert.IsNotNull(con.myPort); }