diff --git a/PinkConnection2-TestApp/PinkConnection2-TestApp/MainForm.cs b/PinkConnection2-TestApp/PinkConnection2-TestApp/MainForm.cs index f893f7a..29338ee 100644 --- a/PinkConnection2-TestApp/PinkConnection2-TestApp/MainForm.cs +++ b/PinkConnection2-TestApp/PinkConnection2-TestApp/MainForm.cs @@ -79,6 +79,11 @@ namespace PinkConnection2_TestApp void sendFrame() { + if (port == null) + { + MessageBox.Show("Please select a serial port"); + return; + } byte byte1 = (byte)(64 | ((b & 8) | (b & 4) | (b & 2) | (b & 1))); byte byte2 = (byte)(64 | (((b & 128) | (b & 64) | (b & 32) | (b & 16)) >> 4)); port.Write(((char)byte1).ToString()); @@ -89,7 +94,12 @@ namespace PinkConnection2_TestApp { if (CommandTextBox.Text.Length != 2) { - MessageBox.Show("Command Length must not be less than 2"); + MessageBox.Show("Command length must not be less than 2"); + return; + } + if (port == null) + { + MessageBox.Show("Please select a serial port"); return; } port.Write(CommandTextBox.Text);