1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58:
| private void button3_Click(object sender, EventArgs e) { if (radioButton1.Checked) { try { byte[] busy = new byte[1]; COM1.Open(); COM1.Write("U"); System.Threading.Thread.Sleep(1); int message = COM1.ReadByte(); COM1.Close();
if (message == 85) { MessageBox.Show("Programmiermodus OK!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); btn_send.Enabled = true; }
} catch { MessageBox.Show("COM1 nicht verfügbar." + Environment.NewLine + "Bitte einen anderen Port wählen", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
} } else if (radioButton2.Checked) { try { byte[] busy = new byte[1]; COM2.Open(); COM2.Write("U"); System.Threading.Thread.Sleep(1); int message = COM2.ReadByte(); COM2.Close(); if (message == 85) { MessageBox.Show("Programmiermodus OK!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); btn_send.Enabled = true;
} } catch { MessageBox.Show("COM2 nicht verfügbar." + Environment.NewLine + "Bitte einen anderen Port wählen", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
} |