private void button1_Click(object sender, EventArgs e) { float DeF_X = Convert.ToSingle(AxisX.Text); float DeF_Y = Convert.ToSingle(AxisY.Text); CarPosition.Refresh(); SSHInfo.Clear(); DrawingPlot(); DrawingRectangle((int)Math.Floor(DeF_X / 10), (int)Math.Floor(DeF_Y / 10)); DrawingLine((int)Math.Floor(DeF_X / 10), (int)Math.Floor(DeF_Y / 10)); previousX = CarPosition.Width / 2; previousY = CarPosition.Height / 2; RPi = new SshClient(IPBox.Text, UsernameBox.Text, PasswordBox.Text); RPi.Connect(); shell = RPi.CreateShellStream("shell", 100, 100, 100, 100, 1024); shell.Write("python3 /home/pi/Documents/fuzzy/fuzzy_script.py \n"); shell.Write(Convert.ToString(DeF_X) + "\n"); shell.Write(Convert.ToString(DeF_Y) + "\n"); shell.Flush(); bool fl = true; int counter = 0; while (fl) { if (shell != null && shell.DataAvailable) { string[] info; string data = shell.Read(); if (counter > 56) { char[] deter = { '\r', '\n' }; info = data.Split(deter); foreach (string s in info) { if (s == "") { continue; } SSHInfo.AppendText(s + "\r\n"); if (s == "DONE" || s == "Terminated") { fl = false; shell.Close(); RPi.Disconnect(); break; } if (s[0] == 'D') { SensorReading.Clear(); SensorReading.ForeColor = Color.Black; SensorReading.AppendText(s); } if (s[0] == 'P') { PWM.Clear(); PWM.AppendText(s); } if (s[0] == 'S') { Speed.Clear(); Speed.AppendText(s); } if (s[0] == 'T') { TraveledDistance.Clear(); TraveledDistance.AppendText(s); } if (s[0] == 'X') { drawRobotWay(Convert.ToSingle(s.Substring(4, s.IndexOf(':') - 4)), Convert.ToSingle(s.Substring(s.IndexOf(':') + 5))); } } } else { counter++; data = null; } } } }